added dnsmasq
This commit is contained in:
parent
b71b10076e
commit
7320bc64c8
7
salt/states/dnsmasq/files/dnsmasq.conf.jinja
Normal file
7
salt/states/dnsmasq/files/dnsmasq.conf.jinja
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
interface={{ interface }}
|
||||||
|
listen-address= {{ ip }}
|
||||||
|
bind-interfaces
|
||||||
|
server=1.1.1.1
|
||||||
|
domain-needed
|
||||||
|
bogus-priv
|
||||||
|
dhcp-range={{ ip[0:-1] }}50,{{ ip[0:-1] }}150,12h
|
44
salt/states/dnsmasq/init.sls
Normal file
44
salt/states/dnsmasq/init.sls
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
Install dnsmasq:
|
||||||
|
pkg.installed:
|
||||||
|
- name: dnsmasq
|
||||||
|
|
||||||
|
{% set ip = pillar['network']['ip'] -%}
|
||||||
|
{% set interface = pillar['network']['interface']['internal'] -%}
|
||||||
|
configure dnsmasq for internal interface:
|
||||||
|
file.managed:
|
||||||
|
- name: /etc/dnsmasq.d/{{ interface }}.conf
|
||||||
|
- source: salt://dnsmasq/files/dnsmasq.conf.jinja
|
||||||
|
- template: jinja
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: "0644"
|
||||||
|
- context:
|
||||||
|
ip: {{ ip }}
|
||||||
|
interface: {{ interface }}
|
||||||
|
|
||||||
|
{% for vlan in pillar['network']['vlan'] -%}
|
||||||
|
{% set id = vlan['id'] -%}
|
||||||
|
{% set ip = vlan['address'] -%}
|
||||||
|
configure dnsmasq for vlan.{{ id }}:
|
||||||
|
file.managed:
|
||||||
|
- name: /etc/dnsmasq.d/vlan.{{ id }}.conf
|
||||||
|
- source: salt://dnsmasq/files/dnsmasq.conf.jinja
|
||||||
|
- template: jinja
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: "0644"
|
||||||
|
- context:
|
||||||
|
ip: {{ ip }}
|
||||||
|
interface: vlan.{{ id }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
Start dnsmasq:
|
||||||
|
service.running:
|
||||||
|
- name: dnsmasq
|
||||||
|
- enable: True
|
||||||
|
- watch:
|
||||||
|
- file: configure dnsmasq for internal interface
|
||||||
|
{% for vlan in pillar['network']['vlan'] -%}
|
||||||
|
{% set id = vlan['id'] -%}
|
||||||
|
- file: configure dnsmasq for vlan.{{ id }}
|
||||||
|
{% endfor %}
|
Loading…
Reference in New Issue
Block a user