Skip to content

Commit b5320ef

Browse files
Building service/runner name for GHES
1 parent 8495c22 commit b5320ef

File tree

5 files changed

+39
-19
lines changed

5 files changed

+39
-19
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Personal Access Token for GitHub account can be created [here](https://github.co
4747
This is a copy from `defaults/main.yml`
4848

4949
```yaml
50+
---
5051
# Runner user - user under which is the local runner service running
5152
runner_user: "{{ lookup('env','USER') }}"
5253

@@ -80,9 +81,6 @@ access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
8081
# Is it the runner for organization or not?
8182
runner_org: no
8283

83-
# Name to assign to this runner in GitHub (System hostname as default)
84-
runner_name: "{{ ansible_hostname }}"
85-
8684
# Labels to apply to the runner
8785
runner_labels: []
8886

@@ -92,7 +90,14 @@ runner_download_repository: "actions/runner"
9290
# Extra arguments to pass to `config.sh`
9391
runner_extra_config_args: ""
9492

93+
# Name to assign to this runner in GitHub (System hostname as default)
94+
runner_name: "{{ ansible_hostname }}"
95+
96+
# Will the runner be deployed on Github Enterprise server?
97+
runner_on_ghes: no
98+
9599
# Custom service name when usign Github Enterprise server
100+
# DEPRECATED: this variable is deprecated in favor of "runner_on_ghes" and will be removed in release 1.15.
96101
# service_name: actions.runner._services.{{ runner_name }}.service
97102

98103
# GitHub Repository user or Organization owner used for Runner registration
@@ -132,7 +137,7 @@ Runner service will be stated and will run under the same user as the Ansible is
132137
- role: monolithprojects.github_actions_runner
133138
```
134139
135-
Same example as above, but runner will be added to an organization.
140+
Same example as above, but runner will be added to an organization and deployed on GitHub Enterprise Server.
136141
137142
```yaml
138143
---
@@ -142,7 +147,8 @@ Same example as above, but runner will be added to an organization.
142147
become: yes
143148
vars:
144149
- github_account: my_awesome_org
145-
- runner_org: true
150+
- runner_org: yes
151+
- runner_on_ghes: yes
146152
roles:
147153
- role: monolithprojects.github_actions_runner
148154
```

defaults/main.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
3232
# Is it the runner for organization or not?
3333
runner_org: no
3434

35-
# Name to assign to this runner in GitHub (System hostname as default)
36-
runner_name: "{{ ansible_hostname }}"
37-
3835
# Labels to apply to the runner
3936
runner_labels: []
4037

@@ -43,7 +40,15 @@ runner_download_repository: "actions/runner"
4340

4441
# Extra arguments to pass to `config.sh`
4542
runner_extra_config_args: ""
43+
44+
# Name to assign to this runner in GitHub (System hostname as default)
45+
runner_name: "{{ ansible_hostname }}"
46+
47+
# Will the runner be deployed on Github Enterprise server?
48+
runner_on_ghes: no
49+
4650
# Custom service name when usign Github Enterprise server
51+
# DEPRECATED: this variable is deprecated in favor of "runner_on_ghes" and will be removed in release 1.15.
4752
# service_name: actions.runner._services.{{ runner_name }}.service
4853

4954
# GitHub Repository user or Organization owner used for Runner registration

tasks/assert.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,14 @@
2929
tags:
3030
- install
3131
- uninstall
32+
33+
- name: GHES service_name deprecation check (RUN ONCE)
34+
assert:
35+
that:
36+
- service_name is not defined
37+
fail_msg: '[DEPRECATION WARNING]: Variable "service_name" will is deprecated and will be removed in release 1.15. Start using "running_on_ghes" boolean variable.'
38+
ignore_errors: yes
39+
run_once: yes
40+
tags:
41+
- install
42+
- uninstall

tasks/collect_info_org.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@
4040
- name: Build service name
4141
set_fact:
4242
runner_service: "actions.runner.{{ ([( github_owner | default(github_account))[:45], runner_name] | join('.'))[:57] }}.service"
43-
when: service_name is not defined
43+
when: not runner_on_ghes
4444
tags:
4545
- install
4646
- uninstall
4747

48-
- name: Build service name
48+
- name: Build service name for GitHub Enterprise Server
4949
set_fact:
50-
runner_service: "{{ service_name }}"
51-
when: service_name is defined
50+
runner_service: "actions.runner._services.{{ ([( github_owner | default(github_account))[:45], runner_name] | join('.'))[:57] }}.service"
51+
when: runner_on_ghes
5252
tags:
5353
- install
5454
- uninstall
55-
check_mode: false

tasks/collect_info_repo.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,18 @@
3636
- install
3737
- uninstall
3838

39-
- name: Build service name
39+
- name: Build service name for github.com
4040
set_fact:
4141
runner_service: "actions.runner.{{ ([([(github_owner | default(github_account)), github_repo ] | join('-'))[:45], runner_name] | join('.'))[:57] }}.service"
42-
when: service_name is not defined
42+
when: not runner_on_ghes
4343
tags:
4444
- install
4545
- uninstall
4646

47-
- name: Build service name
47+
- name: Build service name for GitHub Enterprise Server
4848
set_fact:
49-
runner_service: "{{ service_name }}"
50-
when: service_name is defined
49+
runner_service: "actions.runner._services.{{ ([([(github_owner | default(github_account)), github_repo ] | join('-'))[:45], runner_name] | join('.'))[:57] }}.service"
50+
when: runner_on_ghes
5151
tags:
5252
- install
5353
- uninstall
54-
check_mode: false

0 commit comments

Comments
 (0)