kubeasz/roles/prepare/tasks/offline.yml

37 lines
1.3 KiB
YAML
Raw Normal View History

2019-06-28 12:53:04 +08:00
# 离线安装基础系统包
2023-05-07 14:16:20 +08:00
# 仅当机器无法从本地yum/apt源安装时使用
# 执行前需要预先运行类似 ./ezdown -P debian_10 下载离线安装包
- name: 检查是否已下载离线软件包{{ SYS_PKG_NAME }}
stat:
path: "{{ base_dir }}/down/packages/{{ SYS_PKG_NAME }}"
register: pkg
connection: local
run_once: true
2019-06-28 12:53:04 +08:00
- name: 准备离线安装包目录
file: name=/opt/kube/packages/basic state=directory
- block:
2023-05-07 14:16:20 +08:00
- name: 分发离线软件包{{ SYS_PKG_NAME }}
2019-06-28 12:53:04 +08:00
copy:
2023-05-07 14:16:20 +08:00
src: "{{ base_dir }}/down/packages/{{ SYS_PKG_NAME }}"
dest: "/opt/kube/packages/basic/{{ SYS_PKG_NAME }}"
2019-06-28 12:53:04 +08:00
2019-06-29 18:10:51 +08:00
# 离线安装包可能需要安装多次才能成功
2023-05-07 14:16:20 +08:00
- name: 安装离线软件包{{ SYS_PKG_NAME }}
shell: 'cd /opt/kube/packages/basic && tar zxf {{ SYS_PKG_NAME }} && \
2019-06-28 12:53:04 +08:00
dpkg -i *.deb > /tmp/install_basic.log 2>&1'
2019-06-29 18:10:51 +08:00
register: install_info
until: not install_info.failed
retries: 3
delay: 1
2023-05-07 14:16:20 +08:00
when: 'ansible_distribution_file_variety in ["Debian"]'
2019-06-28 12:53:04 +08:00
2023-05-07 14:16:20 +08:00
- name: 安装离线软件包{{ SYS_PKG_NAME }}
shell: 'cd /opt/kube/packages/basic && tar zxf {{ SYS_PKG_NAME }} && \
2019-06-29 18:10:51 +08:00
rpm -Uvh --force --nodeps *.rpm > /tmp/install_basic.log 2>&1'
2023-05-07 14:16:20 +08:00
when: 'ansible_distribution_file_variety in ["RedHat", "SUSE"]'
when: 'pkg.stat.exists|bool'
2019-06-29 18:10:51 +08:00
ignore_errors: true