相关文章推荐
爱旅游的煎饼果子  ·  javascript - ...·  2 年前    · 

192.168.26.128

ansible主控端

192.168.26.129

ansible被控制端

192.168.26.130

ansible被控制端


1、ansible主配置文件/etc/ansible/ansible.cfg和受管主机/etc/ansible/hosts里面的配置


[root@192 ~]# cat /etc/ansible/ansible.cfg |grep -v "^#"|grep -v "^$"

[defaults]

[inventory]

[privilege_escalation]

[paramiko_connection]

[ssh_connection]

[persistent_connection]

[accelerate]

[selinux]

[colors]

[diff]


[root@192 ~]# cat /etc/ansible/hosts |grep -v "^#"|grep -v "^$"

[test]

192.168.26.129

192.168.26.130


2、使用ping模块探测其它主机



[root@192 ~]# ansible test -m ping -k

SSH password:

192.168.26.130 | FAILED! => {

"msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."

192.168.26.129 | SUCCESS => {

"ansible_facts": {

"discovered_interpreter_python": "/usr/bin/python"

},

"changed": false,

"ping": "pong"


3、可以看到192.168.26.130的主机不能到达,原因是这台主机是新加的机器,信息没写入known_hosts文件


4、在/etc/ansible/hosts把host_key_checking = False注释取消


[root@192 ~]# cat /etc/ansible/ansible.cfg |grep -v "^#"|grep -v "^$"

[defaults]

host_key_checking = False

[inventory]

[privilege_escalation]

[paramiko_connection]

[ssh_connection]

[persistent_connection]

[accelerate]

[selinux]

[colors]

[diff]


5、再次执行ping模块探测其它主机


[root@192 ~]# ansible test -m ping -k

SSH password:

192.168.26.129 | SUCCESS => {

"ansible_facts": {

"discovered_interpreter_python": "/usr/bin/python"

},

"changed": false,

"ping": "pong"

192.168.26.130 | SUCCESS => {

"ansible_facts": {

"discovered_interpreter_python": "/usr/bin/python"

},

"changed": false,

"ping": "pong"


6、可以看到正常的探测到其它的机器,这个方法适用大批量的新增主机至/etc/ansible/hosts主机配置文件中






##################################################################################################### 第四,五章 首次登陆 ####################################################################################

postgres 数组字符串包含某个值
一 简介 Postman 是一款功能超级强大的用于发送 HTTP 请求的 Chrome插件 。做web页面开发和测试的人员应该是无人不晓无人不用!其主要特点 特点: 创建 + 测试:创建和发送任何的HTTP请求 一 简介Postman是一款功能超级强大的用于发送 HTTP 请求的 Chrome插件 。做web页面开发和测试的人员应该是无人不晓无人不用!其主要特点