Ansible playbook to wget a file

0 votes

I'm trying to wget a file using an Ansible playbook. 

My playbook:

- hosts: all
  sudo: true
  - 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-playbook my_3rparties.yml -l vsrv644 --extra-vars "repo_host=vsrv656" -K -f 10 


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?

Jan 16 in Ansible by Celia

1 answer to this question.

0 votes

Hey @Celia, one recommendation, try not using the shell module when you have the a specialized module available.

In this case, create directories using the file module:

- name: create project directory {{ common.project_dir }}
  file: state=directory path={{ common.project_dir }}

Download files with get_url module:

- name: download sources
  get_url: url={{ opencv.url }} dest={{ common.project_dir }}/{{ opencv.file }}

This is the easiest way of doing this.

answered Jan 16 by Vaishu

Related Questions In Ansible

0 votes
1 answer
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,240 points
0 votes
1 answer
0 votes
1 answer

Ansible Playbook to create a Load Balancer

Hey @Himanshu, you can try something like ...READ MORE

answered Mar 25 in Ansible by Jack
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer