Monday, February 29, 2016

How to copy files/directories from list preserving directory


Create a directory 'newdir',
And run the following supplying the filelist file:


You have the following tree as in example:

Now, you have the following list of files inside `filelist.txt`:

You want to copy somewhere else only this files.
The script should run inside the `dir0` directory.
The above script will run on each row inside filelist.txt and copy them to `newdir`. `newdir` should be created before running the script.

* It does not matter if the end path is a file or directory

Ansible and Jinja2: Check if variable is defined and it's True

Jinja2 provides you with a built in test: So you can simply use: However, if you...