签到成功

知道了

CNDBA社区CNDBA社区

ansible模块--ping模块

2021-11-14 08:57 1369 0 原创 ansible
作者: hbhe0316

1.ssh等价性http://www.cndba.cn/hbhe0316/article/16619http://www.cndba.cn/hbhe0316/article/16619

http://www.cndba.cn/hbhe0316/article/16619
http://www.cndba.cn/hbhe0316/article/16619

[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文件http://www.cndba.cn/hbhe0316/article/16619http://www.cndba.cn/hbhe0316/article/16619

[mysql]
192.168.56.88

3.执行命令测试Ping模块http://www.cndba.cn/hbhe0316/article/16619http://www.cndba.cn/hbhe0316/article/16619

[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

http://www.cndba.cn/hbhe0316/article/16619

[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 passwordhttp://www.cndba.cn/hbhe0316/article/16619

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

ansible

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1039791次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ