Skip to content

Commit 3e4f07a

Browse files
Better GitHub Enterprise Server support
Better GitHub Enterprise Server support
2 parents 243cd3d + cff1c8c commit 3e4f07a

File tree

7 files changed

+59
-17
lines changed

7 files changed

+59
-17
lines changed

.ansible-lint

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
skip_list:
2-
- '106'
1+
skip_list:
2+
- '106'
3+
- ignore-errors

README.md

+11-5
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

+8-3
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

molecule/default/converge.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
- github_repo: ansible-github_actions_runner-testrepo
1010
- github_account: monolithprojects-testorg
1111
- runner_version: "latest"
12+
- service_name: awesome
1213
- runner_labels:
1314
- label1
1415
- repo-runner
1516
roles:
1617
- robertdebock.epel
17-
- ansible-github_actions_runner
18+
- ansible-github_actions_runner

tasks/assert.yml

+11
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

+12-3
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,28 @@
3737
- install
3838
- uninstall
3939

40-
- name: Build service name
40+
- name: Build service name for github.com
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
49+
set_fact:
50+
runner_service: "actions.runner._services.{{ ([( github_owner | default(github_account))[:45], runner_name] | join('.'))[:57] }}.service"
51+
when: runner_on_ghes
52+
tags:
53+
- install
54+
- uninstall
55+
56+
- name: Build service name for GitHub Enterprise Server (Left for backward compatibility. This task will be removed in v1.15)
4957
set_fact:
5058
runner_service: "{{ service_name }}"
5159
when: service_name is defined
5260
tags:
5361
- install
5462
- uninstall
63+
5564
check_mode: false

tasks/collect_info_repo.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,28 @@
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
48+
set_fact:
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
51+
tags:
52+
- install
53+
- uninstall
54+
55+
- name: Build service name for GitHub Enterprise Server (Left for backward compatibility. This task will be removed in v1.15)
4856
set_fact:
4957
runner_service: "{{ service_name }}"
5058
when: service_name is defined
5159
tags:
5260
- install
5361
- uninstall
62+
5463
check_mode: false

0 commit comments

Comments
 (0)