2018-08-17 09:18:55 +08:00
|
|
|
- name: apt更新缓存刷新
|
|
|
|
apt: update_cache=yes cache_valid_time=72000
|
2019-05-27 20:02:02 +08:00
|
|
|
ignore_errors: true
|
2019-07-16 22:47:53 +08:00
|
|
|
when:
|
|
|
|
- 'ansible_distribution in ["Ubuntu","Debian"]'
|
|
|
|
- 'INSTALL_SOURCE != "offline"'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
2019-06-29 18:10:51 +08:00
|
|
|
- name: apt 卸载 ntp
|
|
|
|
shell: 'apt remove -y ntp'
|
2019-07-16 22:47:53 +08:00
|
|
|
when: 'ansible_distribution in ["Ubuntu","Debian"]'
|
2019-06-29 18:10:51 +08:00
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: yum 卸载 ntp
|
|
|
|
shell: 'yum remove -y ntp'
|
2020-12-30 11:25:54 +08:00
|
|
|
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
|
2019-07-03 22:39:23 +08:00
|
|
|
args:
|
|
|
|
warn: false
|
2019-06-29 18:10:51 +08:00
|
|
|
ignore_errors: true
|
2018-10-12 20:44:16 +08:00
|
|
|
|
2018-08-17 09:18:55 +08:00
|
|
|
- name: 安装 chrony
|
2019-04-03 15:02:05 +08:00
|
|
|
package: name=chrony state=present
|
2019-06-28 10:50:36 +08:00
|
|
|
when: 'INSTALL_SOURCE != "offline"'
|
|
|
|
|
|
|
|
# 离线安装 chrony
|
|
|
|
- import_tasks: offline.yml
|
|
|
|
when: 'INSTALL_SOURCE == "offline"'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: 配置 chrony server
|
|
|
|
template: src=server-centos.conf.j2 dest=/etc/chrony.conf
|
2020-12-30 11:25:54 +08:00
|
|
|
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 配置 chrony server
|
|
|
|
template: src=server-ubuntu.conf.j2 dest=/etc/chrony/chrony.conf
|
2019-07-16 22:47:53 +08:00
|
|
|
when: 'ansible_distribution in ["Ubuntu","Debian"]'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 启动 chrony server
|
|
|
|
service: name=chronyd state=restarted enabled=yes
|
2020-12-30 11:25:54 +08:00
|
|
|
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
|
2019-05-27 20:02:02 +08:00
|
|
|
|
2018-08-17 09:18:55 +08:00
|
|
|
- name: 启动 chrony server
|
|
|
|
service: name=chrony state=restarted enabled=yes
|
2019-07-16 22:47:53 +08:00
|
|
|
when: 'ansible_distribution in ["Ubuntu","Debian"]'
|
2019-05-27 20:02:02 +08:00
|
|
|
when: 'inventory_hostname == groups.chrony[0]'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: 配置 chrony client
|
|
|
|
template: src=client-centos.conf.j2 dest=/etc/chrony.conf
|
2020-12-30 11:25:54 +08:00
|
|
|
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 配置 chrony client
|
|
|
|
template: src=client-ubuntu.conf.j2 dest=/etc/chrony/chrony.conf
|
2019-07-16 22:47:53 +08:00
|
|
|
when: 'ansible_distribution in ["Ubuntu","Debian"]'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 启动 chrony client
|
|
|
|
service: name=chronyd state=restarted enabled=yes
|
2020-12-30 11:25:54 +08:00
|
|
|
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
|
2018-08-17 09:18:55 +08:00
|
|
|
|
|
|
|
- name: 启动 chrony client
|
|
|
|
service: name=chrony state=restarted enabled=yes
|
2019-07-16 22:47:53 +08:00
|
|
|
when: 'ansible_distribution in ["Ubuntu","Debian"]'
|
2019-05-27 20:02:02 +08:00
|
|
|
when: 'inventory_hostname != groups.chrony[0]'
|