Ansible + Jenkins

Hi!
Everybody knows, how to run ansible playbook from jenkins ci?

Hi,

why dont use a “Shell” Buildstep and inside just do:

ansible-playbook –i /path/to/hosts playbook.yml –v –extra-vars … and so on?

Of course you need an Ansible installation on your system, first.

That´s the way how I´ve setup this – and all playbooks are executed immediately after a SVN commit – running against local virtual environments.

Regards, Torsten

Hello Alex,

As Torsten said you, you can use "Shell buildstep" and invoke your
playbook (Ansible).
At ClinkerHQ (Hosted CI service based on Jenkins) you can available
Ansible Playbook.

Disclaimer: I work at ClinkerHQ.

Regards,

You can use ‘Publish over SSH’ module to call a remote system running ansible.
Configure your ansible host in Jenkins → Manage Jenkins → Configure System
Then you can add a post build action called ‘Send Build artifacts over ssh’. Select your ansible host and then in the Transfers section, specify commands to run on your ansible host. You don’t actually have to transfer files with this action.

An alternative, which you may like, is to install Ansible Tower, and then use ansible-tower-cli in your shell step.

It makes integration with Jenkins a one liner.

It will get you nicer output, particularly for a larger number of hosts, than Jenkins, and also some nice ways to edit inventory and identify problems.

I use jenkins heavily for orchestration, in a setup where I have multiple jenkins CD pipelines in different environments all deploying code using Ansible.

See this setup below, it’s an example for deploying jenkins, setting up the jobs and dependencies.
It also shows how to provisioning and configure a zabbix box using Ansible executed from a jenkins job,
you should be able to adapt it to execute anything you like

https://github.com/Azulinho/ansible-jenkins-showcase

or check out Tower :slight_smile:

i configure like as below for ci

1)i configured Jenkins,maven and git
2) In that .war file to upload to S3 bucket uisng publish artifacts to s3 bucket plugin
3) create new EC2 instance using cloud formation template from S3 bucket using cloud formation plugin
4) now i want to configure Ansible plugin in jenkins how to configure please help me …