V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
qweweretrt515
V2EX  ›  问与答

有会 ansible 的同学吗?新手遇到个 bug, ansible all -a "/bin/echo hello" 不返回任何信息,命令行也卡住不动

  •  
  •   qweweretrt515 · Mar 15, 2017 · 3084 views
    This topic created in 3336 days ago, the information mentioned may be changed or developed.

    我的客户端机器是 ubuntu x64 ,

    Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS Release: 16.04 Codename: xenial

    有 2 个机器

    一个是我的虚拟机 [直接用密码登录] , 一个是阿里云机器 [证书+证书密码] ,

    我的虚拟机执行正常,会返回

    192.168.1.119 | SUCCESS => {
        "changed": false,
        "ping": "pong"
    }
    

    但是我的阿里云机器,就什么都不返回了

    然后我再命令后加了个参数 -vvvv 输出如下(IP 地址已模糊化):

    Using /home/xxx/1/ansible.cfg as config file
    Loading callback plugin minimal of type stdout, v2.0 from /usr/local/lib/python3.5/dist-packages/ansible/plugins/callback/__init__.py
    Using module file /usr/local/lib/python3.5/dist-packages/ansible/modules/core/commands/command.py
    <116.11.11.11> ESTABLISH SSH CONNECTION FOR USER: root
    <116.11.11.11> SSH: EXEC sshpass -d12 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="id_rsa.ppk"' -o User=root -o ConnectTimeout=10 -o ControlPath=/home/xxx/.ansible/cp/ansible-ssh-%h-%p-%r 116.11.11.11 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-14894242864.16524274-2192424226872 `" && echo ansible-tmp-1489242864.16524274-21981024246872="` echo ~/.ansible/tmp/ansible-tmp-1482424864.162474-219824243226872 `" ) && sleep 0'"'"''
    

    ansible.cfg

      [defaults]
      hostfile       = hosts
      host_key_checking = False 
    

    hosts

      116.11.11.11 ansible_ssh_user=root ansible_ssh_private_key_file=id_rsa.ppk ansible_ssh_pass=XXXXXX
    

    我弄了半天,搞不清为什么会这样

    求助各位前辈

    Supplement 1  ·  Mar 15, 2017
    追加:

    目前,发现是我没有导入证书,必须要先执行 以下命令才行

    ssh-keygen
    ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
    Supplement 2  ·  Mar 15, 2017
    shell> ssh-agent bash
    shell> ssh-add ~/.ssh/id_rsa
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2461 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:34 · PVG 15:34 · LAX 00:34 · JFK 03:34
    ♥ Do have faith in what you're doing.