How to pull when deployed out of reach

I use Ansible for configuration management and the following task to clone a Git repository:

# Example git checkout from Ansible Playbooks - git: repo=git://foosball.example.org/path/to/repo.git dest=/srv/checkout version=release-0.22 

This is cloning a repo with a specific version.

Does git pull run on restart if repo already exists? Or does he just clone the repo all the time? How to make git pull in Ansible if the repo already exists and how can we run a certain command if the repo exists and the same if the repo was cloned for the first time?

+5
source share
1 answer

Ansible is a declarative tool where you describe how you want your server / environment to look, and Ansible tries to do it. It is also intended for idempotent , which means that re-playing your pieces should reproduce the same end result every time until nothing underneath has changed.

The git module also ascribes this and just tries to make sure that the remote host has a repo on it and the version (or branch / tag) that you requested.

So when you run the git task in your question in the new environment, it clones the repo to the destination folder. In future runs, the repo already exists, so it just does git pull.

If you specify the tag / branch / commit ref in the update property, then it will simply check this version and pull it out.

+8
source

Source: https://habr.com/ru/post/1235600/


All Articles