Hello everyone,
I am using Ansible 2.1.0.0 in a FEDORA environment.I have a playbook which is supposed to run a Python script.The Python script generates directories and subdirectories in /tmp/data/ of the remote machines.What need to do now is : 1)tar the directory in the remote machines and 2) move them to the controlling machines. I have come across the synchronize module and it says compress is ‘yes’ by default.However even when I try compress=yes, I don’t get a zip or a tar file.Getting a tar file would be ideal for me.So, now I have been trying the following way.Here;s my playbook:
I am using Ansible 2.1.0.0 in a FEDORA environment.I have a
playbook which is supposed to run a Python script.The Python script
generates directories and subdirectories in /tmp/data/ of the remote
machines.What need to do now is : 1)tar the directory in the remote
machines and 2) move them to the controlling machines. I have come across
the synchronize module and it says compress is 'yes' by default.However
even when I try compress=yes, I don't get a zip or a tar file.Getting a tar
file would be ideal for me.So, now I have been trying the following
Synchronize is a wrapper around Rsync, Rsync doesn't make zip or tar files. Compress just indicate the data is compressed before transmitted so potential less data has to go over the wire, the data is automatically uncompress before saved to the file system.
way.Here;s my playbook:
---
- hosts: alltasks:
- name: Execute the script
script: /usr10/bhandara/Desktop/RunPy.sh
register: result
until: result.stdout.find("Exiting simulations exploration.")!=-1
retries: 3
delay: 10- name: Compress files in the data directory
shell: tar -cvzf data_directory*.tgz -P /tmp/data/
This is not valid tar usage, you need to sort this out, "man tar" maybe.
- name: fetch the tar file
fetch:
src: /tmp/data/data_directory*.tgz
dest: ~/Desktop/backup/
src take file or directory, it doesn't support wildcards/regexp to my knowledge.
However, I have problems with converting the directory into tar in the
files inside /tmp in remote machines.I get a warning saying" Try using
unarchive .Also, the fetch task failes with a message, the remote task
fails, not transferring, ignored.
Find the correct tar command for taring the directory first. And the rest should be easy to figure out.