The best way to apply a git patch via Ansible -


i need deploy bunch of ubuntu servers in same way, thought of using ansible instead of doing manually each time need new one.

one of things need git clone upstream repo, , apply custom patch it. hoping save patch in ansible directory under files/, there doesn't seem "git apply" function in git ansible module. what's best practise of doing this?

some options:

  1. run own git repo branch including patch. work, have maintain own git repo somewhere , make sure servers have access/permissions it. nice if configurations kept in ansible directory instead of relying on git repo have maintain.
  2. use shell or command module. easiest working, won't able re-run playbook.
  3. other suggestions?

use ansible script module.

write shell script attempts patch git repository local patch.

handle various possibilities :

  • being invoked during cookbook re-run.
  • the latest upstream source containing identical change local patch.
  • the local patch no longer being applicable on latest upstream source.

a sample shell script template above :

# sync local copy latest changes upstream git repository.  # todo : check here return code of "git am" failure. # # if <filename.patch> applied, : # - cookbook re-run, #   or # - latest upstream source comes patch applied. # display/log info message , skip end of script.  # patch latest upstream source local patch echo "attempting apply <filename.patch>..."  cd <local-clone-dir> git <filename.patch>  # todo : check here return code of "git am" failure. # # in case <filename.patch> no longer applies  # latest version of source upstream repo, # display/log error , abort immediately.  echo "successfully applied <filename.patch>."   # continue rest of tasks. 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -