git - Deploy software (or files) from git checkouts

Author:Michael DeHaan

Synopsis

Manage git checkouts of repositories to deploy files or software.

Options

parameter required default choices comments
accept_hostkey no no
  • yes
  • no
if yes, adds the hostkey for the repo url if not already added. If ssh_args contains "-o StrictHostKeyChecking=no", this parameter is ignored. (added in Ansible 1.5)
bare no no
  • yes
  • no
if yes, repository will be created as a bare repo, otherwise it will be a standard repo with a workspace. (added in Ansible 1.4)
depth no
    Create a shallow clone with a history truncated to the specified number or revisions. The minimum possible value is 1, otherwise ignored. (added in Ansible 1.2)
    dest yes
      Absolute path of where the repository should be checked out to.
      executable no
        Path to git executable to use. If not supplied, the normal mechanism for resolving binary paths will be used. (added in Ansible 1.4)
        force no yes
        • yes
        • no
        If yes, any modified files in the working repository will be discarded. Prior to 0.7, this was always 'yes' and could not be disabled. (added in Ansible 0.7)
        key_file no None
          Uses the same wrapper method as ssh_opts to pass "-i <key_file>" to the ssh arguments used by git (added in Ansible 1.5)
          recursive no yes
          • yes
          • no
          if no, repository will be cloned without the --recursive option, skipping sub-modules. (added in Ansible 1.6)
          reference no
            Reference repository (see "git clone --reference ...") (added in Ansible 1.4)
            remote no origin
              Name of the remote.
              repo yes
                git, SSH, or HTTP protocol address of the git repository.
                ssh_opts no None
                  Creates a wrapper script and exports the path as GIT_SSH which git then automatically uses to override ssh arguments. An example value could be "-o StrictHostKeyChecking=no" (added in Ansible 1.5)
                  update no yes
                  • yes
                  • no
                  If no, just returns information about the repository without updating. (added in Ansible 1.2)
                  version no HEAD
                    What version of the repository to check out. This can be the full 40-character SHA-1 hash, the literal string HEAD, a branch name, or a tag name.

                    Examples


                    # Example git checkout from Ansible Playbooks
                    - git: repo=git://foosball.example.org/path/to/repo.git
                           dest=/srv/checkout
                           version=release-0.22
                    
                    # Example read-write git checkout from github
                    - git: repo=ssh://git@github.com/mylogin/hello.git dest=/home/mylogin/hello
                    
                    # Example just ensuring the repo checkout exists
                    - git: repo=git://foosball.example.org/path/to/repo.git dest=/srv/checkout update=no

                    Note

                    If the task seems to be hanging, first verify remote host is in known_hosts. SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt, one solution is to add the remote host public key in /etc/ssh/ssh_known_hosts before calling the git module, with the following command: ssh-keyscan -H remote_host.com >> /etc/ssh/ssh_known_hosts.

                    Table Of Contents

                    Previous topic

                    bzr - Deploy software (or files) from bzr branches

                    Next topic

                    github_hooks - Manages github service hooks.