Skip to content

Instantly share code, notes, and snippets.

@vr-jack
Created August 13, 2015 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vr-jack/79d3ac87fd3b4fe16047 to your computer and use it in GitHub Desktop.
Save vr-jack/79d3ac87fd3b4fe16047 to your computer and use it in GitHub Desktop.
{% set hostname = grains['host'] %}
{% set hostgroup = pillar['hostgroup'] %}
{% set phostname = hostgroup ~ ':' ~ hostname %}
{% if salt['pillar.get']('hosts:' + phostname + ':network','') != '' %}
{% set gateway = salt['pillar.get']('hosts:' + phostname + ':network:gateway',)
%}
system:
network.system:
- enabled: True
- hostname: {{ hostname }}
{% if gateway is defined %}
- gateway: {{ gateway }}
{% endif %}
{% for inf in pillar['hosts'][hostgroup][hostname]['network']['interfaces'] %}
{{ inf }}:
network.managed:
- enabled: True
{% for key,val in pillar['hosts'][hostgroup][hostname]['network']['interfaces'][
inf].items() %}
- {{ key }}: {{ val }}
{% endfor %}
{% endfor %}
{% else %}
system:
network.system:
- enabled: False
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment