AnsibleHost group Management:
Ansible Configuration
Description: About the parameters available in the Ansible Hosts file:
Ansible_ssh_port=22 #远程主机登陆端口
Ansible_ssh_user=root #远程主机登陆用户名
Ansible_ssh_pass=chekir #远程主机登陆用户名的密码
Ansible_ssh_private_key_file=/etc/ansible/hosts #指定管理主机群列表文件
Host_key_checking=false #跳过第一次连接检测询问是否登陆的提示 (yes/no)
Here Hosts file I did a mutual trust authentication, so the hosts file I wrote a host IP, port number default words can not write
1. Backup Ansible Hosts file:
[Email protected] ~]# Cp/etc/ansible/hosts/etc/ansible/hosts.bak
2. Empty the Hosts file, define the host group
[Email protected] ~]# cat/etc/ansible/hosts[test]192.168.1.2
3. Test Ansible
[Email protected] ~]# ansible-i/etc/ansible/hosts test-m shell-a ' uptime ' 192.168.1.2 | Success | Rc=0 >> 14:28:04 up 21:12, 3 users, load average:0.01, 0.02, 0.00[[email protected] ~]# ansible test-i/etc/ansi Ble/hosts-m command-a ' Date ' 192.168.1.2 | Success | Rc=0 >>wed Dec 14:30:40 CST 2015
#参数解释:
-I: Specify host list file
-U: Specify remote host login user
-M: Specify the module using Ansible
-A: Specify the parameters used under the module
-K: Specifies the password for the remote login user
The commands tested above can also be abbreviated:
[Email protected] ~]# ansible test-a ' Date ' 192.168.1.2 | Success | Rc=0 >>wed Dec 14:33:53 CST 2015
Test remote host status to see if it survives
[[email protected] ~]# ansible all-m ping 192.168.1.2 | Success >> {"Changed": false, "ping": "Pong"}
This article is from the "Linux---basics" blog, so be sure to keep this source http://perin.blog.51cto.com/10410663/1725195
OPS Tools ansible-Host Group Management (hosts)