在剧本中,我使用sudo复制文件。它曾经工作......直到我们迁移到Ansible 1.9 ...从那时起,它失败并出现以下错误消息:
“ssh连接已关闭,等待sudo密码提示”
我提供了ssh和sudo密码(通过Ansible提示符),并且通过sudo运行的所有其他命令都成功(只有文件副本和模板失败)。
我的命令是:
ansible-playbook -k --ask-become-pass --limit = testhost -C -D playbooks / debug.yml
并且playbookd包含:
- 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
这是一个错误还是我错过了什么?
弗朗索瓦。
答案 0 :(得分:0)
你的剧本应该是这样的:
- 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
答案 1 :(得分:0)
Depending on the exact version of Ansible you're using, there may be a bug with sudo_user (experienced it myself).
Trying changing your playbooks from "sudo_user" to "remote_user".