Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit f0bbd1d

Browse files
committed
add enterprise support
1 parent 9c2caa6 commit f0bbd1d

File tree

5 files changed

+82
-46
lines changed

5 files changed

+82
-46
lines changed

README.md

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,92 +7,111 @@ Automatic configuration for running GitHub Actions on Debian hosts as a service
77
#### Table of Contents
88

99
1. [Description](#description)
10+
- [Hiera configuration examples](#hiera-configuration-examples)
11+
- [Github Enterprise examples](#github-enterprise-examples)
1012
2. [Limitations - OS compatibility, etc.](#limitations)
1113
3. [Development - Guide for contributing to the module](#development)
1214

1315
## Description
1416

1517
This module will setup all of the files and configuration needed for GitHub Actions runner to work on any Debian 9 hosts.
1618

17-
### hiera configuration
19+
### hiera configuration examples
1820

19-
This module supports configuration through hiera. The following example
20-
creates repository level Actions runners.
21+
This module supports configuration through hiera.
22+
23+
#### Creating an organization level Actions runner
2124

2225
```yaml
2326
github_actions_runner::ensure: present
2427
github_actions_runner::base_dir_name: '/data/actions-runner'
2528
github_actions_runner::package_name: 'actions-runner-linux-x64'
26-
github_actions_runner::package_ensure: '2.272.0'
29+
github_actions_runner::package_ensure: '2.277.1'
2730
github_actions_runner::repository_url: 'https://github.com/actions/runner/releases/download'
28-
github_actions_runner::org_name: 'github_org'
31+
github_actions_runner::org_name: 'my_github_organization'
2932
github_actions_runner::personal_access_token: 'PAT'
3033
github_actions_runner::user: 'root'
3134
github_actions_runner::group: 'root'
3235
github_actions_runner::instances:
33-
first_instance:
36+
example_org_instance:
3437
labels:
3538
- self-hosted-custom
3639
```
3740
38-
You can also override some of the keys on the instance level
41+
Note, your `personal_access_token` has to contain the `admin:org` permission.
42+
43+
#### Creating an additional repository level Actions runner
3944
```yaml
40-
github_actions_runner::ensure: present
41-
github_actions_runner::base_dir_name: '/data/actions-runner'
42-
github_actions_runner::package_name: 'actions-runner-linux-x64'
43-
github_actions_runner::package_ensure: '2.272.0'
44-
github_actions_runner::repository_url: 'https://github.com/actions/runner/releases/download'
45-
github_actions_runner::org_name: 'github_org'
46-
github_actions_runner::personal_access_token: 'PAT'
47-
github_actions_runner::user: 'root'
48-
github_actions_runner::group: 'root'
4945
github_actions_runner::instances:
50-
first_instance:
46+
example_org_instance:
5147
labels:
5248
- self-hosted-custom1
53-
second_instance:
49+
example_repo_instance:
50+
repo_name: myrepo
51+
labels:
52+
- self-hosted-custom2
53+
```
54+
55+
Note, your `personal_access_token` has to contain the `repo` permission.
56+
57+
#### Instance level overwrites
58+
```yaml
59+
github_actions_runner::instances:
60+
example_org_instance:
5461
ensure: absent
55-
third_instance:
5662
labels:
57-
- self-hosted-custom3
63+
- self-hosted-custom1
64+
example_repo_instance:
65+
org_name: overwritten_orgnization
5866
repo_name: myrepo
59-
org_name: other_org
60-
personal_access_token: other_secret
67+
labels:
68+
- self-hosted-custom2
6169
```
6270

63-
In case you need to set proxy in one instance:
71+
#### Adding a global proxy and overwriting an instance level proxy
6472
```yaml
65-
github_actions_runner::ensure: present
66-
github_actions_runner::base_dir_name: '/data/actions-runner'
67-
github_actions_runner::package_name: 'actions-runner-linux-x64'
68-
github_actions_runner::package_ensure: '2.272.0'
69-
github_actions_runner::repository_url: 'https://github.com/actions/runner/releases/download'
70-
github_actions_runner::org_name: 'github_org'
71-
github_actions_runner::personal_access_token: 'PAT'
72-
github_actions_runner::user: 'root'
73-
github_actions_runner::group: 'root'
73+
github_actions_runner::http_proxy: http://proxy.local
74+
github_actions_runner::https_proxy: http://proxy.local
7475
github_actions_runner::instances:
75-
first_instance:
76-
http_proxy: http://proxy.local
77-
https_proxy: http://proxy.local
76+
example_org_instance:
77+
http_proxy: http://instance_specific_proxy.local
78+
https_proxy: http://instance_specific_proxy.local
7879
no_proxy: example.com
7980
labels:
8081
- self-hosted-custom1
8182
```
8283

83-
In case you are using Github Enterprise Server , you can define these two parameters to specify the correct urls:
84+
### Github Enterprise examples
85+
To use the module with Github Enterprise Server, you have to define these parameters:
8486
```yaml
8587
github_actions_runner::github_domain: "https://git.example.com"
8688
github_actions_runner::github_api: "https://git.example.com/api/v3"
8789
```
8890

91+
In addition to the runner configuration examples above, you can also configure runners
92+
on the enterprise level by setting a value for `enterprise_name`, for example:
93+
```yaml
94+
github_actions_runner::ensure: present
95+
github_actions_runner::base_dir_name: '/data/actions-runner'
96+
github_actions_runner::package_name: 'actions-runner-linux-x64'
97+
github_actions_runner::package_ensure: '2.277.1'
98+
github_actions_runner::repository_url: 'https://github.com/actions/runner/releases/download'
99+
github_actions_runner::enterprise_name: 'enterprise_name'
100+
github_actions_runner::personal_access_token: 'PAT'
101+
github_actions_runner::user: 'root'
102+
github_actions_runner::group: 'root'
103+
github_actions_runner::instances:
104+
```
105+
106+
Note, your `personal_access_token` has to contain the `admin:enterprise` permission.
107+
89108
## Limitations
90109

91110
Tested on Debian 9 stretch hosts only.
92111
full list of operating systems support and requirements are described in `metadata.json` file.
93112

94113

95-
If you don't specify repository name , make sure you `Personal Access Token` is org level admin.
114+
96115

97116
## Development
98117

REFERENCE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ Data type: `String`
3838

3939
actions runner github organization name.
4040

41+
##### `enterprise_name`
42+
43+
Data type: `String`
44+
45+
enterprise name for global runners
46+
4147
##### `hostname`
4248

4349
Data type: `String`

manifests/init.pp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ===========================
33
#
44
# Manages actions_runner service and configuration
5-
# All default Can be view at the `modules/actions_runner/data/common.yaml` file.
5+
# All defaults can be viewed in the `modules/actions_runner/data/common.yaml` file.
66
#
77
# Parameters
88
# ----------
@@ -16,6 +16,9 @@
1616
# * org_name
1717
# String, actions runner org name.
1818
#
19+
# * enterprise_name
20+
# String, enterprise name for global runners
21+
#
1922
# * personal_access_token
2023
# String, GitHub PAT with admin permission on the repositories or the origanization.
2124
#
@@ -56,7 +59,6 @@
5659
class github_actions_runner (
5760
Enum['present', 'absent'] $ensure,
5861
Stdlib::Absolutepath $base_dir_name,
59-
String $org_name,
6062
String $personal_access_token,
6163
String $package_name,
6264
String $package_ensure,
@@ -66,6 +68,8 @@
6668
Hash[String, Hash] $instances,
6769
String $github_domain,
6870
String $github_api,
71+
Optional[String] $enterprise_name = undef,
72+
Optional[String] $org_name = undef,
6973
Optional[String] $http_proxy = undef,
7074
Optional[String] $https_proxy = undef,
7175
Optional[String] $no_proxy = undef,

manifests/instance.pp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
Optional[String] $no_proxy = $github_actions_runner::no_proxy,
5353
Optional[Array[String]] $labels = undef,
5454
Optional[String] $repo_name = undef,
55+
Optional[String] $enterprise_name = $github_actions_runner::enterprise_name,
5556
String $github_domain = $github_actions_runner::github_domain,
5657
String $github_api = $github_actions_runner::github_api,
5758
) {
@@ -63,18 +64,18 @@
6364
$assured_labels = ''
6465
}
6566

66-
$url = $repo_name ? {
67-
undef => "${github_domain}/${org_name}",
68-
default => "${github_domain}/${org_name}/${repo_name}",
69-
}
70-
71-
if $repo_name {
67+
if $enterprise_name {
68+
$token_url = "${github_api}/enterprises/${enterprise_name}/actions/runners/registration-token"
69+
$url = "${github_domain}/enterprises/${enterprise_name}"
70+
} elsif $repo_name {
7271
$token_url = "${github_api}/repos/${org_name}/${repo_name}/actions/runners/registration-token"
73-
} else {
72+
$url = "${github_domain}/${org_name}/${repo_name}"
73+
} else $org_name {
7474
$token_url = $github_api ? {
7575
'https://api.github.com' => "${github_api}/repos/${org_name}/actions/runners/registration-token",
7676
default => "${github_api}/orgs/${org_name}/actions/runners/registration-token",
7777
}
78+
$url = "${github_domain}/${org_name}"
7879
}
7980

8081
$archive_name = "${github_actions_runner::package_name}-${github_actions_runner::package_ensure}.tar.gz"

metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
"9"
3030
]
3131
},
32+
{
33+
"operatingsystem": "CentOS",
34+
"operatingsystemrelease": [
35+
"7"
36+
]
37+
},
3238
{
3339
"operatingsystem": "Ubuntu",
3440
"operatingsystemrelease": [

0 commit comments

Comments
 (0)