Pillar jinja error on iteritems

0 votes

I was trying to use the iterations via piller data and jinja template.  I am using most of the template from a working salt/pillar installation. But now its failing to work in new environment.

I have tried several different syntaxes with the implementation of the iteration but still get same error.

Rendering SLS 'base:pillar_lab_user' failed: Jinja variable 'str object' 

Jinja Template

{% set users = salt['pillar.get']('XXXXXXX') %}
{% for user, args in users.iteritems() %}
{{ user }}:
  user.present:
    - fullname: {{ args.fullname }}
    - uid: {{ args.uid }}
    - gid_from_name: True
    - shell: {{ args.shell }}
{% if not args.empty_password == true %}
    - password: {{ args.password }}
{% else %}
    - empty_password: {{ args.empty_password }}
{% endif %}
{% if 'groups' in args %}
    - groups: {{ args['groups'] }}
{% endif %}
{% endfor %}

Pillar Data

users:

  user1:
    fullname: User1 Fullname
    uid: 951
    gid: 951
    shell: /bin/bash
    groups:
      - sudo
      - admin
    password: (REMOVED)
    pub_ssh_keys: (REMOVED)
  user2:
    fullname: User2 Fullname
    uid: 955
    gid: 955
    shell: /bin/bash
    groups:
     - sudo
     - admin
    password: (REMOVED)
    pub_ssh_keys: (REMOVED)
Jul 23, 2018 in Other DevOps Questions by Hannah
• 18,520 points
1,999 views

1 answer to this question.

0 votes

Your data should fail with :
Rendering SLS 'base:so' failed: Jinja variable 'dict object' has no attribute 'empty_password'

The error that you’re seeing is probably because of non-existing pillar data.

You've pasted full pillar data but left XXXXXXX in state file.

Try using this

{% set users = salt['pillar.get']('users') %}

Or

check if you use pillarenv, then remember to pass the correct one, you can simply verify this in command line:

salt 'your minion' pillar.get users

If it doesn't return your dictionary then try:

salt 'your minion' pillar.get users pillarenv=your_pillar_env

or

It could be a user the pillar configuration was not formed properly

Removed the first line "{% set users = salt['pillar.get']('XXXXXXX') %}" 

It wont use pillar.get

This should work fine

answered Jul 23, 2018 by Kalgi
• 52,350 points

Related Questions In Other DevOps Questions

0 votes
1 answer

How to get issues count based on rules in a sonar project?

There are API docs in the footer ...READ MORE

answered May 4, 2018 in Other DevOps Questions by DareDev
• 6,890 points
2,843 views
0 votes
1 answer

Setting up CICD on a local server

As to how to integrate git repo ...READ MORE

answered May 31, 2018 in Other DevOps Questions by ajs3033
• 7,300 points

edited May 31, 2018 by ajs3033 1,067 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
+2 votes
1 answer
0 votes
1 answer

Unable to Pull image from quay.io: ERROR x509: certificate signed by unknown authority

Download necessary CA certificate. "/etc/ssl/certs/ca-certificates.crt", -> Debian/Ubuntu "/etc/pki/tls/certs/ca-bundle.crt", ...READ MORE

answered Jul 3, 2018 in Other DevOps Questions by Kalgi
• 52,350 points
3,918 views
0 votes
1 answer

Capistrano deploy error saying "end of file reached" while deploying to Ubuntu server

Seems like Capistrano can't connect to the server ...READ MORE

answered Jul 3, 2018 in Other DevOps Questions by Kalgi
• 52,350 points
1,266 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP