Linux 升级到1.9后,sudo的Ansible文件复制失败

Linux 升级到1.9后,sudo的Ansible文件复制失败,linux,yaml,ansible,ansible-playbook,Linux,Yaml,Ansible,Ansible Playbook,在剧本中,我使用sudo复制文件。它过去是有用的。。。直到我们迁移到Ansible 1.9。。。此后,它将失败,并显示以下错误消息: “ssh连接已关闭,等待sudo密码提示” 我提供ssh和sudo密码(通过Ansible提示符),通过sudo运行的所有其他命令都成功(只有文件副本和模板失败) 我的命令是: ansible playbook-k--ask been pass--limit=testhost-C-D playbooks/debug.yml Playboord包含: - hosts

在剧本中,我使用sudo复制文件。它过去是有用的。。。直到我们迁移到Ansible 1.9。。。此后,它将失败,并显示以下错误消息:

“ssh连接已关闭,等待sudo密码提示”

我提供ssh和sudo密码(通过Ansible提示符),通过sudo运行的所有其他命令都成功(只有文件副本和模板失败)

我的命令是:

ansible playbook-k--ask been pass--limit=testhost-C-D playbooks/debug.yml

Playboord包含:

- hosts: designsync

  gather_facts: yes 

  tasks:
    - name: Make sure the syncmgr home folder exists
       action: file path=/home/syncmgr owner=syncmgr group=syncmgr mode=0755 state=directory
      sudo: yes
      sudo_user: syncmgr

    - name: Copy .cshrc file
      action: copy src=roles/designsync/files/syncmgr.cshrc dest=/home/syncmgr/.cshrc owner=syncmgr group=syncmgr mode=0755
      sudo: yes
      sudo_user: syncmgr
这是一只虫子还是我错过了什么


弗朗索瓦。

你的剧本应该是这样的:

- hosts: designsync

  gather_facts: yes 

  tasks:
    - name: Make sure the syncmgr home folder exists
      sudo: yes
      sudo_user: syncmgr
      file: 
        path: "/home/syncmgr" 
        owner: syncmgr
        group: syncmgr
        mode: 0755 
        state: directory

    - name: Copy .cshrc file
      sudo: yes
      sudo_user: syncmgr
      copy: 
        src: "roles/designsync/files/syncmgr.cshrc" 
        dest: "/home/syncmgr/.cshrc"
        owner: syncmgr 
        group: syncmgr 
        mode: 0755

根据您正在使用的Ansible的确切版本,sudo_用户可能存在错误(我自己也经历过)


尝试将您的剧本从“sudo_用户”更改为“远程_用户”

我看到您正在跨多个服务器复制.cshrc文件,这可能意味着syncmgr用户的远程shell是csh。如果是这样的话。。是的,这至少与1.9和1.8.4挂起(sudo+csh)。我刚刚检查了1.9.1,看起来还可以。你运行的是什么版本?在Ansible 1.9.0.x中确实存在一个与sudo相关的bug,但我认为它只在角色中传递时发生,而不是在任务中。但是如果你正在运行1.9.0.x,你应该升级到1.9.1,然后再试一次。事实上我正在使用1.9.1。。。Ansible主机正在运行RedHat-6.4,远程主机在CentOS-6.5下运行。。。如果有关系(sudo1.8.6,OpenSSH 5.3)。