Skip to content

Commit 6c60556

Browse files
committed
completed ntp role and tested
1 parent 4bc153b commit 6c60556

8 files changed

Lines changed: 69 additions & 40 deletions

File tree

ansible/group_vars/all.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
registry_env: prod
44
registry_port: 80
55

6-
# ntp servers
7-
ntp_servers:
8-
- 0.north-america.pool.ntp.org
9-
- 1.north-america.pool.ntp.org
10-
- 2.north-america.pool.ntp.org
11-
- 3.north-america.pool.ntp.org
12-
136
# for docker stop old container
147
stop_time: 5
158

ansible/ntp.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
- hosts: all
3-
vars_files:
4-
group_vars/all.yml
3+
gather_facts: no
4+
55
roles:
6-
- { role: notify, tags: "notify" }
7-
- { role: install-config-ntp-package, tags "Setup NTP Package" }
6+
- { role: package_ntp, tags "Setup NTP Package" }

ansible/restart_service.yml

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+
5+
tasks:
6+
name : restart services
7+
sudo: yes
8+
service:
9+
name={{ item }}
10+
state=restarted
11+
with_items:
12+
- ntp

ansible/roles/install-config-ntp-package/tasks/main.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.
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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
---
22
- name: Restart ntp
3+
sudo: yes
34
service:
4-
name=
5-
state=restart
6-
enabled=yes
7-
tags: restart ntp
5+
name=ntp
6+
state=restarted
87

98
- name: Froce ntp update
9+
sudo: yes
1010
shell:
1111
"service ntp stop && /usr/sbin/ntpdate pool.ntp.org && service ntp start"
12-
tags: force ntp update
12+
13+
- name: Start and Enable ntp
14+
sudo: yes
15+
service:
16+
name=ntp
17+
state=started
18+
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)