Skip to content

Commit

Permalink
bind: New role
Browse files Browse the repository at this point in the history
  • Loading branch information
Per Lundberg committed Jun 1, 2021
1 parent 3aa5bd3 commit 91d4417
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bind.yaml
@@ -0,0 +1,12 @@
- name: Runs the bind role
hosts: all

pre_tasks:
- import_tasks: include/common_pre_tasks.yml

roles:
- role: bind

module_defaults:
apt:
force_apt_get: yes
7 changes: 7 additions & 0 deletions roles/bind/defaults/main.yml
@@ -0,0 +1,7 @@
# The path in the inventory to where the files in /etc/bind will be copied from.
# Note that no default value is provided by this role; you must set in the
# inventory on host/group level.
#
# Typical override value:
# {{ inventory_dir }}/overrides/<host>/bind/etc/bind
bind_etc_bind_path: null
6 changes: 6 additions & 0 deletions roles/bind/handlers/main.yml
@@ -0,0 +1,6 @@
- name: Reload or start the bind service
systemd:
name: bind9.service
state: reloaded
listen: reload_bind
become: true
33 changes: 33 additions & 0 deletions roles/bind/tasks/main.yml
@@ -0,0 +1,33 @@
- name: Ensure mandatory variables are set
fail:
msg: "Mandatory variable bind_etc_bind_path must be set"
when: bind_etc_bind_path == None

- name: Install/update bind9
ansible.builtin.package:
name:
- bind9

# Deliberately not using 'state: latest' to avoid unexpected surprises when
# e.g. deploying updated configuration.
state: present
become: true

- name: Find /etc/bind files
find:
paths: '{{ bind_etc_bind_path }}'
patterns: '*'
register: etc_bind_files
delegate_to: 127.0.0.1

- name: Copy configuration to /etc/bind
ansible.builtin.template:
src: '{{ item.path }}'
dest: /etc/bind/{{ item.path | basename | replace('.j2', '') }}
owner: root
group: bind
mode: 0644
backup: false
become: true
loop: '{{ etc_bind_files.files }}'
notify: reload_bind

0 comments on commit 91d4417

Please sign in to comment.