Ansible playbook to wget a file
I'm trying to wget a file using an Ansible playbook.
My playbook:
- hosts: all
sudo: true
tasks:
- name: Prepare Install folder
sudo: true
action: shell sudo mkdir -p /tmp/my_install/mysql/ && cd /tmp/my_install/mysql/
- name: Download MySql
sudo: true
action: shell sudo wget http://{{ repo_host }}/MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar
I get an error when I execute the following error ansible wget :
ansible-playbook my_3rparties.yml -l vsrv644 --extra-vars "repo_host=vsrv656" -K -f 10
error:
Cannot write to `MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar' (Permission denied).
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/usr2/ihazan/vufroria_3rparties.retry
vsrv644 : ok=2 changed=1 unreachable=0 failed=1
Why do I get this error and how do I solve it?
While getting error ansible wget, it is recommended not to use the shell module when you have the specialized module available.
So what you can do in this case is, create directories using the file module:
- name: create project directory {{ common.project_dir }}
file: state=directory path={{ common.project_dir }}
You can download files with the get_url module below is code for the same:
- name: download sources
get_url: url={{ opencv.url }} dest={{ common.project_dir }}/{{ opencv.file }}