Git Repository Deployment

You can use the globalrepo service to deploy one or multiple Git repositories to the server.

Tip

This feature is not designed to roll out your application. Instead, you should clone/pull your application’s repositories manually via SSH or through a CI job, which will be better in most cases.

If in doubt, contact us, and we will help you select the best approach.

Configuration Options

Enable / Disable

present

  • present enable repository

  • absent disable and remove the repository from the server

  • default: present

Git Repository

source

  • Repository source address, e.g. git@git.example.net:myproject.git

  • you can add a hash of multiple sources and select the appropriate one through the remote parameter

Path on the Server

path

  • local path on the server where the Git repository shall be checked out

  • default: /opt/global/<name> (where <name> is e.g. “myproject” in the examples below)

Commit-Hash

revision

  • desired Git revision (commit-id) to be checked out from the repository

Tip

As you cannot let this module check-out the most recent revision of a branch and have to set a specific commit-hash, that’s why this is not as practical for deploying applications as mentioned before.

SSH Private Key

ssh_private_key

  • SSH private key used to authenticate on the remote server when fetching the repository

  • default: empty

Tip

Use cat /tmp/private_key | python3 -c "import json,sys; print(json.dumps(sys.stdin.read()))" to convert a key into a single line with escaped line breaks. Make sure the string ends with a line break, otherwise SSH will be unable to load the key.

Command

exec_after

  • command executed after update, e.g. composer install

  • default: empty

Configuration Examples

Minimal configuration

Use the Custom JSON at the Server Level Configuration.

{
  "globalrepo::repo": {
    "myproject": {
      "source": "git@git.example.net:myproject.git",
      "revision": "7151c3ebb6bf624388528853afb1613e6543021c"
    }
  }
}

Full example

Use the Custom JSON at the Server Level Configuration.

{
  "globalrepo::repo": {
    "myproject": {
      "ensure": "present",
      "source": "git@git.example.net:myproject.git",
      "path": "/opt/global/myproject",
      "revision": "7151c3ebb6bf624388528853afb1613e6543021c",
      "ssh_private_key": "ssh-private-key",
      "exec_after": "composer update"
    }
  }
}