salt.states.git

Interaction with Git repositories

Important: Before using git over ssh, make sure your remote host fingerprint exists in "~/.ssh/known_hosts" file. To avoid requiring password authentication, it is also possible to pass private keys to use explicitly.

https://github.com/saltstack/salt.git:
  git.latest:
    - rev: develop
    - target: /tmp/salt
salt.states.git.config(name, value, repo=None, user=None, is_global=False)

New in version 2014.7.0.

Manage a git config setting for a user or repository

name
Name of the git config value to set
value
Value to set
repo : None
An optional location of a git repository for local operations
user : None
Optional name of a user as whom git config will be run
is_global : False
Whether or not to pass the --global option to git config

Local config example:

mylocalrepo:
  git.config:
    - name: user.email
    - value: fester@bestertester.net
    - repo: file://my/path/to/repo

Global config example:

mylocalrepo:
  git.config:
    - name: user.name
    - value: Esther Bestertester
    - user: ebestertester
    - is_global: True
salt.states.git.latest(name, rev=None, target=None, user=None, force=None, force_checkout=False, force_reset=False, submodules=False, mirror=False, bare=False, remote_name='origin', always_fetch=False, fetch_tags=True, depth=None, identity=None, https_user=None, https_pass=None, onlyif=False, unless=False)

Make sure the repository is cloned to the given directory and is up to date

name
Address of the remote repository as passed to "git clone"
rev
The remote branch, tag, or revision ID to checkout after clone / before update
target
Name of the target directory where repository is about to be cloned
user

Name of the user performing repository management operations

New in version 0.17.0.

force
Force git to clone into pre-existing directories (deletes contents)
force_checkout
Force a checkout even if there might be overwritten changes (Default: False)
force_reset
Force the checkout to --reset hard to the remote ref (Default: False)
submodules
Update submodules on clone or branch change (Default: False)
mirror
True if the repository is to be a mirror of the remote repository. This implies bare, and thus is incompatible with rev.
bare
True if the repository is to be a bare clone of the remote repository. This is incompatible with rev, as nothing will be checked out.
remote_name
defines a different remote name. For the first clone the given name is set to the default remote, else it is just a additional remote. (Default: 'origin')
always_fetch
If a tag or branch name is used as the rev a fetch will not occur until the tag or branch name changes. Setting this to true will force a fetch to occur. Only applies when rev is set. (Default: False)
depth
Defines depth in history when git a clone is needed in order to ensure latest. E.g. depth: 1 is usefull when deploying from a repository with a long history. Use rev to specify branch. This is not compatible with tags or revision IDs.(Default: None)
identity
A path on the minion server to a private key to use over SSH
https_user

HTTP Basic Auth username for HTTPS (only) clones

New in version 2015.5.0.

https_pass

HTTP Basic Auth password for HTTPS (only) clones

New in version 2015.5.0.

onlyif
A command to run as a check, run the named command only if the command passed to the onlyif option returns true
unless
A command to run as a check, only run the named command if the command passed to the unless option returns false

Note

Clashing ID declarations can be avoided when including different branches from the same git repository in the same sls file by using the name declaration. The example below checks out the gh-pages and gh-pages-prod branches from the same repository into separate directories. The example also sets up the ssh_known_hosts ssh key required to perform the git checkout.

gitlab.example.com:
  ssh_known_hosts:
    - present
    - user: root
    - enc: ecdsa
    - fingerprint: 4e:94:b0:54:c1:5b:29:a2:70:0e:e1:a3:51:ee:ee:e3

git-website-staging:
  git.latest:
    - name: git@gitlab.example.com:user/website.git
    - rev: gh-pages
    - target: /usr/share/nginx/staging
    - identity: /root/.ssh/website_id_rsa
    - require:
        - pkg: git
        - ssh_known_hosts: gitlab.example.com

git-website-prod:
  git.latest:
    - name: git@gitlab.example.com:user/website.git
    - rev: gh-pages-prod
    - target: /usr/share/nginx/prod
    - identity: /root/.ssh/website_id_rsa
    - require:
        - pkg: git
        - ssh_known_hosts: gitlab.example.com
salt.states.git.mod_run_check(cmd_kwargs, onlyif, unless)

Execute the onlyif and unless logic. Return a result dict if: * onlyif failed (onlyif != 0) * unless succeeded (unless == 0) else return True

salt.states.git.present(name, bare=True, user=None, force=False, shared=None)

Make sure the repository is present in the given directory

name
Name of the directory where the repository is about to be created
bare
Create a bare repository (Default: True)
user

Name of the user performing repository management operations

New in version 0.17.0.

force
Force-create a new repository into an pre-existing non-git directory (deletes contents)
shared
Specify the permission for sharing, see git-init for details (Default: None)

New in version XXXX.