Skip to content

Instantly share code, notes, and snippets.

@QuinnyPig
Last active August 29, 2015 14:08
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 QuinnyPig/2d5cc0ed33923951f398 to your computer and use it in GitHub Desktop.
Save QuinnyPig/2d5cc0ed33923951f398 to your computer and use it in GitHub Desktop.
Pillar says:
vlans:
- id: 100
network: 10.20.0.0
netmask: 255.255.255.0
prefix: 10.20.0
gateway: 10.20.0.1
- id: 101
network: 10.21.0.0
netmask: 255.255.255.0
prefix: 10.21.0
gateway: 10.21.0.1
Templated file says:
{%- for vlan in pillar['vlans'] %}
subnet {{ pillar[vlan.network] }} netmask {{ pillar[vlan.netmask] }} {
option routers {{ pillar[vlan.gateway] }};
option subnet-mask {{ pillar[vlan.netmask] }};
range {{ pillar[vlan.prefix] }}.200 {{ pillar[vlan.prefix] }}.240;
default-lease-time 1200;
max-lease-time 2400;
}
{%- endfor %}
Salt says:
ID: /etc/dhcp/dhcpd.conf
Function: file.managed
Result: False
Comment: Unable to manage file: Jinja variable 'dict' object has no attribute '10.20.0.0'; line 62
---
[...]
}
{%- for vlan in pillar['vlans'] %}
subnet {{ pillar[vlan.network] }} netmask {{ pillar[vlan.netmask] }} {
option routers {{ pillar[vlan.gateway] }};
option subnet-mask {{ pillar[vlan.netmask] }}; <======================
default-lease-time 1200;
max-lease-time 2400;
}
{%- endfor %}
---
Changes:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment