我有在Ansible以下劇本sudo的權限:複製與下ansible
---
- hosts: ESNodes
sudo: yes
tasks:
- name: Copy Elasticsearch
copy: src=~/elasticsearch-1.0.0.tar.gz dest=/opt/elasticsearch-1.0.0.tar.gz
- name: Untar Elasticsearch
action: shell cd /opt/ && tar xvfz elasticsearch-1.0.0.tar.gz
當運行劇本如下:
bash-4.1$ ansible-playbook es_playbook.yml -K
sudo password:
PLAY [ESNodes] ****************************************************************
GATHERING FACTS ***************************************************************
ok: [isk-vsrv643]
TASK: [Copy Elasticsearch] ****************************************************
failed: [isk-vsrv643] => {"failed": true}
msg: Could not replace file: /usr2/ihazan/.ansible/tmp/ansible-1393762341.08-257257560838959/source to /opt/elasticsearch-1.0.0.tar.gz: [Errno 13] Permission denied: '/usr2/ihazan/.ansible/tmp/ansible-1393762341.08-257257560838959/source'
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/usr2/ihazan/es_playbook.retry
isk-vsrv643 : ok=1 changed=0 unreachable=0 failed=1
它失敗權限的問題。
在遠程主機上,我不能這樣做:
-bash-4.1$ cp elasticsearch-1.0.0.tar.gz /opt/
cp: cannot create regular file `/opt/elasticsearch-1.0.0.tar.gz': Permission denied
但我可以做的:
-bash-4.1$ sudo cp elasticsearch-1.0.0.tar.gz /opt/
什麼我在劇本越來越錯了嗎?
提前
你可以用-vvv運行劇本嗎? – leucos