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 in Ansible by Joe
102 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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

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,190 points
702 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,520 points
69 views
+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
62 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.