2018-08-17 09:18:55 +08:00
|
|
|
- name: apt更新缓存刷新
|
|
|
|
apt: update_cache=yes cache_valid_time=72000
|
|
|
|
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
|
|
|
|
|
2018-10-12 20:44:16 +08:00
|
|
|
- name: 确保已卸载ntp
|
|
|
|
package: name=ntp state=absent
|
|
|
|
|
2018-08-17 09:18:55 +08:00
|
|
|
- name: 安装 chrony
|
|
|
|
package: name=chrony state=latest
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: 配置 chrony server
|
|
|
|
template: src=server-centos.conf.j2 dest=/etc/chrony.conf
|
2019-01-03 20:21:39 +08:00
|
|
|
when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "7"
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 配置 chrony server
|
|
|
|
template: src=server-ubuntu.conf.j2 dest=/etc/chrony/chrony.conf
|
|
|
|
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
|
|
|
|
|
|
|
|
- name: 启动 chrony server
|
|
|
|
service: name=chronyd state=restarted enabled=yes
|
2019-01-03 20:21:39 +08:00
|
|
|
when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "7"
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 启动 chrony server
|
|
|
|
service: name=chrony state=restarted enabled=yes
|
|
|
|
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
|
|
|
|
when: 'inventory_hostname == groups.deploy[0]'
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: 配置 chrony client
|
|
|
|
template: src=client-centos.conf.j2 dest=/etc/chrony.conf
|
2019-01-03 20:21:39 +08:00
|
|
|
when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "7"
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 配置 chrony client
|
|
|
|
template: src=client-ubuntu.conf.j2 dest=/etc/chrony/chrony.conf
|
|
|
|
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
|
|
|
|
|
|
|
|
- name: 启动 chrony client
|
|
|
|
service: name=chronyd state=restarted enabled=yes
|
2019-01-03 20:21:39 +08:00
|
|
|
when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "7"
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 启动 chrony client
|
|
|
|
service: name=chrony state=restarted enabled=yes
|
|
|
|
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
|
|
|
|
when: 'inventory_hostname != groups.deploy[0]'
|
|
|
|
|