I intend to use ansible to deploy a remote file, since the remote location can only be written with 'root', and local file cannot be downloaded with 'root', I use the following playbook:
# in the main playbook
- hosts: master
user: ec2-user
sudo: yes
# in role definition
# download only in the ansible master node
- local_action: get_url url={{ hadoop_mirrors|random }}/hadoop-{{ hadoop_version }}/hadoop-{{ hadoop_version }}.tar.gz dest=/opt/hadoop-{{ hadoop_version }}.tar.gz force=no
sudo: False
register: result
until: result|success
retries: 5
delay: 2
when: hadoop_type_of_node == 'master'
However Ansible seems incapable of reading the line sudo: False
. When I ran this playbook I still got this error:
TASK [ansible-role-hadoop : get_url] **************************************************************************************************
FAILED - RETRYING: ansible-role-hadoop : get_url (5 retries left).
FAILED - RETRYING: ansible-role-hadoop : get_url (4 retries left).
FAILED - RETRYING: ansible-role-hadoop : get_url (3 retries left).
FAILED - RETRYING: ansible-role-hadoop : get_url (2 retries left).
FAILED - RETRYING: ansible-role-hadoop : get_url (1 retries left).
fatal: [54.201.26.110 -> localhost]: FAILED! => {"attempts": 5, "changed": false, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
to retry, use: --limit @/home/peng/git/datapassport/clusterops/ansible/deploy/master.retry
Why is this line not read and what should I do to fix it?