使用ansible 2.1

时间:2016-10-10 19:24:31

标签: ansible ansible-playbook ansible-2.x

当我在父ansible目录中有角色目录时,我能够使用ansible 2.1复制模块。然后我继续在我的playbooks目录中移动角色目录(因为我在调用playbook目录中的play并将角色保留在主ansible目录中时收到错误抱怨缺少角色)。现在,当我运行相同的任务时,复制命令似乎失败并且下面复制了错误(远程计算机上没有任何更改)。

任务

- copy: src={{ debian_build.stdout }}  dest=/home/ubuntu/ owner=ubuntu group=ubuntu mode=644 backup=yes
  become: true
  become_user: root 
  become_method: sudo

debian_build是一个有效的路径。

错误

fatal: [testserver]: FAILED! => {"failed": true, "msg": "Failed to get information on remote file (/home/ubuntu/test-server_0.1.0-27686387a8b765f3dfb0bfea287737f97f223f14_all.deb): MODULE FAILURE"}

更新

site.yml

## move artifacts to remote servers
- include: playbooks/test.yml

剧本/ test.yml

---
- name:  test deployment for xyz 
  hosts: testservers
  strategy: debug  ## turn off if not debugging

  roles:
  - test

测试/任务

main.yml

  • 包括:copy.yml

copy.yml

我尝试将copy.yml修改为以下内容,但都不起作用。

---
- name: transferring artifact to server
  copy:
    src: "{{ lookup('fileglob','/tmp/test/testproj/target/*.deb', wantlist=true) | first }}"
    dest: /home/ubuntu/
    owner: ubuntu
    group: ubuntu
    mode: 644
    backup: yes
  become: true
  become_user: root 
  become_method: sudo

#  local_action: shell ls -d /tmp/repos/latchapi-beta/target/*.deb
#  register: debian_build
#- debug: msg={{ debian_build.stdout }}

#- copy: src={{ debian_build.stdout }}  dest=/home/ubuntu/ owner=ubuntu group=ubuntu mode=644 backup=yes
#  become: true
#  become_user: root
#  become_method: sudo

当我使用-vvv运行playbook时,我会在错误消息之前得到以下输出:

ec2-abc.def.ghi.jkl.compute-1.amazonaws.com> ESTABLISH SSH CONNECTION FOR USER: None
<ec2-abc.def.ghi.jkl.compute-1.amazonaws.com> SSH: EXEC ssh -C -q -o ForwardAgent=yes -o Port=1212 -o 'IdentityFile="/home/testuser/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 ec2-abc.def.ghi.jkl.compute-1.amazonaws.com '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476129233.91-106561207229420 `" && echo ansible-tmp-1476129233.91-106561207229420="` echo $HOME/.ansible/tmp/ansible-tmp-1476129233.91-106561207229420 `" ) && sleep 0'"'"''
<ec2-abc.def.ghi.jkl.compute-1.amazonaws.com> PUT /tmp/tmpRHKTU1 TO /home/testuser/.ansible/tmp/ansible-tmp-1476129233.91-106561207229420/stat
<ec2-abc.def.ghi.jkl.compute-1.amazonaws.com> SSH: EXEC sftp -b - -C -o ForwardAgent=yes -o Port=1212 -o 'IdentityFile="/home/testuser/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 '[ec2-abc.def.ghi.jkl.compute-1.amazonaws.com]'
<ec2-abc.def.ghi.jkl.compute-1.amazonaws.com> ESTABLISH SSH CONNECTION FOR USER: None
<ec2-abc.def.ghi.jkl.compute-1.amazonaws.com> SSH: EXEC ssh -C -q -o ForwardAgent=yes -o Port=1212 -o 'IdentityFile="/home/testuser/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -tt ec2-abc.def.ghi.jkl.compute-1.amazonaws.com '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-khhahbdoujszvmnsqqqoglhkeeihbcog; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/testuser/.ansible/tmp/ansible-tmp-1476129233.91-106561207229420/stat; rm -rf "/home/testuser/.ansible/tmp/ansible-tmp-1476129233.91-106561207229420/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''

1 个答案:

答案 0 :(得分:0)

我安装了acl工具,之后我的ansible playbook工作了:

- name: install setfacl support
  become: yes
  apt: pkg=acl
相关问题