base: use a template for ntp configuration to ease the management of the different cases
This commit is contained in:
parent
ec6de426d6
commit
d10b2c42b3
|
@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
* base: configure "/usr/X11R6" and "/usr/local" for servers that have a mount on it
|
* base: configure "/usr/X11R6" and "/usr/local" for servers that have a mount on it
|
||||||
* base: we can chose to deploy or not utils files
|
* base: we can chose to deploy or not utils files
|
||||||
* base: reordering default variable file and deleting unused one
|
* base: reordering default variable file and deleting unused one
|
||||||
|
* base: use a template for ntp configuration to ease the management of the different cases
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ general_alert_email: "root@localhost"
|
||||||
cron_root_path: "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
|
cron_root_path: "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
|
||||||
|
|
||||||
# ntp.yml
|
# ntp.yml
|
||||||
|
is_ntpd_server: false
|
||||||
ntpd_servers: "ntp.evolix.net"
|
ntpd_servers: "ntp.evolix.net"
|
||||||
|
|
||||||
# fstab.yml
|
# fstab.yml
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
args:
|
args:
|
||||||
warn: false
|
warn: false
|
||||||
|
|
||||||
- name: reload ntp
|
- name: restart ntpd
|
||||||
service:
|
service:
|
||||||
name: ntpd
|
name: ntpd
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -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"
|
- name: "Customize ntpd conf"
|
||||||
lineinfile:
|
template:
|
||||||
path: /etc/ntpd.conf
|
src: ntpd.conf.j2
|
||||||
line: "servers {{ ntpd_servers }}"
|
dest: /etc/ntpd.conf
|
||||||
create: true
|
|
||||||
owner: root
|
owner: root
|
||||||
group: wheel
|
group: wheel
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
notify:
|
notify:
|
||||||
- reload ntp
|
- restart ntpd
|
||||||
tags:
|
tags:
|
||||||
- ntp
|
- ntp
|
||||||
|
|
4
roles/base/templates/ntpd.conf.j2
Normal file
4
roles/base/templates/ntpd.conf.j2
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{% if is_ntpd_server %}
|
||||||
|
listen on *
|
||||||
|
{% endif %}
|
||||||
|
servers {{ ntpd_servers }}
|
Loading…
Reference in a new issue