作者:L呆头_383 | 来源:互联网 | 2023-05-17 21:36
1.配置源(centos6)yuminstallhttp:download.fedoraproject.orgpubepel6x86_64epel-release-6-8.noarc
1.配置源(centos6)
yum install http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
2.下载配置文件 CentOS6-Base-163.repo
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo CentOS6-Base-163.repo主要是为了安装:PyYAML
mv CentOS6-Base-163.repo /etc/yum.repos.d/
配置源(centos7)
rpm -iUvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel//7/x86_64/e/epel-release-7-7.noarch.rpm
下载配置文件(centos7)
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo CentOS7-Base-163.repo主要是为了安装:PyYAML
mv CentOS7-Base-163.repo /etc/yum.repos.d/
3.下载安装ansible
yum install ansible
4.查看ansible 版本
# ansible --version
ansible 1.9.2
configured module search path = None
5.安装依赖包
yum install gcc python-devel python-pip
6.升级软件
pip install --upgrade PyCrypto
pip install pycrypto-on-pypi
7.配置ansible
[root~]# vi /etc/ansible/hosts
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
# - Comments begin with the '#' character
# - Blank lines are ignored
# - Groups of hosts are delimited by [header] elements
# - You can enter hostnames or ip addresses
# - A hostname/ip can be a member of multiple groups
# Ex 1: Ungrouped hosts, specify before any group headers.
192.168.165.46 #配置ansible监控地址
green.example.com
###############
8.验证ansible
[root@ansible02 ~]# ansible 192.168.165.46 -m ping --ask-pass
SSH password: # 输入系统密码
192.168.165.46 | success >> { # 输出正常
"changed": false,
"ping": "pong"
}
[root@ansible02 ~]#
至此,ansible 部署完成