1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_unbound.git synced 2024-08-16 13:39:49 +02:00

improve validating mechanism

This commit is contained in:
L3D 2021-09-30 00:22:27 +02:00
parent b3c0dfffab
commit 347c8600b9
Signed by: l3d
GPG key ID: CD08445BFF4313D1
5 changed files with 40 additions and 46 deletions

View file

@ -1,14 +1,4 @@
--- ---
- name: unbound checkconf
become: true
ansible.builtin.command: unbound-checkconf /etc/unbound/unbound.conf
retries: 5
delay: 3
register: result
until: result.rc == 0
notify: systemctl restart unbound
- name: systemctl restart unbound - name: systemctl restart unbound
become: true become: true
ansible.builtin.service: ansible.builtin.service:

23
tasks/configure.yml Normal file
View file

@ -0,0 +1,23 @@
---
- name: Copy unbound configuration snippets
become: true
ansible.builtin.copy:
src: '{{ item }}'
dest: '/etc/unbound/unbound.conf.d/'
owner: root
group: root
mode: 'u=rw,g=r,o=r'
with_fileglob:
- 'files/snippets/*.conf'
notify: systemctl restart unbound
- name: Copy main unbound configuration
become: true
ansible.builtin.template:
src: 'files/unbound.conf'
dest: '/etc/unbound/unbound.conf'
owner: root
group: root
mode: 'u=rw,g=r,o=r'
validate: unbound-checkconf %s
notify: systemctl restart unbound

13
tasks/install.yml Normal file
View file

@ -0,0 +1,13 @@
---
- name: update debian cache
become: true
ansible.builtin.apt:
update_cache: true
cache_valid_time: 43200
when: ansible_pkg_mgr == "apt"
- name: install unbound
become: true
ansible.builtin.package:
name: unbound
state: "{{ unbound__state }}"

View file

@ -3,40 +3,8 @@
ansible.builtin.include_tasks: versioncheck.yml ansible.builtin.include_tasks: versioncheck.yml
when: submodules_versioncheck|bool when: submodules_versioncheck|bool
- name: update cache
become: true
ansible.builtin.apt:
state: "{{ unbound__state }}"
update_cache: true
cache_valid_time: 43200
when: ansible_pkg_mgr == "apt"
- name: install unbound - name: install unbound
become: true ansible.builtin.include_tasks: install.yml
ansible.builtin.package:
name: unbound
state: present
- name: Copy unbound configuration snippets - name: configure unbound
become: true ansible.builtin.include_tasks: configure.yml
ansible.builtin.copy:
src: '{{ item }}'
dest: '/etc/unbound/unbound.conf.d/'
owner: root
group: root
mode: 'u=rw,g=r,o=r'
with_fileglob:
- 'files/snippets/*.conf'
notify:
- unbound checkconf
- name: Copy main unbound configuration
become: true
ansible.builtin.template:
src: 'files/unbound.conf'
dest: '/etc/unbound/unbound.conf'
owner: root
group: root
mode: 'u=rw,g=r,o=r'
notify:
- unbound checkconf

View file

@ -1,3 +1,3 @@
--- ---
playbook_version_number: 68 # should be integer playbook_version_number: 69 # should be integer
playbook_version_path: 'role-unbound_roles-ansible_github.com.version' playbook_version_path: 'role-unbound_roles-ansible_github.com.version'