1.ssh等价性

[root@ansible ansible]# ssh-copy-id 192.168.56.88
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.56.88 (192.168.56.88)' can't be established.
ECDSA key fingerprint is SHA256:kbb/xaKinLr3YzSaqvkSuYr2x4MgX50QhnIPvZH6bcI.
ECDSA key fingerprint is MD5:67:a9:14:9d:8c:8b:35:8c:48:65:eb:ea:61:20:7b:92.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.56.88's password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh '192.168.56.88'"
and check to make sure that only the key(s) you wanted were added.

2.将IP加入/etc/ansible/hosts文件

[mysql]
192.168.56.88

3.执行命令测试Ping模块

[root@ansible ansible]# ansible -i hosts mysql -m ping
192.168.56.88 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}

4.指定IP ping

[root@ansible ansible]# ansible 192.168.56.88 -m ping
192.168.56.88 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}

5.询问输入密码ping​

[root@ansible ansible]# ansible 192.168.56.88 -m ping -k
SSH password: xxxxxxxxx
192.168.56.88 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}

-k参数:
-K, —ask-become-pass
ask for privilege escalation password​​


版权声明:本文为博主原创文章,未经博主允许不得转载。

ansible