Add ntp role.

This commit is contained in:
Markus 2015-12-13 18:51:08 +01:00
commit f354af18a8
7 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
- name: Restart ntp
service: name=ntp state=restarted

View File

@ -0,0 +1,4 @@
---
- name: Restart ntp
service: name=ntpd state=restarted

View File

@ -0,0 +1,7 @@
---
- include: Debian.yml
when: ansible_os_family == 'Debian'
- include: FreeBSD.yml
when: ansible_distribution == 'FreeBSD'

View 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

View 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
View 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'

View 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