<p>A gitlab runner is a process that f.e. tests, compiles your project, pushes the artefact to you artefact store etc.</p>
<p>A Gitlab runner can be tagged inside Gitlab or via config.toml - so - you can assign runners via tags to Gitlab projects (shared).</p>
<p>Gitlab runner are not designed to run an application 24x7. So - you assign a project to a runner (or a tag or all) to build you application). If you want to deploy the project, use the K8S deployment inside Gitlab (that must be connected to a specific Kubernetes environment based on you Git-branches etc). Or (just an example) run an AWX task that is able to push your new artefact via the artefact storage (docker registry). Also you could just call a SSH remote command on a script (via Gitlab runner) to start a deployment - but don't use the runner to &quot;host&quot; your environment. They will stop (per default after 1h) without a return code.</p>

CC BY-SA 4.0
2021-02-15T15:05:06.383Z
2021-02-15T15:05:06.383Z
TRW
<p><strong>Given</strong></p>
<p>We run an in-house <code>GitLab</code> server, with many <code>projects</code> (aka &quot;<code>repositories</code>&quot;)</p>
<p>We provision all servers using <code>Ansible</code> (and deploy projects using <code>pip</code>)</p>
<p>We deploy to</p>
<ul>
<li>dev.project.example.com</li>
<li>test.project.example..com</li>
<li>beta.project.example..com</li>
<li>(and eventually to) www.project.example..com</li>
</ul>
<p><strong>When</strong></p>
<p>We add <code>.gitlab-ci-.yml</code> to all <code>project</code>s' <code>repository</code> roots</p>
<p>We want to use <code>dev.project.example.com</code> as a runner for that <code>GitLab project</code></p>
<p><strong>Then</strong></p>
<p>What Ansible playbooks could we write to provision <code>dev.project.example.com</code> as a <code>GitLab Runner</code> for that <code>project</code>?</p>

<ansible><gitlab><gitlab-ci-runner>
How can we prepare GitLab runners using Ansible deploys
jalanb
# How can we prepare GitLab runners using Ansible deploys

(Asked by: username_0 on 2021-02-06)

**Given**

We run an in-house `GitLab` server, with many `projects` (aka "`repositories`")

We provision all servers using `Ansible` (and deploy projects using `pip`)

We deploy to

* dev.project.example.com
* test.project.example..com
* beta.project.example..com
* (and eventually to) www.project.example..com

**When**

We add `.gitlab-ci-.yml` to all `project`s' `repository` roots

We want to use `dev.project.example.com` as a runner for that `GitLab project`

**Then**

What Ansible playbooks could we write to provision `dev.project.example.com` as a `GitLab Runner` for that `project`?

**Tags:** ansible, gitlab, gitlab-ci-runner


---

## 1 answers

### Answer by username_1 on 2021-02-15. Score: 1

A gitlab runner is a process that f.e. tests, compiles your project, pushes the artefact to you artefact store etc.

A Gitlab runner can be tagged inside Gitlab or via config.toml - so - you can assign runners via tags to Gitlab projects (shared).

Gitlab runner are not designed to run an application 24x7. So - you assign a project to a runner (or a tag or all) to build you application). If you want to deploy the project, use the K8S deployment inside Gitlab (that must be connected to a specific Kubernetes environment based on you Git-branches etc). Or (just an example) run an AWX task that is able to push your new artefact via the artefact storage (docker registry). Also you could just call a SSH remote command on a script (via Gitlab runner) to start a deployment - but don't use the runner to "host" your environment. They will stop (per default after 1h) without a return code.


---

