homeserver/friedhof/mgrote_dnsmasq_adblocker/mgrote.dnsmasq_adblocker/tasks/install.yml
Michael Grote 7a24089031 fix linter errors (#584)
Reviewed-on: #584
Co-authored-by: Michael Grote <michael.grote@posteo.de>
Co-committed-by: Michael Grote <michael.grote@posteo.de>
2023-10-25 22:26:17 +02:00

62 lines
1.3 KiB
YAML

---
- name: ensure packages are installed
become: true
ansible.builtin.package:
name:
- dnsmasq
- wget
state: present
register: install
- name: stop dnsmasq (to prevent accidental DHCP-Server after installation)
become: true
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 }}"
ansible.builtin.shell: /usr/sbin/nologin
create_home: false
when:
- dnsmasq_user_group is defined
- dnsmasq_user is defined
- name: ensure needed directories exists
become: true
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: true
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /etc/dnsmasq.d/README
- name: template logrotate config
become: true
ansible.builtin.template:
src: logrotate.j2
dest: /etc/logrotate.d/dnsmasq
owner: root
group: root