Wednesday, October 11, 2017
Saturday, October 7, 2017
Ansible plugin for Jenkins
I need to utilize my ansible playbook in jenkins. We do have a plugin called Ansible Plugin.
You can install this plugin from jenkins itself. Once you login in jenkins --> Manage Jenkins --> Manage Plugins search for ansible plugin. Select, download and install plugin with restart of jenkins.
What we are doing here in this example:
I had a playbook, which contains two hosts, office.lan and lb.lan, the play book will just print a message "Hello from Ansible!!" when it runs.
Here is my ansible directory structure:
Directory: /home/shivin/Desktop/ansible-workshop
File : main.yml
Other directory: inventories/localdc
Run this play book from shell :
ansible-playbook main.yml -i inventories/localdc --user root --ask-pass
This will ask for the password and will get a result, if everything is configured correctly.
How we can configure in Jenkins:
First need to give the ansible path in jenkins. Login to Jenkins --> Manage Jenkins --> Global Tool Configuration
Give a name : Ansible<version>
Path to ansible executables directory: /usr/bin/
For job configuration:
In my jenkins job, i am downloading the ansible playbook files from GIT to the workspace.
Then run the job :)
You can install this plugin from jenkins itself. Once you login in jenkins --> Manage Jenkins --> Manage Plugins search for ansible plugin. Select, download and install plugin with restart of jenkins.
What we are doing here in this example:
I had a playbook, which contains two hosts, office.lan and lb.lan, the play book will just print a message "Hello from Ansible!!" when it runs.
Here is my ansible directory structure:
Directory: /home/shivin/Desktop/ansible-workshop
File : main.yml
Other directory: inventories/localdc
Run this play book from shell :
ansible-playbook main.yml -i inventories/localdc --user root --ask-pass
This will ask for the password and will get a result, if everything is configured correctly.
How we can configure in Jenkins:
First need to give the ansible path in jenkins. Login to Jenkins --> Manage Jenkins --> Global Tool Configuration
Give a name : Ansible<version>
Path to ansible executables directory: /usr/bin/
For job configuration:
In my jenkins job, i am downloading the ansible playbook files from GIT to the workspace.
Then run the job :)
Subscribe to:
Posts (Atom)