{%- set myconfig = pillar['netbox']['config_context'] -%} salt: minion_remove_config: True minion: master_type: str master: {{ myconfig['salt_master'] }} {%- if 'roles' in myconfig and myconfig['roles'] | length > 0 %} grains: roles: {{ myconfig['roles'] }} {%- endif %}