ansible with jenkins pipeline

Hi,

Anyone using ansible with jenkins pipeline ?

Can you please point me to some documentation with examples ?

Regards,
Sidh

Are you familiar with groovy syntax? To play around you can setup a pipeline job and create stages for the steps that you want the job to handle.

here is an example stage where yu call a playbook with parameters

stage('deploy') { if ("${DEPLOY_FLAG}" == "true") { // def SSH_KEY='<path>/deploy_id_rsa' def DEP_PLAYBOOK='<path>/deploy_app.yml' sh "ansible-playbook --private-key=${SSH_KEY} -b -e MY_WORKSPACE=${workspace} ${DEP_PLAYBOOK} -l ${DEPLOY_TARGET}" } }

it works nicely and you can see the status of the stages on the job home page.

So an example job which builds and deploys might have stages where you

  • pull from source mgmnt
  • verify
  • build
  • build test
  • deploy to canary
  • sanity check
  • deploy
  • deploy verification
  • tests …
  • post deploy notification

All in one script -

Note in my example the conditional - you can set that either in the gui or in github post hooks etc. So the same pipeline file can handle build tests as well as deploys, etc

I would dive in and sandbox until yuo get comfortable