- Outline
- Simple ansible
- ready
- ansible installation
- Avoid close Login
- Promise
- Because the focus is on iventory, so only the most simple ping module
1. host-simple
- Outline
- Simple version of the hosts file
- hosts
- Not the / etc / hosts
- ansible script, very often, the host needs of the environment
- If the configuration / etc / hosts
- not very convenient
- I can not go along with the script
- Not the / etc / hosts
format
# hosts-simple 192.168.20.135.nip.io ansible_user=root
command
# ansible -i <hosts> <hosts/group> -m <module> > ansible -i hosts-simple 192.168.20.135.nip.io -m ping
- doubt
- nip.io
- This thing in the end is what
- nip.io
2. hosts
- Outline
- hosts file similar systems
- File Structure
- Host name, address
format
<hostName> ansible_host=<ip>
- problem
- ansible_host just a property
- There are other attributes you
- ansible_host just a property
- Clusters
- Outline
- It can be introduced to multiple addresses
format
[groupName] <hostName> <hostName>
- Outline
- Large clusters
- Outline
- Clusters can continue to set
format
[superGrouop:subGroup] <group> <group>
- Outline
- Attributes
- Outline
- Group as a unit, the division of property
format
[group:vars] <key>=<value>
- doubt
- I do not know there is no inheritance relationship
- Outline
Examples
# 1. 服务器 demo ansible_host=192.168.2.135 # 2. 服务器组 [servers] demo # 3. 大组 [cloud:children] servers # 4. 变量 [cloud:vars] ansible_connection=ssh ansible_user=root ansible_private_key_file=~/.ssh/id_rsa host_key_checking=True
- Host name, address
- ansible command: Specify the host file
- default
- /etc/ansible/hosts
parameter
-i <hosts>
- default
2. ping module
- Outline
- ansible functions are implemented by the module
- ping module, so naturally it is to achieve ping function
parameter
-m <module>
3. Packet execution
- Outline
- Execution of the script size, can be specified
command
# 1. 地址对 > ansible -i hosts demo -m ping # 2. 组 > ansible -i hosts servers -m ping # 3. 大组 > ansible -i hosts cloud -m ping # 4. 所有 > ansible -i hosts all -m ping
ps
- ref
- learn python
- Ansible series (a): Basic configuration and usage
- Legacy
- Because it is a novice, so that many parameters are not well understood, and so your studies will be finished up