HAProxy Enterprise Documentation 1.7r1

Git Integration

The Data Plane API integrates with git, enabling you to sync the changes you've made to your HAProxy Enterprise configuration to a remote git repository.

Configure git integration

  1. Install the Data Plane API.

  2. Create a new empty git repository on your version control server (i.e. GitHub, GitLab, Jenkins).

  3. Create an access token so that the Data Plane API can access your remote repository.

  4. On your HAProxy Enterprise server, configure the /etc/hapee-1.7/ directory as a git clone, as shown below:

    • initialize the directory as a local git clone,

    • set its remote URL to be the URL of your git repository,

    • fetch and check out the latest changes.

    $ cd /etc/hapee-1.7/
    $ sudo git init
    $ sudo git remote add origin https://gitlab.mycompany.com/username/repo.git
    $ sudo git fetch
    $ sudo git reset origin/master
  5. Set your username and email for commits.

    $ sudo git config --global user.name "Your Name"
    $ sudo git config --global user.email "name@mycompany.com"
  6. Commit and push the local hapee-lb.cfg file to the remote repository.

    $ sudo git add .
    $ sudo git commit -m "Initial commit"
    $ sudo git push origin master
  7. Add the file /etc/hapee-extras/git.settings with the following fields.

    • Set url to the URL of your git repository,

    • Set auth_access_token to your remote repository's access token.

      "url": "https://gitlab.mycompany.com/username/repo.git",
      "auth_method": "access_token",
      "auth_access_token": "C4Axa1kCcxPv-fzrhsde",
      "storage_type": "dir",
      "storage_dir": "/etc/hapee-1.7/",
      "config_file": "hapee-lb.cfg"
  8. Edit the file /etc/hapee-extras/dataplaneapi.hcl.

    Add the git_mode and git_settings_file fields to the dataplaneapi block.

    dataplaneapi {
      host = ""
      port = 5555
      git_mode = true
      git_settings_file = "/etc/hapee-extras/git.settings"
      userlist {
        userlist = "hapee-dataplaneapi"
      resources {
        maps_dir      = "/etc/hapee-1.7/maps"
        ssl_certs_dir = "/etc/hapee-1.7/ssl"
        spoe_dir      = "/etc/hapee-1.7/spoe"
  9. Restart the Data Plane API. If using the program section in your hapee-lb.cfg file, you can do this by restarting the HAProxy Enterprise service:

    $ sudo systemctl restart hapee-extras-dataplaneapi
  10. Call the pull API endpoint to sync the Data Plane API with changes from the repository.

    $ curl -X POST \
        -u admin:adminpwd \
        -H 'Content-Type: application/json' \
        -d '{ "action":"pull"}' \

Sync changes with the remote repository

Once the configuration directory has been initialized as a local git clone, you can sync any changes by calling the commit and push actions.

For example, you could add a new server to an existing backend named webservers:

$ curl -X POST \
    -u admin:adminpwd \
    -H "Content-Type: application/json" \
    -d '{"name":"anotherserver", "address":"", "port":8080, "check":"enabled"}' \

Then commit the change by calling the commit action on the /services/git/actions API endpoint:

$ curl -X POST \
    -u admin:adminpwd \
    -H 'Content-Type: application/json' \
    -d '{ "action":"commit", "commit_message":"add new web server" }' \

Then push the change to the remote repository by calling the push action:

$ curl -X POST \
    -u admin:adminpwd \
    -H 'Content-Type: application/json' \
    -d '{ "action":"push" }' \

You can also pull the latest changes from the repository by calling the pull action:

$ curl -X POST \
    -u admin:adminpwd \
    -H 'Content-Type: application/json' \
    -d '{ "action":"pull" }'

Next up

Dynamic Data Updates