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
• 16,300 points
344 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
• 42,330 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
439 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,280 points

edited May 31, 2018 by ajs3033 33 views
+13 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
213 views
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
• 42,330 points
765 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
• 42,330 points
94 views