检查每台机器的系统版本
# 查看 ubuntu 版本 和 内核版本
uname -a
Linux cluster48 4.4.0-128-generic #154~14.04.1-Ubuntu SMP Fri May 25 14:58:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
# 同上
cat /proc/version
# 查看版本号
cat /etc/issue
Ubuntu 14.04.6 LTS \n \l
# 查看具体版本信息,包括版本代号
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.6 LTS"
版本代号:
14.04:trusty
16.04:xenial
18.04:bionic
更换 apt 源的脚本
vim update_apt_source.sh
#!/bin/bash
mv /etc/apt/sources.list /etc/apt/sources.list.bak
SYS_VERSION=$(lsb_release -c | grep -o "\s.*")
cat >> /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ $SYS_VERSION-proposed main restricted universe multiverse
EOF
apt update
通过 ansible 分发脚本到集群并执行
vim update_apt_source.yml
- hosts: k8s_nodes1
become: true
vars:
docker_version: 18.09.2
tasks:
- name: copy update_apt_source.sh
copy:
src: "/usr/GitCodes/CopyrightMonitor/DevOps/Ansible/playbooks/update_apt_source.sh"
dest: '/etc/apt'
owner: root
group: root
mode: 0777
- name: update apt source.list
shell: /etc/apt/update_apt_source.sh
ansible-playbook update_apt_source.yml