add {{ pillar['username'] }} to optional groups: user.present: - name: {{ pillar['username'] }} - optional_groups: {% for group, args in pillar['groups'].items() -%} - {{ group }} {% endfor %}