Having issues iterations via pillar data and jinja template. I took most of the template from a working salt/pillar installation but now failing to work in new environment.
I have tried several different syntaxes with the implementation of the iteration but still get same error.
ServerName:
Data failed to compile:
Rendering SLS 'base:pillar_lab_user' failed: Jinja variable 'str object'
has no attribute 'iteritems'
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)
{% for user, args in users.iteritems() %}
What is the correct syntax for iteritems and accessing this data via a jinja template. I have tried many variations of this syntax but still getting the
ServerName:
Data failed to compile:
----------
Rendering SLS 'base:pillar_lab_user' failed: Jinja variable 'str object'
has no attribute 'iteritems'
EDIT
This was all user error, the pillar configuration was malformed. I removed the first line
"{% set users = salt['pillar.get']('XXXXXXX') %}"
so I didn't use pillar.get and targeted with pillar top.sls. It works properly now.