diff --git a/defauts/main.yml b/defauts/main.yml new file mode 100644 index 0000000..5757c8a --- /dev/null +++ b/defauts/main.yml @@ -0,0 +1,4 @@ +--- +dnsmasq_listen_address: + - "127.0.0.1" + - "::1" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..74f4928 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,9 @@ +- name: Restart dnsmasq Service + service: + name: dnsmasq + state: restarted + daemon_reload: yes + enabled: yes + listen: __dnsmasq_restart + become: True + become_user: root diff --git a/tasks/main.yml b/tasks/main.yml index 1f69f7a..ea3e214 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,21 @@ --- -- include_tasks: setup.yml +- block: + - name: Install package + package: + name: dnsmasq + state: present + + - name: Create dnsmasq configuration + template: + src: "etc/dnsmasq.d/local.conf.j2" + dest: "/etc/dnsmasq.d/local.conf" + mode: 0644 + notify: __dnsmasq_restart + + - name: Ensure dnsmasq is up and running + service: + name: dnsmasq + enabled: True + state: started + become: True + become_user: root diff --git a/tasks/setup.yml b/tasks/setup.yml deleted file mode 100644 index e06861d..0000000 --- a/tasks/setup.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- block: - - name: Install package - package: - name: dnsmasq - state: present - - - name: Ensure dnsmasq is up and running - service: - name: dnsmasq - enabled: True - state: started - become: True - become_user: root diff --git a/template/etc/dnsmasq.d/local.conf.j2 b/template/etc/dnsmasq.d/local.conf.j2 new file mode 100644 index 0000000..eefde54 --- /dev/null +++ b/template/etc/dnsmasq.d/local.conf.j2 @@ -0,0 +1 @@ +listen-address={{ dnsmasq_listen_address | join(",") }}