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

Commit 0616336

Browse files
authored
Merge branch 'Telefonica:master' into update_pdk
2 parents d10715f + deab7a1 commit 0616336

File tree

8 files changed

+174
-91
lines changed

8 files changed

+174
-91
lines changed

.github/workflows/pdk-test-unit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Run pdk test unit
33
on:
44
- push
55
- pull_request
6+
- workflow_dispatch
67

78
jobs:
89
validating:

README.md

Lines changed: 58 additions & 42 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

15-
This module will setup all of the files and configuration needed for GitHub Actions runner to work on any Debian 9 hosts.
17+
This module will setup all of the files and configuration needed for GitHub Actions runner to work on Debian (Stretch and Buster) and CentOS7 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), Debian 10 (buster) 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

data/common.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ github_actions_runner::base_dir_name: '/some_dir/actions-runner'
44
github_actions_runner::package_name: 'actions-runner-linux-x64'
55
github_actions_runner::package_ensure: '2.272.0'
66
github_actions_runner::repository_url: 'https://github.com/actions/runner/releases/download'
7-
github_actions_runner::org_name: 'github_org'
87
github_actions_runner::personal_access_token: 'PAT'
98
github_actions_runner::user: 'root'
109
github_actions_runner::group: 'root'

manifests/init.pp

Lines changed: 18 additions & 15 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
#
@@ -52,23 +55,23 @@
5255
# * no_proxy
5356
# Optional[String], Comma separated list of hosts that should not use a proxy. More information at https://docs.github.com/en/actions/hosting-your-own-runners/using-a-proxy-server-with-self-hosted-runners
5457
#
55-
5658
class github_actions_runner (
5759
Enum['present', 'absent'] $ensure,
5860
Stdlib::Absolutepath $base_dir_name,
59-
String $org_name,
60-
String $personal_access_token,
61-
String $package_name,
62-
String $package_ensure,
63-
String $repository_url,
64-
String $user,
65-
String $group,
66-
Hash[String, Hash] $instances,
67-
String $github_domain,
68-
String $github_api,
69-
Optional[String] $http_proxy = undef,
70-
Optional[String] $https_proxy = undef,
71-
Optional[String] $no_proxy = undef,
61+
String[1] $personal_access_token,
62+
String[1] $package_name,
63+
String[1] $package_ensure,
64+
String[1] $repository_url,
65+
String[1] $user,
66+
String[1] $group,
67+
Hash[String[1], Hash] $instances,
68+
String[1] $github_domain,
69+
String[1] $github_api,
70+
Optional[String[1]] $enterprise_name = undef,
71+
Optional[String[1]] $org_name = undef,
72+
Optional[String[1]] $http_proxy = undef,
73+
Optional[String[1]] $https_proxy = undef,
74+
Optional[String[1]] $no_proxy = undef,
7275
) {
7376

7477
$root_dir = "${github_actions_runner::base_dir_name}-${github_actions_runner::package_ensure}"

manifests/instance.pp

Lines changed: 34 additions & 27 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)
@@ -38,22 +41,22 @@
3841
# * labels
3942
# Optional[Array[String]], A list of costum lables to add to a runner.
4043
#
41-
4244
define github_actions_runner::instance (
43-
Enum['present', 'absent'] $ensure = 'present',
44-
String $org_name = $github_actions_runner::org_name,
45-
String $personal_access_token = $github_actions_runner::personal_access_token,
46-
String $user = $github_actions_runner::user,
47-
String $group = $github_actions_runner::group,
48-
String $hostname = $::facts['hostname'],
49-
String $instance_name = $title,
50-
Optional[String] $http_proxy = $github_actions_runner::http_proxy,
51-
Optional[String] $https_proxy = $github_actions_runner::https_proxy,
52-
Optional[String] $no_proxy = $github_actions_runner::no_proxy,
53-
Optional[Array[String]] $labels = undef,
54-
Optional[String] $repo_name = undef,
55-
String $github_domain = $github_actions_runner::github_domain,
56-
String $github_api = $github_actions_runner::github_api,
45+
Enum['present', 'absent'] $ensure = 'present',
46+
String[1] $personal_access_token = $github_actions_runner::personal_access_token,
47+
String[1] $user = $github_actions_runner::user,
48+
String[1] $group = $github_actions_runner::group,
49+
String[1] $hostname = $::facts['hostname'],
50+
String[1] $instance_name = $title,
51+
String[1] $github_domain = $github_actions_runner::github_domain,
52+
String[1] $github_api = $github_actions_runner::github_api,
53+
Optional[String[1]] $http_proxy = $github_actions_runner::http_proxy,
54+
Optional[String[1]] $https_proxy = $github_actions_runner::https_proxy,
55+
Optional[String[1]] $no_proxy = $github_actions_runner::no_proxy,
56+
Optional[Array[String[1]]] $labels = undef,
57+
Optional[String[1]] $enterprise_name = $github_actions_runner::enterprise_name,
58+
Optional[String[1]] $org_name = $github_actions_runner::org_name,
59+
Optional[String[1]] $repo_name = undef,
5760
) {
5861

5962
if $labels {
@@ -63,18 +66,22 @@
6366
$assured_labels = ''
6467
}
6568

66-
$url = $repo_name ? {
67-
undef => "${github_domain}/${org_name}",
68-
default => "${github_domain}/${org_name}/${repo_name}",
69-
}
70-
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",
69+
if $org_name {
70+
if $repo_name {
71+
$token_url = "${github_api}/repos/${org_name}/${repo_name}/actions/runners/registration-token"
72+
$url = "${github_domain}/${org_name}/${repo_name}"
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",
77+
}
78+
$url = "${github_domain}/${org_name}"
7779
}
80+
} elsif $enterprise_name {
81+
$token_url = "${github_api}/enterprises/${enterprise_name}/actions/runners/registration-token"
82+
$url = "${github_domain}/enterprises/${enterprise_name}"
83+
} else {
84+
fail("Either 'org_name' or 'enterprise_name' is required to create runner instances")
7885
}
7986

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

metadata.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "telefonica-github_actions_runner",
3-
"version": "0.5.0",
3+
"version": "0.6.0",
44
"author": "Shimon Ohayon",
55
"summary": "Module to configure our GitHub Actions runner on Debian hosts",
66
"license": "Apache-2.0",
@@ -26,7 +26,14 @@
2626
{
2727
"operatingsystem": "Debian",
2828
"operatingsystemrelease": [
29-
"9"
29+
"9",
30+
"10"
31+
]
32+
},
33+
{
34+
"operatingsystem": "CentOS",
35+
"operatingsystemrelease": [
36+
"7"
3037
]
3138
},
3239
{

0 commit comments

Comments
 (0)