安装
pip install ansible
#
yum install ansible
# 默认目录(如何没有就自行创建)
/etc/ansible
主要配置文件为
ansible.cfg
hosts
# 查看ansible版本
[root@15b883 ~]# ansible --version
ansible 2.10.6
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.8.0 (default, Sep 17 2020, 11:03:48) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
ansible.cfg
[defaults]
# some basic default values...
#inventory = /etc/ansible/hosts #主机列表配置文件
#library = /usr/share/my_modules/ #库文件存放目录
#remote_tmp = $HOME/.ansible/tmp #临时python命令存放在远程主机的目录
#local_tmp = $HOME/.ansible/tmp #本地主机临时命令执行目录
#forks = 5 #默认并发数
#poll_interval = 15
#sudo_user = root #默认sudo用户
#ask_sudo_pass = True #每次执行ansible命令是否询问ssh密码
#ask_pass = True
#transport = smart
#remote_port = 22
#module_lang = C
#module_set_locale = True
#host_key_checking = False #检查对应服务器的host_key,建议取消注释
#log_path=/var/log/ansible.log #日志文件,建议启用
module_name = shell # 模块默认模块是 command
hosts
[master]
13.114.16.212
[bootstrap]
3.112.243.131
[public]
3.112.130.212
[private]
3.112.252.175
[abc:children]
master
bootstrap
public
private
[abc:vars]
ansible_ssh_user=root
#ansible_ssh_pass="123456"
#ansible_ssh_port=22
ansible_ssh_private_key_file=/Users/15b883/keys/sshserver