在一台CentOS7.x的联网机器上
# yum -y install yum-utils createrepo epel-release
# mkdir yum
# repotrack ansible -p yum
# createrepo -v yum
# tar -zcf yum.tar.gz yum
在离线机器上安装ansible
# cat install_ansible.sh
########################################################
#!/bin/bash
parent_path="$( cd "$(dirname "$0")"; pwd -P )"
cd "$parent_path"
rm -rf /tmp/yum
tar -zxf yum.tar.gz -C /tmp
echo "
[YUM]
name=yum
baseurl=file:///tmp/yum
enable=1
gpgcheck=0 " > /etc/yum.repos.d/yum.repo
yum clean all
yum -y install ansible --disablerepo="*" --enablerepo="YUM"
sed -i '/\[defaults\]/a \host_key_checking = False\' /etc/ansible/ansible.cfg
rm -rf /etc/yum.repos.d/yum.repo
rm -rf /tmp/yum
ansible --version
if [ $? -eq 0 ]; then
echo -e "\033[32mInstall ansible successfullly! \033[0m"
else
echo -e "\033[31mInstall ansible failed! \033[0m"
fi
#########################################################
网友评论