blob: a5863ba972ef5e34becde3d49b07baa92f5614cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
- name: configure and enable dnsmasq if enabled
when: enable_dnsmasq | bool
block:
- name: install dnsmasq
apt:
name: dnsmasq
state: present
update_cache: true
- name: remove existing /etc/dnsmasq.d directory and all contents
file:
path: /etc/dnsmasq.d
state: absent
- name: recreate empty /etc/dnsmasq.d directory
file:
path: /etc/dnsmasq.d
state: directory
owner: root
group: root
mode: '0755'
- name: deploy dnsmasq config from template
template:
src: vmbr1.conf.j2
dest: /etc/dnsmasq.d/vmbr1.conf
owner: root
group: root
mode: '0644'
- name: ensure dnsmasq group exists
group:
name: dnsmasq
system: yes
- name: ensure dnsmasq user exists
user:
name: dnsmasq
group: dnsmasq
system: yes
create_home: no
- name: insert dhcp allow rules for vmbr1 into /etc/ufw/before.rules
blockinfile:
path: /etc/ufw/before.rules
block: |
-A ufw-before-input -i vmbr1 -p udp --dport 67 -j ACCEPT
-A ufw-before-output -o vmbr1 -p udp --sport 67 -j ACCEPT
marker: "# {mark} ANSIBLE MANAGED DHCP VMBR1 ALLOW RULES"
insertafter: '^# End required lines'
- name: enable and restart dnsmasq service
systemd:
name: dnsmasq
enabled: true
state: restarted
when: ansible_service_mgr == 'systemd'
|