diff --git a/salt-pillar/dhcp/init.sls b/salt-pillar/dhcp/init.sls new file mode 100644 index 000000000..973cc70 --- /dev/null +++ b/salt-pillar/dhcp/init.sls @@ -0,0 +1,37 @@ +dhcp: + serv: + start: 172.20.73.2 + end: 172.20.73.63 + time: 7776000 + max-time: 31536000 + opts: + domain-name: serv.zentralwerk.online + #domain-name-servers: + routers: 172.20.73.1 + + pub: + start: 172.20.76.2 + end: 172.20.77.254 + time: 300 + max-time: 3600 + opts: + domain-name: pub.zentralwerk.online + routers: 172.20.76.1 + + priv1: + start: 172.20.74.2 + end: 172.20.74.14 + time: 3600 + max-time: 86400 + opts: + domain-name: priv1.zentralwerk.online + routers: 172.20.74.1 + + priv2: + start: 172.20.75.2 + end: 172.20.75.14 + time: 3600 + max-time: 86400 + opts: + domain-name: priv2.zentralwerk.online + routers: 172.20.75.1 diff --git a/salt-pillar/top.sls b/salt-pillar/top.sls index a75d0dc..fc18a48 100644 --- a/salt-pillar/top.sls +++ b/salt-pillar/top.sls @@ -3,3 +3,5 @@ base: - hosts - subnets - vlans + '*gw': + - dhcp diff --git a/salt/dhcp/dhcpd.conf b/salt/dhcp/dhcpd.conf new file mode 100644 index 000000000..a49ced1 --- /dev/null +++ b/salt/dhcp/dhcpd.conf @@ -0,0 +1,17 @@ +{%- import_yaml "netmasks.yaml" as netmasks -%} + +{%- for iface, ips in salt['grains.get']('ip_interfaces').items() %} +{%- if iface not in ['core', 'lo'] %} +{%- set conf = pillar['dhcp'][iface] %} +{%- set subnet = pillar['subnets-inet'][iface] %} +subnet {{ subnet.split('/')[0] }} netmask {{ netmasks[subnet.split('/')[1]] }} { + authoritative; + default-lease-time {{ conf['time'] }}; + max-lease-time {{ conf['max-time'] }}; + range {{ conf['start'] }} {{ conf['end'] }}; +{%- for name, value in conf['opts'].items() %} + option {{ name }} {{ value }}; +{%- endfor %} +} +{%- endif %} +{%- endfor %} diff --git a/salt/dhcp/init.sls b/salt/dhcp/init.sls new file mode 100644 index 000000000..9706599 --- /dev/null +++ b/salt/dhcp/init.sls @@ -0,0 +1,7 @@ +isc-dhcp-server: + pkg.installed: [] + +/etc/dhcp/dhcpd.conf: + file.managed: + - source: salt://dhcp/dhcpd.conf + - template: 'jinja' diff --git a/salt/top.sls b/salt/top.sls index d42bb98..eab045d 100644 --- a/salt/top.sls +++ b/salt/top.sls @@ -8,6 +8,7 @@ base: - no-ssh - forwarding - ospf + - dhcp 'upstream*': - no-ssh - forwarding