Skip to content

Commit 24b19ef

Browse files
author
anandkumarpatel
committed
Merge pull request #283 from CodeNow/SAN-3343-Install-Config-NTP
San 3343 install config ntp
2 parents e78d90a + 329ae33 commit 24b19ef

7 files changed

Lines changed: 78 additions & 0 deletions

File tree

ansible/oneOffScripts/ntp.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- hosts: all
3+
gather_facts: no
4+
5+
roles:
6+
- { role: package_ntp, tags "ntp" }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- hosts: all
3+
gather_facts: no
4+
tasks:
5+
6+
# pl test on test box
7+
- name: Froce ntp update
8+
sudo: yes
9+
shell:
10+
"service ntp stop && /usr/sbin/ntpdate pool.ntp.org && service ntp start"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- hosts: all
3+
gather_facts: no
4+
tasks:
5+
- fail: msg="`name` needs to be defined for this role"
6+
when: name is not defined
7+
8+
- name: restart {{ name }}
9+
sudo: yes
10+
service:
11+
name={{ name }}
12+
state=restarted
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
ntp_servers:
3+
- 0.north-america.pool.ntp.org
4+
- 1.north-america.pool.ntp.org
5+
- 2.north-america.pool.ntp.org
6+
- 3.north-america.pool.ntp.org
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Start and Enable ntp
3+
sudo: yes
4+
service:
5+
name=ntp
6+
state=started
7+
enabled=yes
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Install ntp package
3+
sudo: yes
4+
apt:
5+
name=ntp
6+
state=present
7+
force=yes
8+
update_cache=yes
9+
cache_valid_time=604800
10+
11+
- name: Copy the ntp.conf template file
12+
sudo: yes
13+
template:
14+
src=ntp.conf.j2
15+
dest=/etc/ntp.conf
16+
mode=0644
17+
notify: Start and Enable ntp
18+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# {{ ansible_managed }}
2+
3+
driftfile /var/lib/ntp/ntp.drift
4+
5+
statsdir /var/log/ntpstats/
6+
statistics loopstats peerstats clockstats
7+
filegen loopstats file loopstats type day enable
8+
filegen peerstats file peerstats type day enable
9+
filegen clockstats file clockstats type day enable
10+
11+
restrict -4 default kdo notrap nomodify nopeer noquery
12+
restrict -6 default kdo notrap nomodify nopeer noquery
13+
14+
restrict 127.0.0.1
15+
restrict ::1
16+
17+
{% for server in ntp_servers %}
18+
server {{ server }} iburst
19+
{% endfor %}

0 commit comments

Comments
 (0)