Ansible Pilot

Checkout git repository via HTTPS - Ansible module git

How to checkout a git repository via HTTPS using Ansible module git.

Automate Git installation and repository checkout with Ansible on multiple hosts. Ensure seamless setup and version control integration.
August 10, 2021
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

YouTube Video

How to checkout git repository via HTTPS?

I’m going to show you a live demo with some simple Ansible code. I’m Luca Berton and welcome to today’s episode of Ansible Pilot

Ansible checkout git repository

Today we’re talking about Ansible module git. The full name is ansible.builtin.git which means is part of the collection of modules “builtin” with ansible and shipped with it. This module is pretty stable and out for years. The purpose is to Deploy software (or files) from git checkouts in our managed hosts. If you would like to fetch via SSH please refer to: Checkout git repository SSH - Ansible module git

Parameters and Return Values

The parameter list is pretty wide but I’ll summarize the most useful.

The only required parameters are “repo” and “dest”.

“repo” specifies the source repository URL.

“dest” specify the destination path.

The “update” retrieves new revisions from the already synched origin repository.

The most interesting return value is “after” which contains the last commit after the update process.


Let’s jump in a real-life playbook to checkout a git repository with Ansible

- name: git module demo
  hosts: all
  become: true
    - name: ensure git pkg installed
        name: git
        state: present

    - name: checkout git repo
        dest: /home/devops/ansible-pilot

code with ❤️ in GitHub


Now you know how to checkout git repository via HTTPS with Ansible. Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.


Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases