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
  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-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?

Jan 16, 2019 in Ansible by Celia
2,485 views

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, 2019 by Vaishu

Related Questions In Ansible

0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
739 views
+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,250 points
3,623 views
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, 2019 in Ansible by Jack
437 views
+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,400 points
304 views
0 votes
1 answer
0 votes
1 answer

How to create a new encrpted file using Ansible Vault?

If you are creating a new file ...READ MORE

answered Jan 29, 2019 in Ansible by Kyraa
101 views
0 votes
1 answer

obtain information about a file in windows using ansible playbook

Hey @Travis, you can use the win_stat ...READ MORE

answered Jun 10, 2019 in Ansible by Drake
169 views