Skip to content

Instantly share code, notes, and snippets.

@unicolet
Created October 31, 2012 14:50
Show Gist options
  • Save unicolet/3987451 to your computer and use it in GitHub Desktop.
Save unicolet/3987451 to your computer and use it in GitHub Desktop.
Generate a dns zone definition from Salt
@ in soa localhost. root 1 3H 15M 1W 1D
ns localhost.
{% set nets=salt['publish.publish']('*','network.interfaces') %}{% for n in nets %}{% set pdata=salt['publish.publish'](n,'pillar.data') %}{% if pdata.has_key(n) %}{% if pdata[n].has_key('zone') %}{% if pdata[n]['zone']=='linuxservers' %}
{{ n }} IN A {{ nets[n]['eth0']['inet'][0]['address'] }}
{% endif %}{% endif %}{% endif %}{% endfor %}
@dangarthwaite
Copy link

@ in soa localhost. root 1 3H 15M 1W 1D
  ns localhost.
{%- set nets=salt['publish.publish']('*','network.interfaces') -%}
{%- for n in nets -%}
    {%- set pdata=salt['publish.publish'](n,'pillar.data') -%}
    {%- if pdata.has_key(n) -%}
        {%- if pdata[n].has_key('zone') -%}
            {%- if pdata[n]['zone']=='linuxservers' %}
{{ n }} IN      A       {{ nets[n]['eth0']['inet'][0]['address'] }} 
            {% endif -%}
        {%- endif -%}
     {%- endif -%}
{%- endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment