mg
fac0c68c5c
Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: mg/ansible#298 Co-authored-by: mg <michael.grote@posteo.de> Co-committed-by: mg <michael.grote@posteo.de>
62 lines
1.5 KiB
YAML
62 lines
1.5 KiB
YAML
---
|
|
- name: ensure packages are installed
|
|
become: yes
|
|
ansible.builtin.package:
|
|
name:
|
|
- dnsmasq
|
|
- wget
|
|
state: present
|
|
register: install
|
|
|
|
- name: stop dnsmasq (to prevent accidental DHCP-Server after installation)
|
|
become: yes
|
|
ansible.builtin.service:
|
|
name: dnsmasq
|
|
state: stopped
|
|
when: install.changed
|
|
|
|
- name: ensure group exists
|
|
become: true
|
|
ansible.builtin.group:
|
|
name: "{{ dnsmasq_user_group }}"
|
|
state: present
|
|
when:
|
|
- dnsmasq_user_group is defined
|
|
|
|
- name: ensure user exists
|
|
become: true
|
|
ansible.builtin.user:
|
|
name: "{{ dnsmasq_user }}"
|
|
group: "{{ dnsmasq_user_group }}"
|
|
shell: /usr/sbin/nologin
|
|
create_home: no
|
|
when:
|
|
- dnsmasq_user_group is defined
|
|
- dnsmasq_user is defined
|
|
|
|
- name: ensure needed directories exists
|
|
become: yes
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ dnsmasq_user }}"
|
|
group: "{{ dnsmasq_user_group }}"
|
|
loop:
|
|
- /etc/dnsmasq.d
|
|
- /etc/dnsmasq.d/blocklists
|
|
|
|
- name: clear default directories
|
|
become: yes
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- /etc/dnsmasq.d/README
|
|
|
|
- name: template logrotate config
|
|
become: yes
|
|
ansible.builtin.template:
|
|
src: logrotate.j2
|
|
dest: /etc/logrotate.d/dnsmasq
|
|
owner: "{{ dnsmasq_user }}"
|
|
group: "{{ dnsmasq_user_group }}"
|