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

Commit bbc6b19

Browse files
committed
Merge branch 'enterprise_support' of github.com:LDaneliukas/puppet-github-actions-runner into enterprise_support
2 parents 9a0e529 + 79f3d35 commit bbc6b19

File tree

5 files changed

+107
-58
lines changed

5 files changed

+107
-58
lines changed

README.md

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,113 @@
22

33
# GitHub Actions Runner
44

5-
Automatic configuration for running GitHub Actions on Debian hosts as a service
5+
Automatic configuration for running GitHub Actions as a service
66

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

89-
## Limitations
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+
```
90105

91-
Tested on Debian 9 stretch hosts only.
92-
full list of operating systems support and requirements are described in `metadata.json` file.
106+
Note, your `personal_access_token` has to contain the `admin:enterprise` permission.
93107

108+
## Limitations
94109

95-
If you don't specify repository name , make sure you `Personal Access Token` is org level admin.
110+
Tested on Debian 9 stretch and CentOS7 hosts.
111+
Full list of operating systems support and requirements are described in `metadata.json` file.
96112

97113
## Development
98114

REFERENCE.md

Lines changed: 15 additions & 1 deletion
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`
@@ -123,7 +129,15 @@ Data type: `String`
123129

124130
actions runner github organization name.
125131

126-
Default value: `github_actions_runner::org_name`
132+
Default value: `undef`
133+
134+
##### `enterprise_name`
135+
136+
Data type: `String`
137+
138+
enterprise name for global runners
139+
140+
Default value: `undef`
127141

128142
##### `personal_access_token`
129143

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: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
# Enum, Determine if to add or remove the resource.
77
#
88
# * org_name
9-
# String, actions runner org name.(Default: Value set by github_actions_runner Class)
9+
# Optional[String], org name for organization level runners. (Default: Value set by github_actions_runner Class)
10+
#
11+
# * enterprise_name
12+
# Optional[String], enterprise name for global runners. (Default: Value set by github_actions_runner Class)
1013
#
1114
# * personal_access_token
1215
# String, GitHub PAT with admin permission on the repositories or the origanization.(Default: Value set by github_actions_runner Class)
@@ -41,19 +44,20 @@
4144

4245
define github_actions_runner::instance (
4346
Enum['present', 'absent'] $ensure = 'present',
44-
String $org_name = $github_actions_runner::org_name,
4547
String $personal_access_token = $github_actions_runner::personal_access_token,
4648
String $user = $github_actions_runner::user,
4749
String $group = $github_actions_runner::group,
4850
String $hostname = $::facts['hostname'],
4951
String $instance_name = $title,
52+
String $github_domain = $github_actions_runner::github_domain,
53+
String $github_api = $github_actions_runner::github_api,
5054
Optional[String] $http_proxy = $github_actions_runner::http_proxy,
5155
Optional[String] $https_proxy = $github_actions_runner::https_proxy,
5256
Optional[String] $no_proxy = $github_actions_runner::no_proxy,
5357
Optional[Array[String]] $labels = undef,
58+
Optional[String] $enterprise_name = $github_actions_runner::enterprise_name,
59+
Optional[String] $org_name = $github_actions_runner::org_name,
5460
Optional[String] $repo_name = undef,
55-
String $github_domain = $github_actions_runner::github_domain,
56-
String $github_api = $github_actions_runner::github_api,
5761
) {
5862

5963
if $labels {
@@ -63,18 +67,23 @@
6367
$assured_labels = ''
6468
}
6569

66-
$url = $repo_name ? {
67-
undef => "${github_domain}/${org_name}",
68-
default => "${github_domain}/${org_name}/${repo_name}",
69-
}
7070

71-
if $repo_name {
72-
$token_url = "${github_api}/repos/${org_name}/${repo_name}/actions/runners/registration-token"
73-
} else {
74-
$token_url = $github_api ? {
75-
'https://api.github.com' => "${github_api}/repos/${org_name}/actions/runners/registration-token",
76-
default => "${github_api}/orgs/${org_name}/actions/runners/registration-token",
71+
if $org_name {
72+
if $repo_name {
73+
$token_url = "${github_api}/repos/${org_name}/${repo_name}/actions/runners/registration-token"
74+
$url = "${github_domain}/${org_name}/${repo_name}"
75+
} else {
76+
$token_url = $github_api ? {
77+
'https://api.github.com' => "${github_api}/repos/${org_name}/actions/runners/registration-token",
78+
default => "${github_api}/orgs/${org_name}/actions/runners/registration-token",
79+
}
80+
$url = "${github_domain}/${org_name}"
7781
}
82+
} elsif $enterprise_name {
83+
$token_url = "${github_api}/enterprises/${enterprise_name}/actions/runners/registration-token"
84+
$url = "${github_domain}/enterprises/${enterprise_name}"
85+
} else {
86+
fail("Either 'org_name' or 'enterprise_name' is required to create runner instances")
7887
}
7988

8089
$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)