Introduction
In this page we’ll learn how to configure those items:- Get Gitlab to push events (ex: “new MR created”) to Augment Cosmos via webhooks
- Configure a Cosmos Daemon on a AWS EC2 instance/VM (where the Gitlab local repos will be cloned locally)
- Get Augment Cosmos to interact with Gitlab via the
glabcli - Deploy your first Cosmos MR experts

Prerequisites
To configure the one-time connectivity between Cosmos and Gitlab: Cosmos- must be an admin to create a Augment service account and webhooks
- must have at least Maintainer or Owner role on a given project, or be Owner of a group that has access to given projects
- allow inbound connections from other VMs on your VPC (inbound calls will come from within your network)
- must have the ability to deploy EC2 instances in a VPC that has network connectivity to your Gitlab self-hosted. Must enable outbound network connectivity to *.augmentcode.com (see https://docs.augmentcode.com/setup-augment/network-configuration)
Step 1 - Configure Gitlab to notify a Cosmos Webhook
Webhook receiver in Cosmos
Let’s create a new webhook in Cosmos (so Cosmos can listen to Gitlab events):- As an admin go to Cosmos (https://cosmos.augmentcode.com) > Settings > Webhooks > Create a webhook > Select type: GitLab > Enter Description: GitLab MR events



text
Webhook sender in Gitlab
Create a new webhook config in Gitlab** **(so Gitlab can POST to a given url when certain Gitlab events occur): as a Maintainer or Owner, go to your Gitlab repo > Settings > Webhooks > Add new webhook > Add those details:- Name: Notify Cosmos on MR created/updated/merged/commented
- URL: the webhook url provided by Cosmos
- Secret token: the secret provided by Cosmos
- Trigger:
CommentsandMerge request events - Custom header: leave empty
- Enable SSL verification: keep it selected
- Click on Add webhook





Step 2 - Create a Gitlab Service Account
For headless automation and to start agentic workflows based on Gitlab events, you’ll create a dedicated Gitlab service account and its access token: Gitlab repo > Settings > Service accounts > Add service account > Add a name (ex: Cosmos-XXX) and username (ex: cosmos-xxx):

- Enter a token name (ex: Cosmos01)
- Set a max expiration date as far out as possible
- Select scope
api - Click on Generate token


Maintainer onto the repos where the service account should be able to read/post (add it per repo or add it to the group that manages all the repos):
Go to your Gitlab repo(s) > Manage > Members > Invite members > add your Gitlab service account and click on Invite:

Step 3 - Create a Augment service account
Before we start the websocket tunnel from your AWS EC2 instance to Cosmos, you’ll need to create a dedicated Augment service account, which will be used to authenticate and start the tunnel. As an admin go to https://app.augmentcode.com/ > Service Accounts > + Add Service Account > Add:



Step 4 - Create a Cosmos daemon pool
Since you’ll be leveraging a AWS EC2 VM to host your daemon, it’s important to think about uptime and resilience: your VM could loose network connectivity or have an outage. The best practice is to create a daemon pool and attach your daemons to that daemon pool. Then you can later have N daemons (1 per VM) all tied to the same daemon pool, and Cosmos will use that pool which will automatically route to the next available daemon. In this guide you’ll create 1 daemon pool and 1 daemon running in 1 VM, but you can extend that approach to spin up 2 more VMs (and their respective daemons) for max resilience. Go to Cosmos (https://cosmos.augmentcode.com) > Settings > Environments > Create an environment > Daemon Pool:
- Name: Team01-Pool-Gitlab-SelfHosted
- Daemon connector: select the dedicated service account you created in the section earlier
- Shared: toggle on
- Workspace behavior:
Isolated workspace



Step 5 - Configure your VM with local Gitlab repos, glab cli and Cosmos daemon
In this section you’ll configure a AWS EC2 VM with the following:- locally cloned Gitlab repos
glabcli so Cosmos local agents can communicate to Gitlab- a Cosmos pool + daemon (to establish an outbound websocket tunnel from AWS to Cosmos)
Create the VM, with git and NVM/node
Create a new AWS EC2 Linux instance (ex: Ubuntu x86_64 - ami-091138d0f0d41ff90) in a AWS VPC that will be able to reach your Gitlab Self-Hosted instance. Minimum config recommended: 4 vCPU, 16 GB RAM, 100 GB SSD


Git clone your Gitlab repos locally
Create a local ~/workspace/ folder In that workspace folder create folders for your Gitlab organizations In the corresponding organization folders, git clone your repos (you need at a minimum an empty git repo with at least one commit for the git worktree configuration to be valid and for the agent to start) You should have a “2 layers” folder structure like this:- ~/workspace/augmentcode-sa1/REPO_A/.git
- ~/workspace/augmentcode-sa1/REPO_B/.git
- ~/workspace/augmentcode-sa2/REPO_C/.git
- ~/workspace/augmentcode-sa2/REPO_D/.git
Note: at this moment you have to own making sure that the git repos are locally cloned and are kept up to date regularly. In a future release, daemons will be able to handle that on your behalf - stay tuned
Install and authenticate the glab CLI
Install theglab cli: make sure you’re in your root folder, install the glab cli using this command:
glab cli, run:
text
Start the daemon
cd into ~/workspace/ run- “Launch dir is a non-git container; adopting N discovered git repo(s) as workspaces […]” ⇒ check that all your local git repos have been discovered
- “Git worktree support: supported”
- “Joining daemon pool: <YOUR-POOL-ID>”
- “Indexing enabled for workspace: […]”
- “Starting Auggie Daemon […]”
- “Connecting to Cosmos…”



Step 6 - Connectivity test
Now you’ll create a session in Cosmos (cloud) and verify it can connect to the VM, make sense of the local repos and from that VM reach out to Gitlab via theglab CLI.
Go to Cosmos > New Session (https://cosmos.augmentcode.com/home)
Under the prompt, click on the dropdown list with the cloud icon > select Daemon > select your daemon pool:



glab cli to lookup the MR.
Step 7 - Create your Cosmos Experts
Now that connectivity is established, you can focus on deploying your Cosmos experts. You can follow the steps in https://docs.augmentcode.com/cosmos/gitlab-cloud#step-3-create-a-mr-deep-reviewer-expert to create a MR author, MR Deep Code Reviewer etc. The only key difference is you’ll have to explicitly instruct Cosmos Advisor to do the following when deploying those experts:- use the
glabcli (instead of the native Gitlab Cloud integration) - use your daemon pool (instead of the cloud environment)
- use the Gitlab webhook (instead of the native Gitlab Cloud integration)
Congratulations, you’ve integrated Cosmos with Gitlab Self-Hosted and deployed your first MR experts! 🎉