yum -y install epel-release yum list all *ansible* yum info ansible yum -y install ansible
/etc/ansible/ansible.cfg 主配置文件 /etc/ansible/hosts Inventory /usr/bin/ansible-doc 帮助文件 /usr/bin/ansible-playbook 指定运行任务文件
# cd /etc/ansible/ # cp hosts{,.bak} # > hosts # cat hosts [webserver] 127.0.0.1 192.168.10.149 [dbserver] 192.168.10.113
What you can do at the inventory level is add
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
or
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
to your host definition (see Ansible Behavioral Inventory Parameters).
This will work provided you use the ssh
connection type, not paramiko
or something else).
For example, a Vagrant host definition would look like…
vagrant ansible_port=2222 ansible_host=127.0.0.1 ansible_ssh_common_args='-o StrictHostKeyChecking=no'
or
vagrant ansible_port=2222 ansible_host=127.0.0.1 ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
ssh-keygen -t rsa ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.10.149 ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.10.113 ssh-copy-id -i /root/.ssh/id_rsa.pub root@127.0.0.1
ansible-doc -l 列出ansible所有的模块 ansible-doc -s MODULE_NAME 查看指定模块具体适用
ansible <host-pattern> [-f forks] [-m module_name] [-a args] <host-pattern> 这次命令对哪些主机生效的 inventory group name ip all -f forks 一次处理多少个主机 -m module_name 要使用的模块 -a args 模块特有的参数
ansible 192.168.10.113 -m command -a 'date' ansible webserver -m command -a 'date' ansible all -m command -a 'date'
Global Configuration 设置ansible,ansible-playbook路径/usr/bin/