OPS Tools ansible-Host Group Management (hosts)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.