What is Jenkins & Ansible?
Jenkins is one of the most powerful and commonly used Continuous Integration and Deployment (CI/CD) tool in the DevOps world. A Job in Jenkins denotes an automated flow created to do a particular set of tasks. There are different types of Jobs available in the Jenkins like Freestyle, Pipeline, DSL, etc. with the most common being the Jenkins Pipeline job.
Ansible is one of the most powerful and commonly used open-source Configuration management tool in the DevOps world. It is widely used for software provisioning, automate apps, configuration management and application deployment. It is compatible to run on almost all platforms.
Today's Agenda
In this post, we will learn how to install Jenkins using Ansible Playbook. We will do this installation using the Normal Jenkins Installation with default user token generated and default plugins installed. Refer to this link install Jenkins using the Customised Installation (i.e. with Custom User Credentials and Plugins).
Prerequisite
This post has been prepared for the audience who :
- Have access to a system with Ansible installed and configured on it.
- Have a very basic understanding of Linux commands to debug if there is any errors.
- Have a server setup on which Jenkins needs to be installed.
- And finally, are eager to learn and try such powerful tools.
Let's get started
The Normal Way (With Default User & Plugins)
Step 1: Create an empty Ansible playbook structure for Jenkins.
Create the main work directory in which you will run the below steps.
Run the below command to create a default directory structure that we can change further.
Now, we will make changes in the following 2 files:
1. ansible > roles > jenkins > defaults > main.yml
2. ansible > roles > jenkins > tasks > main.yml
Step 2: Change required playbook files for Jenkins.
In the Ansible playbook file structure, tasks > main.yml file include the main installation steps.
In the Ansible playbook file structure, defaults > main.yml file include the variables that we want to use in our main installation script (tasks > main.yml) file.
Now we make changes in the files that will help Ansible to know the server details on which Jenkins needs to be installed.
1. ansible > jenkins.yml
2. sensible > ansible.cfg
In Ansible, jenkins.yml file includes the hosts, users, basic variables, roles, etc that playbook will need while running.
In Ansible playbook file structure, ansible.cfg file includes the host's authentication details like IP, pem path, etc.
Replace the <jenkins_private_ip> and <pem_path> with the actual values.
Step 4: Run the playbook to get the results.
Run the below command and wait for it to execute successfully.
Comments
Post a Comment