bind: extract systemd service file in a template

This commit is contained in:
Jérémy Lecour 2017-04-06 14:21:29 +02:00 committed by Jérémy Lecour
parent a798bf0ebc
commit 2f7116f676
2 changed files with 21 additions and 23 deletions

View file

@ -10,32 +10,15 @@
replace: 'OPTIONS="-u bind -t {{ bind_chroot_root }}"'
- name: Create systemd service
file:
path: "{{ bind_systemd_service_path }}"
template:
src: bind9.service.j2
dest: "{{ bind_systemd_service_path }}"
owner: root
group: root
mode: "0644"
state: touch
register: create_bind_systemd
- name: "Fill out systemd service"
blockinfile:
dest: "{{ bind_systemd_service_path }}"
block: |
[Unit]
Description=BIND Domain Name Server
Documentation=man:named(8)
After=network.target
[Service]
EnvironmentFile=-/etc/default/bind9
ExecStart=/usr/sbin/named -f $OPTIONS
ExecReload=/usr/sbin/rndc reload
ExecStop=/usr/sbin/rndc stop
[Install]
WantedBy=multi-user.target
when: create_bind_systemd | changed
force: yes
backup: yes
notify: restart bind
- name: Create directories
file:

View file

@ -0,0 +1,15 @@
# {{ ansible_managed }}
[Unit]
Description=BIND Domain Name Server
Documentation=man:named(8)
After=network.target
[Service]
EnvironmentFile=-/etc/default/bind9
ExecStart=/usr/sbin/named -f $OPTIONS
ExecReload=/usr/sbin/rndc reload
ExecStop=/usr/sbin/rndc stop
[Install]
WantedBy=multi-user.target