ansible
# ansible
## 安装
```
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache
yum install epel-release -y
yum install ansible
[root@master ansible]# ls
ansible-2.9.27-1.el7.noarch.rpm python2-jmespath-0.9.4-2.el7.noarch.rpm python-jinja2-2.7.2-4.el7.noarch.rpm python-paramiko-2.1.1-9.el7.noarch.rpm
python2-httplib2-0.18.1-3.el7.noarch.rpm python-babel-0.9.6-8.el7.noarch.rpm python-markupsafe-0.11-10.el7.x86_64.rpm sshpass-1.06-2.el7.x86_64.rpm
[root@master ansible]# yum install --downloadonly --downloaddir=/root/zgy/ansible ansible
```
## 配置
```
[test]
152.55.249.[96:100] ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_pass=211314
#152.55.249.97 ansible_ssh_pass=test!2013
#152.55.249.98 ansible_ssh_pass=test!2013
#152.55.249.99 ansible_ssh_pass=test!2013
#ansible_ssh_host
#用于指定被管理的主机的真实IP
#ansible_ssh_port
#用于指定连接到被管理主机的ssh端口号,默认是22
#ansible_ssh_user
#ssh连接时默认使用的用户名
#ansible_ssh_pass
#ssh连接时的密码
#ansible_sudo_pass
#使用sudo连接用户时的密码
#ansible_sudo_exec
#如果sudo命令不在默认路径,需要指定sudo命令路径 ansible_ssh_private_key_file
#秘钥文件路径,秘钥文件如果不想使用ssh-agent管理时可以使用此选项 ansible_shell_type
#目标系统的shell的类型,默认sh
#ansible_connection
#SSH 连接的类型: local , ssh , paramiko,在 ansible 1.2 之前默认是 paramiko ,后来智能选择,优先使用基于 ControlPersist 的 ssh (支持的前提)
#ansible_python_interpreter
#用来指定Python解释器的路径,默认为/usr/bin/python 同样可以指定ruby 、perl 的路径
#ansible_*_interpreter
#其他解释器路径,用法和ansible_python_interpreter类似,这里"*"可以是ruby或才perl等其他语言
```
```
101.43.129.109 | FAILED! => {
"msg": "to use the 'ssh' connection type with passwords or pkcs11_provider, you must install the sshpass program"
}
apt-get install sshpass
yum install sshpass
方式二:
1、若yum安装不上,则用下面方法
https://sourceforge.net/projects/sshpass/files/
or
https://pan.baidu.com/s/1pLNxeLd
or
wget http://sourceforge.net/projects/sshpass/files/latest/download -O sshpass.tar.gz
2:下载后,解压,安装
tar -zxvf sshpass-1.06.tar.gz
cd sshpass-1.06
./configure
make
make install
```
[ansible模块](https://blog.csdn.net/qq_36410466/article/details/119812869)