ansible 内置参数

作者: 宇晨棒棒的 | 来源:发表于2021-09-15 21:58 被阅读0次

inventory内置参数

参考解释例子

1)ansible_ssh_host

将要连接的远程主机名.与你想要设定的主机的别名不同的话,可通过此变量设置.

eg: ansible_ssh_host=192.169.1.123

2)ansible_ssh_port  

ssh端口号.如果不是默认的端口号,通过此变量设置  

eg:ansible_ssh_port=5000

3)ansible_ssh_user    默认的 ssh 用户名   

eg:ansible_ssh_user=cxpadmin

4)ansible_ssh_passssh  

密码(这种方式并不安全,我们强烈建议使用 --ask-pass 或 SSH 密钥)   

eg:ansible_ssh_pass=’123456’

5)ansible_sudo_passsudo 

密码(这种方式并不安全,我们强烈建议使用 --ask-sudo-pass)

eg:ansible_sudo_pass=’123456’

6)ansible_sudo_exesudo 

命令路径(适用于1.8及以上版本)   

eg:ansible_sudo_exe=/usr/bin/sudo

7)ansible_connection  

与主机的连接类型.比如:local, ssh 或者 paramiko. 

Ansible 1.2 以前默认使用 paramiko.1.2 以后默认使用 'smart','smart' 方式会根据是否支持 ControlPersist, 来判断'ssh' 方式是否可行.

eg:ansible_connection=local

8)ansible_ssh_private_key_filessh 

使用的私钥文件.适用于有多个密钥,而你不想使用 SSH 代理的情况.

eg:ansible_ssh_private_key_file=/root/key

9)ansible_shell_type

目标系统的shell类型.默认情况下,命令的执行使用 'sh' 语法,可设置为 'csh' 或 'fish'.

eg:ansible_shell_type=zsh

10)ansible_python_interpreter

目标主机的 python 路径.适用于的情况: 系统中有多个 Python, 或者命令路径不是"/usr/bin/python",比如 \*BSD, 或者 /usr/bin/python,

不是 2.X 版本的 Python.我们不使用 "/usr/bin/env" 机制,因为这要求远程用户的路径设置正确,且要求 "python" 可执行程序名不可为 python以外的名字(实际有可能名为python26).

eg:ansible_python_interpreter=/usr/bin/python2.6

11)ansible_*_interpreter

定义其他语言解释器

eg:ansible_*_interpreter=/usr/bin/ruby

12)ansible_sudo

定义sudo用户

eg:ansible_sudo=cxpadmin

注:从ansible2.0开始, 

ansible_ssh_user  ----------------->ansible_user

ansible_ssh_host  ------------------->ansible_host

ansible_ssh_port    ------------------> ansible_port

相关文章

网友评论

    本文标题:ansible 内置参数

    本文链接:https://www.haomeiwen.com/subject/bedqgltx.html