允許系統免秘鑰執行 sudo
# User privilege specification
root ALL=(ALL:ALL) ALL
huyi ALL=(ALL) NOPASSWD: ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD: ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
## ssh 權限修改
重新設置root 密碼
passwd root
在當前管理員賬號創建ssh 公鑰并授權給所有目標設備
huyi@k8s-master:~$ sudo ssh-keygen
ssh_config.sh 腳本復制到所有設備,執行腳本允許root 用戶登錄ssh,復制ssh 秘鑰
bash -x ssh_config.sh
sudo ssh-copy-id root@192.168.1.117
ansible 安裝
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get -y install python-minimal python-apt python-pip python-dev #每臺宿主機都要安裝 python2
sudo apt-get install ansible -y
### pip 麒麟系統 python 特殊依賴包
pip install setuptools
sudo apt-get install python-dev
pip install wheel -i https://mirrors.aliyun.com/pypi/simple
pip install PyYAML -i https://mirrors.aliyun.com/pypi/simple
apt-get autoremove python-pkg-resources