Add ntp role.
This commit is contained in:
commit
f354af18a8
4
roles/ntp/handlers/Debian.yml
Normal file
4
roles/ntp/handlers/Debian.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
- name: Restart ntp
|
||||
service: name=ntp state=restarted
|
4
roles/ntp/handlers/FreeBSD.yml
Normal file
4
roles/ntp/handlers/FreeBSD.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
- name: Restart ntp
|
||||
service: name=ntpd state=restarted
|
7
roles/ntp/handlers/main.yml
Normal file
7
roles/ntp/handlers/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- include: Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: FreeBSD.yml
|
||||
when: ansible_distribution == 'FreeBSD'
|
11
roles/ntp/tasks/Debian.yml
Normal file
11
roles/ntp/tasks/Debian.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
- name: Install ntp
|
||||
apt: name=ntp state=present
|
||||
|
||||
- name: Configure ntp
|
||||
template: src=ntp.conf.j2 dest=/etc/ntp.conf
|
||||
notify: Restart ntp
|
||||
|
||||
- name: Start the ntp service
|
||||
service: name=ntp state=started enabled=yes
|
10
roles/ntp/tasks/FreeBSD.yml
Normal file
10
roles/ntp/tasks/FreeBSD.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
|
||||
# ntp is already installed on FreeBSD
|
||||
|
||||
- name: Configure ntp
|
||||
template: src=ntp.conf.j2 dest=/etc/ntp.conf
|
||||
notify: Restart ntp
|
||||
|
||||
- name: Start the ntp service
|
||||
service: name=ntpd state=started enabled=yes
|
8
roles/ntp/tasks/main.yml
Normal file
8
roles/ntp/tasks/main.yml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
# This playbook contains common plays that will be run on all nodes.
|
||||
|
||||
- include: Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: FreeBSD.yml
|
||||
when: ansible_distribution == 'FreeBSD'
|
15
roles/ntp/templates/ntp.conf.j2
Normal file
15
roles/ntp/templates/ntp.conf.j2
Normal file
@ -0,0 +1,15 @@
|
||||
{% for srv in ntp_servers %}
|
||||
server {{ srv }} iburst
|
||||
{% endfor %}
|
||||
{% if ntp_peers is defined %}
|
||||
|
||||
{% for peer in ntp_peers %}
|
||||
peer {{ peer }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
restrict default kod nomodify notrap nopeer noquery
|
||||
restrict -6 default kod nomodify notrap nopeer noquery
|
||||
|
||||
restrict 127.0.0.1
|
||||
restrict -6 ::1
|
Loading…
Reference in New Issue
Block a user