增加支持离线安装chrony

pull/641/head
gjmzj 2019-06-28 10:50:36 +08:00
parent 4a591f3e92
commit 55451ed797
3 changed files with 35 additions and 1 deletions

View File

@ -9,3 +9,5 @@ ntp_servers:
# 设置允许内部时间同步的网络段,比如"10.0.0.0/8",默认全部允许
local_network: "0.0.0.0/0"
# 离线安装 chrony (offline|online)
INSTALL_SOURCE: "offline"

View File

@ -1,6 +1,6 @@
- name: apt更新缓存刷新
apt: update_cache=yes cache_valid_time=72000
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16
when: ansible_distribution == "Ubuntu" and INSTALL_SOURCE != "offline"
ignore_errors: true
- name: 确保已卸载ntp
@ -8,6 +8,11 @@
- name: 安装 chrony
package: name=chrony state=present
when: 'INSTALL_SOURCE != "offline"'
# 离线安装 chrony
- import_tasks: offline.yml
when: 'INSTALL_SOURCE == "offline"'
- block:
- name: 配置 chrony server

View File

@ -0,0 +1,27 @@
# 离线安装 chrony
- name: 准备离线安装包目录
file: name=/opt/kube/packages/chrony state=directory
- block:
- name: 分发 chrony_xenial 离线包
copy:
src: "{{ base_dir }}/down/packages/chrony_xenial.tar.gz"
dest: "/opt/kube/packages/chrony/chrony_xenial.tar.gz"
- name: 安装 chrony_xenial 离线包
shell: 'cd /opt/kube/packages/chrony && tar zxf chrony_xenial.tar.gz && \
dpkg -i *.deb > /tmp/install_chrony.log 2>&1'
when: ansible_distribution_release == "xenial"
- block:
- name: 分发 chrony_centos7 离线包
copy:
src: "{{ base_dir }}/down/packages/chrony_centos7.tar.gz"
dest: "/opt/kube/packages/chrony/chrony_centos7.tar.gz"
- name: 安装 chrony_centos7 离线包
shell: 'cd /opt/kube/packages/chrony && tar zxf chrony_centos7.tar.gz && \
rpm -Uvh --nodeps *.rpm > /tmp/install_chrony.log 2>&1'
when:
- 'ansible_distribution_major_version == "7"'
- 'ansible_distribution == "CentOS"'