Unarchive module overwriting - Ansible

0 votes

I have an ansible playbook that downloads file from the internet and unarchives them and then sends them to another host machine. 

- hosts: group1
sudo: yes
tasks:

  - name: Download and Extract apache
  unarchive:
   src: http://mirrors.up.pt/pub/apache/tomcat/tomcat-9/v9.0.1/bin/apache-tomcat-9.0.1.tar.gz
   dest: /opt/
   remote_src: yes

- name: Copy file to host
  copy: src=/etc/ansible/files/myfile.xml dest=/opt/apache-tomcat-9.0.1/conf/myfile.xml

But everytime I use the unarchive module, ansible is overwriting files with the same content. 

Jan 30, 2019 in Ansible by Joe
3,613 views

1 answer to this question.

0 votes

Hey @joe, you can use the create option, something like this:

- unarchive:
    remote_src : yes
    src        : "{{ url }}"
    dest       : "{{ install_dir }}/"
    creates    : "{{ flagFile }}" 

This creates a flag that will prevent the overwritten if the same content is already present.

answered Jan 30, 2019 by Khadeer

Related Questions In Ansible

0 votes
1 answer

How to use Ansible git module pull a branch with local changes?

You cannot achieve it using the git ...READ MORE

answered Jul 9, 2018 in Ansible by Atul
• 10,240 points
7,032 views
0 votes
1 answer
0 votes
1 answer

Using lxc_container module in ansible

This mostly happens when you've not installed ...READ MORE

answered Aug 10, 2018 in Ansible by DareDev
• 6,890 points
1,619 views
0 votes
1 answer
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,005 views
+2 votes
1 answer
0 votes
1 answer

lineinfile module in Ansible

You can use the lineinfile module for ...READ MORE

answered Jan 17, 2019 in Ansible by Emily
1,481 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP