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
• 14,080 points
195 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
• 37,430 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,810 points
223 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,240 points

edited May 31, 2018 by ajs3033 24 views
+13 votes
2 answers
0 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
• 37,430 points
406 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
• 37,430 points
52 views