How To Install Git Using Ansible: A Step-By-Step Guide
Step 1: Launch An Instance
- Now go to AWS Management console and login with credentials ,Here we are going to launch two instances one is master node another is slave node.
- Now launch an two EC2 instances
- Now connect with terminal
Step 2: Install Ansible
- Now install ansible in master node. by using following command
sudo amazon-linux-extras install ansible2
Step 3: Creating Playbook
- Create a new YAML file, with .yml extension to define the git installation tasks on slave node. By using this playbook we are installing git on slave node.
- Here is the script to install git using ansible playbook
- name: Install Git on Amazon Linux
hosts: your_amazon_linux_instance_name
become: true
tasks:
- name: Install Git
yum:
name: git
state: present
Step 4: Creating Inventory File Or Setting Up Host Permissions
- Create an inventory file listing the target servers where Git will be installed on slave node.
- Now by using cd command move to ansible directory path
- In host file we are providing slave node details because target group is slave node. Git can be installed on slave node.
ansible_host=private IP address of slave node
ansible_user=ec2-user
ansible_ssh_private_key=keypair file path
- Now we need to import our keypair from desktop to local machine by using following command
scp -i keyapir.pem keypair.pem ec2-user@public-IP-address:/home/ec2-user #this is our home directory path
- Now we need to change file permission to only read. We only providing read permissions , so users cannot edit this file
sudo chmod 400 <filename>
- So now we are verifying that our master node is connected or not to slave node, it can be check by using following command
ansible all -m ping
Step 5: Running the Playbook
Now execute to run the playbook by using following command
ansible-playbook <filename.yml>
Step 6: Verify The Git Installation
- Now slave node connect to terminal and check git version by using following command
git --version
How to Install Git Using Ansible ?
Git is a powerful and broadly utilized version control system that assumes a crucial role in current software development work processes, it gives developers a powerful structure for tracking changes in source code, planning cooperative work, and managing project chronicles proficiently. With its conveyed architecture, Git empowers groups to work flawlessly across various areas, enabling joint effort and ensuring code integrity.
Consolidating the capacities of Git and Ansible presents a convincing solution for automating the arrangement and maintenance of software improvement environments. Introducing Git utilizing Ansible streamlines the most common way of provisioning servers with the important tools for adaptation control, upgrading efficiency and empowering fast emphasis in the product advancement lifecycle. Then again, Ansible serves in as a flexible automation device that works on the management of server setups, application deployment, and infrastructure orchestration. By utilizing Ansible, associations can smooth out their operations, reduce manual exertion, and authorize predictable designs across their environments.
Contact Us