Skip to content

Commit 4bc153b

Browse files
committed
adding ntp playbook
1 parent 35b8943 commit 4bc153b

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

ansible/group_vars/all.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
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+
613
# for docker stop old container
714
stop_time: 5
815

ansible/ntp.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- hosts: all
3+
vars_files:
4+
group_vars/all.yml
5+
roles:
6+
- { role: notify, tags: "notify" }
7+
- { role: install-config-ntp-package, tags "Setup NTP Package" }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Restart ntp
3+
service:
4+
name=
5+
state=restart
6+
enabled=yes
7+
tags: restart ntp
8+
9+
- name: Froce ntp update
10+
shell:
11+
"service ntp stop && /usr/sbin/ntpdate pool.ntp.org && service ntp start"
12+
tags: force ntp update
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
- name: Install ntp package
3+
apt:
4+
name=ntp
5+
become=yes
6+
state=latest
7+
update_chache=yes
8+
cache_valid_time=86400
9+
10+
- name: Copy the ntp.conf template file
11+
template:
12+
src=ntp.conf.j2
13+
dest=/etc/ntp.conf
14+
mode=660
15+
notify:
16+
- restart ntp
17+
18+
- name: start and enable ntp
19+
service:
20+
name=ntp
21+
become=yes
22+
state=started
23+
enabled=yes
24+

0 commit comments

Comments
 (0)