我这里就添加了两个主机组:local、web,local主机组两台主机,web主机组4台主机。
这里你可以把同一类主机或者是想统一管理的主机放在一个主机组里。 # 其他ansible2.3 inventory参数举例
General for all connections:
ansible_hostThe name of the host to connect to, if different from the alias you wish to give to it.ansible_portThe ssh port number, if not 22ansible_userThe default ssh user name to use.
Specific to the SSH connection:
ansible_ssh_passThe ssh password to use (never store this variable in plain text; always use a vault. See Variables and Vaults)ansible_ssh_private_key_filePrivate key file used by ssh. Useful if using multiple keys and you don’t want to use SSH agent.ansible_ssh_common_argsThis setting is always appended to the default command line for sftp, scp, and ssh. Useful to configure a ProxyCommand for a certain host (or group).ansible_sftp_extra_argsThis setting is always appended to the default sftp command line.ansible_scp_extra_argsThis setting is always appended to the default scp command line.ansible_ssh_extra_argsThis setting is always appended to the default ssh command line.ansible_ssh_pipeliningDetermines whether or not to use SSH pipelining. This can override the pipelining setting in ansible.cfg.ansible_ssh_executable (added in version 2.2)This setting overrides the default behavior to use the system ssh. This can override the ssh_executable setting in ansible.cfg.
Privilege escalation (see Ansible Privilege Escalation for further details):
ansible_becomeEquivalent to ansible_sudo or ansible_su, allows to force privilege escalationansible_become_methodAllows to set privilege escalation methodansible_become_userEquivalent to ansible_sudo_user or ansible_su_user, allows to set the user you become through privilege escalationansible_become_passEquivalent to ansible_sudo_pass or ansible_su_pass, allows you to set the privilege escalation password (never store this variable in plain text; always use a vault. See Variables and Vaults)ansible_become_exeEquivalent to ansible_sudo_exe or ansible_su_exe, allows you to set the executable for the escalation method selectedansible_become_flagsEquivalent to ansible_sudo_flags or ansible_su_flags, allows you to set the flags passed to the selected escalation method. This can be also set globally in ansible.cfg in the sudo_flags option
Remote host environment parameters:
ansible_shell_typeThe shell type of the target system. You should not use this setting unless you have set the ansible_shell_executable to a non-Bourne (sh) compatible shell. By default commands are formatted using sh-style syntax. Setting this to csh or fish will cause commands executed on target systems to follow those shell’s syntax instead.ansible_python_interpreterThe target host python path. This is useful for systems with more than one Python or not located at /usr/bin/python such as *BSD, or where /usr/bin/python is not a 2.X series Python. We do not use the /usr/bin/env mechanism as that requires the remote user’s path to be set right and also assumes the python executable is named python, where the executable might be named something like python2.6.ansible_*_interpreterWorks for anything such as ruby or perl and works just like ansible_python_interpreter. This replaces shebang of modules which will run on that host.
New in version 2.1.
ansible_shell_executableThis sets the shell the ansible controller will use on the target machine, overrides executable in ansible.cfg which defaults to /bin/sh. You should really only change it if is not possible to use /bin/sh (i.e. /bin/sh is not installed on the target machine or cannot be run from sudo.).
# ansible local -m ping #使用ping模块 server
| UNREACHABLE! => {"changed": false,"msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", }
client
| UNREACHABLE! => {"changed": false,"msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", }