Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DevOps Lifecycle
  • DevOps Roadmap
  • Docker Tutorial
  • Kubernetes Tutorials
  • Amazon Web Services [AWS] Tutorial
  • AZURE Tutorials
  • GCP Tutorials
  • Docker Cheat sheet
  • Kubernetes cheat sheet
  • AWS interview questions
  • Docker Interview Questions
  • Ansible Interview Questions
  • Jenkins Interview Questions
Open In App
Next Article:
How To Install Docker Using Ansible Playbook ?
Next article icon

How to Install Git Using Ansible ?

Last Updated : 16 Apr, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

Primary Terminologies Related To Ansible And Git

  • Ansible: Ansible is an open-source automation device utilized for design the management, application arrangement, and system organization. It works on the most common way of managing server configurations and automation dreary undertakings across an organization of PCs.
  • Git: Git is a disseminated rendition control framework utilized for following changes in source code during programming improvement. It permits various designers to team up on projects, oversee modifications, and keep a background marked by changes.
  • Playbook: A playbook is a YAML file containing a set of tasks to be executed by Ansible. It defines the ideal condition of the system and indicates the means expected to accomplish that state.
  • YAML: YAML (YAML Ain't Markup Language) is a human-readable data serialization design utilized in Ansible playbooks to define setups, tasks, and factors, it is ordinarily utilized for its simplicity and readability.
  • Inventory: A inventory is a document that rundowns the target servers or nodes where Ansible will execute tasks. It gives a method for organize and deal with the infrastructure that Ansible communicates with.
  • Task: An task is a single unit of work defined in an Ansible playbook. It addresses an activity to be performed on an target system, like introducing a package, copying a file, or restarting a service.

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

Launch Master And Slave Nodes

  • Now connect with terminal

Connect To EC2 Console

Step 2: Install Ansible

  • Now install ansible in master node. by using following command
sudo amazon-linux-extras install ansible2

Install Ansible

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
Creating Playbook

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

Create Inventory file

  • 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

Configure Inventory File

  • 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>

Providing Permissions On Pem File

  • 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

Pinging with all nodes

Step 5: Running the Playbook

Now execute to run the playbook by using following command

ansible-playbook <filename.yml>

Running Playbook

Step 6: Verify The Git Installation

  • Now slave node connect to terminal and check git version by using following command
git --version

Verifying the Git Installation

Conclusion

In conclusion, the usage of Ansible to automate the installation of Git on servers presents various benefits for software improvement teams and system manage the same. By bridling the joined abilities of Git version control functionality and Ansible's automation highlights, associations can essentially smooth out their deployment processes, improve efficiency, and ensure consistency across their infrastructure.

The incorporation of Git and Ansible works with the adoption of DevOps standards by cultivating consistent coordinated effort among improvement and activities teams, with Git offering vigorous version control capacities and Ansible automating deployment and setup tasks, associations can understand sped up chance to-showcase, raised software quality, and increased agility in light of developing business requests.


Next Article
How To Install Docker Using Ansible Playbook ?

K

kavyaa17
Improve
Article Tags :
  • DevOps
  • Ansible

Similar Reads

  • How To Install PIP Using Ansible ?
    Nowadays the IT culture is evolving with Agile practices and DevOps Culture, on idea of making the business plans, and features quickly to market and making users available. In this software development workflow configuring software and updating the patches to each system manually or through automat
    6 min read
  • How to Install Helm using Ansible Playbook?
    Managing various infrastructure and applications under different conditions in the present dynamic IT landscape can challenge. Automation tools like Ansible assist with smoothing out these undertakings by providing a basic yet amazing method to automate configuration management, application deployme
    8 min read
  • How To Install Docker Using Ansible Playbook ?
    Docker is a software platform that allows you to build, test and deploy applications that use OS-Level virtualization to deliver software in packages called "containers". Containers - Docker package software into standardized units called "Containers". Docker is a stand-alone tool. which means no ne
    7 min read
  • How To Install Java Using Ansible PlayBook ?
    In today's dynamic IT landscape, effective management and automation of software installations across various servers are pivotal for maintaining consistency, dependability, and versatility. Ansible, an open-source automation tool, has acquired huge popularity for its simplicity and flexibility in a
    7 min read
  • How To Install HTTPD Using Ansible Playbook ?
    Ansible is an open-source automation tool that improves IT orchestration, the design of the board, and application deployment. It works over SSH and requires no agent to be installed on a managed host. It is lightweight, efficient, and easy to set up, making it suitable for automating tasks on a var
    8 min read
  • How to Install Apache in Ubuntu using Ansible?
    Apache HTTP Server, commonly referred to as Apache, is a robust and broadly used web server for open-source web server programming. It is exceptionally adaptable and extensible, and it is famous for hosting websites and web applications. Ansible, then again, is a strong automation device that improv
    6 min read
  • How To Install MYSQL Using Ansible Playbook ?
    Introducing MySQL physically on different servers can be a tedious and mistake-inclined process. Be that as it may, with Ansible, an open-source mechanization apparatus, you can computerize the establishment and setup of MySQL across your framework effectively and proficiently. By allowing you to de
    6 min read
  • How To Install Git on AWS?
    Git is a well-known distributed version control system. There are many other distributed version control systems are present, like Mercurial, Bazar, etc but among them, Git is widely used for some of its unique features. Basically Version Control systems are two types. One is Centralised & anoth
    2 min read
  • How To Install Python Using Ansible Playbook ?
    Automation is now absolutely necessary for the effective management of software deployment and infrastructure in IT landscape. Ansible emerges as a main automation tool, eminent for its effortlessness, simplicity, and flexibility. Software installation, configuration management, and application depl
    7 min read
  • How To Install Tomcat Using Ansible Playbook?
    Automating software installation and configuration tasks is fundamental for efficient DevOps practices. Ansible, an open-source automation tool, works on this interaction by permitting you to characterize the framework as code and automate tasks across various servers. In this article, we will zero
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences