forked from pingcap/tidb-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_ntp.yml
87 lines (76 loc) · 2.25 KB
/
deploy_ntp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
- hosts: all
user: root
tasks:
- name: Get distro name from /etc/os-release
raw: "([ -f /etc/os-release ] && grep '^NAME=' /etc/os-release | sed s'/NAME=//' | tr -d \\\") || ([ -f /etc/redhat-release ] && cat /etc/redhat-release | cut '-d ' -f1)"
register: distro_st
failed_when: false
changed_when: false
- name: set distro facts
set_fact:
distro: "{{ distro_st.stdout | trim }}"
- name: Redhat/CentOS - Make sure ntp, ntpstat have been installed
yum:
name: "{{ item }}"
state: present
with_items:
- ntp
when:
- "'CentOS' in distro"
- name: Redhat/CentOS - Make sure ntpdate have been installed
yum:
name: "{{ item }}"
state: present
with_items:
- ntpdate
when:
- "'CentOS' in distro"
- ntp_server is defined
- name: Debian/Ubuntu - Make sure ntp, ntpstat have been installed
apt:
name: "{{ item }}"
state: present
with_items:
- ntp
- ntpstat
when:
- "'Ubuntu' in distro or 'Debian' in distro"
- name: Debian/Ubuntu - Make sure ntpdate have been installed
apt:
name: "{{ item }}"
state: present
with_items:
- ntpdate
when:
- "'Ubuntu' in distro or 'Debian' in distro"
- ntp_server is defined
- name: Adjust Time | Make sure ntpd service has been stopped
service:
name: ntpd
state: stopped
when:
- "'CentOS' in distro"
- ntp_server is defined
- name: Adjust Time | Make sure ntp service has been stopped
service:
name: ntp
state: stopped
when:
- "'Ubuntu' in distro or 'Debian' in distro"
- ntp_server is defined
- name: Adjust Time | Start to adjust time with {{ ntp_server }}
shell: ntpdate {{ ntp_server }}
when: ntp_server is defined
- name: Adjust Time | Make sure ntpd service has been started
service:
name: ntpd
state: started
when:
- "'CentOS' in distro"
- name: Adjust Time | Make sure ntpd service has been started
service:
name: ntp
state: started
when:
- "'Ubuntu' in distro or 'Debian' in distro"