{% if pillar['groups'] is defined %} {% for group, args in pillar['groups'].items() %} Added {{ group }} group: group.present: - name: {{ group }} {% if args['gid'] is defined %} - gid: {{ args['gid'] }} {% endif %} {%if args['system'] is defined %} - system: {{ args['system'] }} %} {% endif %} {% endfor %} {% endif %}