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

  - name: Download and Extract apache
   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 in Ansible by Joe

1 answer to this question.

Your answer

Your name to display (optional):
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 by Khadeer

Related Questions In Ansible

0 votes
1 answer


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

answered Jul 9, 2018 in Ansible by Atul
• 10,190 points
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,520 points
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

lineinfile module in Ansible

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

answered Jan 16 in Ansible by Emily
