ansible与semaphoreUI(二)-ansible个性化定制SSH连接登录端口

189 阅读1分钟

配置hosts文件

如果管理的主机端口和密码不相同,可以通过配置hosts文件的方式实现个性化。 以下是investory常用的定义规则:

ansible_ssh_host: ansible使⽤ssh要连接的主机。
ansible_ssh_port : ssh的端⼝。默认为22。
ansible_ssh_user: ssh登录的⽤户名。默认为root。
ansible_ssh_pass : ssh登录远程⽤户时的认证密码.
ansible_ssh_private_key_file: ssh登录远程⽤户时的认证私钥。(?)
ansible_connection : 使⽤何种模式连接到远程主机。默认值为smart(智能),表⽰当本地ssh⽀持持久连接(controlpersist)时采⽤ssh连接,否则采⽤python的paramiko ssh连接。
ansible_shell_type : 指定远程主机执⾏命令时的shell解析器,默认为sh(不是bash,它们是有区别的,也不是全路径)。
ansible_python_interpreter: 远程主机上的python解释器路径。默认为/usr/bin/python。
ansible_*_interpreter:使⽤什么解释器。例如,sh、bash、awk、sed、expect、ruby等等。

以下是一个个性化配置示例:

[cluster]
hostA.com 
[cluster:vars]
ansible_ssh_port=222   #自定义端口
ansible_ssh_pass='ww%GDtfIBpoA5j6mnwod3t5ww'   ###自定义密码