Example scenario: config files for a certain service are kept under version control on a private github repo. I want to write a playbook that fetches one of these files on the remote node and puts it into the desired location.
I can think of several solutions to this:
- do a checkout on the machine that runs ansible (
local_action
) and then use thecopy
module - do a checkout on the remote node (with the
git
module), copy the files to the desired location withcommand: cp src dest creates=dest
(perhaps do this with a handler - only when repo has changes to be pulled) - use the url module or
command: wget https://raw.github.com/repo/.../file creates=file
in the playbook to only download the file of interest. Is thecommand
module actually going to check if the file to be created is different from the one that may already exist or does it just check the file exists? - use wget on the machine that runs ansible (
local_action
) and then use the copy module to push it to the remote node
What are the advantages/disadvantages of these. Which (if any) of these could be considered good practice. What is the best general solution to this?