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:
local_action
) and then use the copy
modulegit
module), copy the files to the desired location with command: cp src dest creates=dest
(perhaps do this with a handler - only when repo has changes to be pulled)command: wget https://raw.github.com/repo/.../file creates=file
in the playbook to only download the file of interest. Is the command
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? local_action
) and then use the copy module to push it to the remote nodeWhat are the advantages/disadvantages of these. Which (if any) of these could be considered good practice. What is the best general solution to this?
I'll start by saying that we chose the 2nd solution for our production environment and I guarantee one thing - it just works. Now for the longer version:
Solution no. 1:
Solution no. 2:
Solution no. 3/4:
My guess it will work, but feels a bit strange to have your configuration in source control and then not really using source control features. The advantage of these solutions is that you can "cherry pick" which configuration files you want to download rather than cloning the whole repository. This also reduces I/O against github as cloning becomes heavier over time.