Jenkins And Ansible: A Get Together
By Sudheer S
If you are wondering how to automate the installation and configuration of Jenkins using code, this post is for you.
Jenkins is a popular open source tool to build CI/CD pipelines.
Ansible is a popular open source tool to automate a lot of things in IT, including CI/CD and infrastructure orchestration.
Ansible can be used to deploy applications in the cloud. Ansible is a nice tool to execute steps such as:
- Git clone and git pull
- Restart application
- Run migration commands
When the teams and number of applications grow over time, a web interface with controlled privileges provides a good developer experience. Often, Ansible playbooks are executed as part of a Jenkins job. For this purpose, there is a Jenkins plugin called Ansible.
To install and configure Jenkins, you can of course use Ansible. I wrote one Ansible role to orchestrate Jenkins. There are a few Ansible modules to help configure parts of Jenkins.
community.general.jenkins_plugin module: with this Ansible module, you can install and uninstall plugins.
community.general.jenkins_script module: with this Ansible module, you can execute arbitrary Groovy scripts on your Jenkins instance. Groovy scripts can be used to create users, credentials, etc.
community.general.jenkins_job module: with this Ansible module, you can create a Jenkins job. Particularly useful to create a seed job.
With this combination of Jenkins and Ansible, orchestrate your CI/CD pipeline.