我在 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/
我在剧本中做错了什么?
提前谢谢