A, Ansible host manifest file: Ansible simultaneously operable relationship between a group belonging to multiple hosts, group, and host configuration inventory file by default file path / etc / ansible / hosts.
1, a single host operations:
ansible192.168.154.160 -m shell -a "ip a"
He explained: 192.168.154.160 as the managed host, -m shell: call the shell module, to query the managed host ip
2, the host group management operation:
ansible host -mshell -a "hostname"
Explanation: This is the calling shell module queries hostname
3, understanding host variables: variable along the back of the host is the host variable, you can use
Host variable usage:
First, host group inside the hostname of the host is localhost
Now use host variables change the host name:
ansible host -mshell -a 'hostname host{{ host }}'
Explanation: The double brackets variable is the host variable: that is host, the host list, there are the definition of this host, respectively, 160 and 158, corresponding to the host
4, Group variables: variables are variables set in the host group can be used
The contents of the printed set of variables in each host:
ansible host -mshell -a 'echo {{ port }}'
Explanation: The reference variable or use '{{port}}' in the form of double braces
5, talk about Parameter Description host list:
ansible_ssh_host
Remote host name to be connected. With the alias of the host you want to set different things can be set by this variable.
ansible_ssh_port
ssh port number. If it is not the default port number, by setting this variable.
ansible_ssh_user
The default ssh username
ansible_ssh_pass
ssh password (this way is not safe, we strongly recommend the use of --ask-pass or SSH keys)
ansible_sudo_pass
sudo password (this way is not safe, we strongly recommend the use of --ask-sudo-pass)
ansible_sudo_exe(new in version 1.8)
sudo command path (for 1.8 and above)
ansible_connection
Host connection types such as:.. Local, ssh or paramiko Ansible 1.2 paramiko.1.2 after previous default default 'smart', 'smart' approach will support ControlPersist, judges 'ssh' according to the embodiment is feasible.
ansible_ssh_private_key_file
Ssh private key file used is suitable for multiple keys, and you do not want to use SSH proxy.
ansible_shell_type
shell type target system. By default, the command is executed using the 'sh' grammar, may be set to 'csh' or 'fish'.
ansible_python_interpreter
python path to the target host applies: the system has a plurality of Python, or the command is not the path "/ usr / bin / python", such as * BSD, or / usr / bin / python
Not 2.X version of Python. We do not use the "/ usr / bin / env" mechanism, because it requires that the remote user's path is set up correctly, and require "python" to the name of the executable program name can not be other than python (may actually be named python26).
Ansible_python_interpreter work with the same, the path may be set as a ruby or perl ....
Source: The Definitive Guide to Chinese sources of knowledge ansible
QQ online Zabbix Q group 177,428,068