feat: add environment variables
This commit is contained in:
parent
24bc640fc9
commit
f2e3f37201
7 changed files with 48 additions and 0 deletions
|
@ -24,6 +24,12 @@ Install and configure a Gitlab runner
|
||||||
locked: false
|
locked: false
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- `gitlab_runner_env_variables` - dict with environment variables
|
||||||
|
|
||||||
|
```
|
||||||
|
HTTP_PROXY: https://127.0.0.1:3218
|
||||||
|
```
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
gitlab_runner_repository: >
|
gitlab_runner_repository: >
|
||||||
deb https://packages.gitlab.com/runner/gitlab-runner/debian/ {{ ansible_distribution_release }} main
|
deb https://packages.gitlab.com/runner/gitlab-runner/debian/ {{ ansible_distribution_release }} main
|
||||||
gitlab_runner_runners: []
|
gitlab_runner_runners: []
|
||||||
|
gitlab_runner_env_variables: {}
|
||||||
|
|
5
handlers/main.yml
Normal file
5
handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: restart gitlab-runner
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: gitlab-runner
|
||||||
|
state: restarted
|
|
@ -4,6 +4,8 @@
|
||||||
roles:
|
roles:
|
||||||
- ansible-role-gitlab_runner
|
- ansible-role-gitlab_runner
|
||||||
vars:
|
vars:
|
||||||
|
gitlab_runner_env_variables:
|
||||||
|
TEST: toto
|
||||||
gitlab_runner_runners:
|
gitlab_runner_runners:
|
||||||
- name: test
|
- name: test
|
||||||
url: https://gitlab.example.com
|
url: https://gitlab.example.com
|
||||||
|
|
|
@ -4,6 +4,15 @@ def test_packages(host):
|
||||||
package = host.package('gitlab-runner')
|
package = host.package('gitlab-runner')
|
||||||
assert package.is_installed
|
assert package.is_installed
|
||||||
|
|
||||||
|
def test_env_file(host):
|
||||||
|
path = host.file('/etc/systemd/system/gitlab-runner.service.d/ansible.conf')
|
||||||
|
assert path.exists
|
||||||
|
assert path.is_file
|
||||||
|
assert path.user == 'root'
|
||||||
|
assert path.group == 'root'
|
||||||
|
assert path.mode == 0o644
|
||||||
|
assert path.contains('Environment="TEST=toto"')
|
||||||
|
|
||||||
def test_config_file(host):
|
def test_config_file(host):
|
||||||
config = host.file('/etc/gitlab-runner/config.toml')
|
config = host.file('/etc/gitlab-runner/config.toml')
|
||||||
assert config.exists
|
assert config.exists
|
||||||
|
|
|
@ -17,6 +17,25 @@
|
||||||
GITLAB_RUNNER_DISABLE_SKEL: 'true'
|
GITLAB_RUNNER_DISABLE_SKEL: 'true'
|
||||||
tags: gitlab-runner
|
tags: gitlab-runner
|
||||||
|
|
||||||
|
- name: create system directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/systemd/system/gitlab-runner.service.d
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
state: directory
|
||||||
|
tags: gitlab-runner
|
||||||
|
|
||||||
|
- name: add environment variables
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: environment.conf.j2
|
||||||
|
dest: /etc/systemd/system/gitlab-runner.service.d/ansible.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
notify: restart gitlab-runner
|
||||||
|
tags: gitlab-runner
|
||||||
|
|
||||||
- name: register runners
|
- name: register runners
|
||||||
gitlab_runner:
|
gitlab_runner:
|
||||||
name: '{{ item.name }}'
|
name: '{{ item.name }}'
|
||||||
|
|
6
templates/environment.conf.j2
Normal file
6
templates/environment.conf.j2
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
{% for env, value in gitlab_runner_env_variables.items() %}
|
||||||
|
Environment="{{ env }}={{ value }}"
|
||||||
|
{% endfor %}
|
Loading…
Reference in a new issue