base: use a template for ntp configuration to ease the management of the different cases
parent
ec6de426d6
commit
d10b2c42b3
@ -1,31 +1,12 @@
|
||||
---
|
||||
- name: "Retrieve ntpd.conf content"
|
||||
command: cat ntpd.conf
|
||||
args:
|
||||
chdir: /etc/
|
||||
check_mode: false
|
||||
changed_when: false
|
||||
register: ntpd_conf
|
||||
tags:
|
||||
- ntp
|
||||
|
||||
- name: "Empty ntpd.conf before customizing it"
|
||||
file:
|
||||
path: /etc/ntpd.conf
|
||||
state: absent
|
||||
when: ntpd_conf.stdout is not regex('^servers ' + ntpd_servers + '$')
|
||||
tags:
|
||||
- ntp
|
||||
|
||||
- name: "Customize ntpd conf"
|
||||
lineinfile:
|
||||
path: /etc/ntpd.conf
|
||||
line: "servers {{ ntpd_servers }}"
|
||||
create: true
|
||||
template:
|
||||
src: ntpd.conf.j2
|
||||
dest: /etc/ntpd.conf
|
||||
owner: root
|
||||
group: wheel
|
||||
mode: '0644'
|
||||
notify:
|
||||
- reload ntp
|
||||
- restart ntpd
|
||||
tags:
|
||||
- ntp
|
||||
|
@ -0,0 +1,4 @@
|
||||
{% if is_ntpd_server %}
|
||||
listen on *
|
||||
{% endif %}
|
||||
servers {{ ntpd_servers }}
|
Loading…
Reference in New Issue