Skip to content

Commit 434a704

Browse files
enhancement: general improvements (#2)
* enhancement: moved the runner setup to the modules folder This allows us to import the runner-setup module from other sources. * enhancement: increased necessary versions in order to run the automation * enhancement: flagged gh and hcloud token as sensistive * enhancement: removed outdated file * enhancement: renamed output variables and changed resource reference path * enhancement: added module reference * enhancement: added provider config * docs: update root README.md * docs: update modules README * enhancement: added nodejs version to variables * enhancement: update auto generated modules
1 parent ad00491 commit 434a704

15 files changed

Lines changed: 438 additions & 54 deletions

File tree

README.md

Lines changed: 58 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,6 @@
22

33
This repository provides the functionality to deploy the github actions runner on the hetzner cloud infrastructure. This repository is used to set up the test infrastructure for the fylr application.
44

5-
## Avaiable variables
6-
7-
| Variable | Type | Default value | Description |
8-
|----------|------|---------------|-------------|
9-
| `hcloud_token` | string | "" | Defines the authentication token with which new machines are registered with the [hetzner cloud](https://www.hetzner.com/cloud). |
10-
| `ssh_private_key` | string | "~/.ssh/id_rsa" | Defines the path to the location of the private key. The private key is used together with the public key to connect to the machine. |
11-
| `ssh_public_key` | string | "~/.ssh/id_rsa.pub" | Defines the path to the location of the public key. The public key is used together with the private key to connect to the machine. |
12-
| `ssh_key_name` | string | `admin_ssh_key` | Defines the name for the ssh key added to the hetzner cloud, as defined in ssh_private_key and ssh_public_key. Must be different from hetzner_additional_public_key_ids. |
13-
| `hetzner_machine_type` | string | "cx11" | Sets the machine type to use. |
14-
| `hetzner_machine_os` | string | "debian-10" | Defines the machine operating system to be installed. |
15-
| `hetzner_additional_public_key_ids` | []string | [] | Adds public keys to the server that are already registered with hetzner |
16-
| `hetzner_machine_additional_packages` | string | "" | Defines additional packages that must be installed on the machine. Each package name must be separated by a space ` `. |
17-
| `hetzner_machine_location` | string | nbg1 | Specifies the location of the data center where the machine is to be deployed. |
18-
| `github_actions_runner_count` | number | 1 | Defines the number of runners to be provided. This option is equal to Machines at hetzner. |
19-
| `github_actions_runner_labels` | string | "" | Defines a list of labels used to identify the runners. The list is divided by separating the individual entries with `,`. |
20-
| `github_actions_runner_replace_existing` | bool | false | Specifies whether to replace existing Github action runners with the same name. |
21-
| `github_owner` | string | "" | Defines the organisation name or repository owner. |
22-
| `github_repository_name` | string | "" | Sets the name of the repository. This option is only used if you use self-hosted Github runners at the repository level. |
23-
| `github_authentication_user` | string | | Sets the user used for issuing new registration tokens. Ensure that the user has the appropriate permissions. |
24-
| `github_authentication_token` | string | | Sets the personal access token for the configured user in the variable github_authentication_user. |
25-
| `github_runner_type` | string | "repo" | Defines the github runner type. Available values are: repo, org |
26-
275
## Example terraform.tfvars, which provides the runners at repository level
286

297
```ini
@@ -72,3 +50,61 @@ ssh_key_name="example-bot-ssh-key"
7250

7351
github_runner_type="org"
7452
```
53+
54+
## Requirements
55+
56+
| Name | Version |
57+
|------|---------|
58+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= v1.2.9 |
59+
| <a name="requirement_hcloud"></a> [hcloud](#requirement\_hcloud) | >= 1.35.1 |
60+
61+
## Providers
62+
63+
| Name | Version |
64+
|------|---------|
65+
| <a name="provider_hcloud"></a> [hcloud](#provider\_hcloud) | 1.35.1 |
66+
67+
## Modules
68+
69+
| Name | Source | Version |
70+
|------|--------|---------|
71+
| <a name="module_hetzner_gh_runners"></a> [hetzner\_gh\_runners](#module\_hetzner\_gh\_runners) | ./modules/actions-runner | n/a |
72+
73+
## Resources
74+
75+
| Name | Type |
76+
|------|------|
77+
| [hcloud_ssh_key.admin_ssh_key](https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/ssh_key) | resource |
78+
79+
## Inputs
80+
81+
| Name | Description | Type | Default | Required |
82+
|------|-------------|------|---------|:--------:|
83+
| <a name="input_github_actions_runner_count"></a> [github\_actions\_runner\_count](#input\_github\_actions\_runner\_count) | Defines the number of runners to be provided. This option is equal to Machines at hetzner. | `number` | `1` | no |
84+
| <a name="input_github_actions_runner_labels"></a> [github\_actions\_runner\_labels](#input\_github\_actions\_runner\_labels) | Defines a list of labels used to identify the runners. The list is divided by separating the individual entries with `,`. | `string` | `""` | no |
85+
| <a name="input_github_actions_runner_replace_existing"></a> [github\_actions\_runner\_replace\_existing](#input\_github\_actions\_runner\_replace\_existing) | Specifies whether to replace existing Github action runners with the same name. | `bool` | `false` | no |
86+
| <a name="input_github_authentication_token"></a> [github\_authentication\_token](#input\_github\_authentication\_token) | Sets the personal access token for the configured user in the variable github\_authentication\_user. | `string` | n/a | yes |
87+
| <a name="input_github_authentication_user"></a> [github\_authentication\_user](#input\_github\_authentication\_user) | Sets the user used for issuing new registration tokens. Ensure that the user has the appropriate permissions. | `string` | n/a | yes |
88+
| <a name="input_github_owner"></a> [github\_owner](#input\_github\_owner) | Defines the organisation name or repository owner. | `string` | `""` | no |
89+
| <a name="input_github_repository_name"></a> [github\_repository\_name](#input\_github\_repository\_name) | Sets the name of the repository. This option is only used if you use self-hosted Github runners at the repository level. | `string` | `""` | no |
90+
| <a name="input_github_runner_release"></a> [github\_runner\_release](#input\_github\_runner\_release) | Defines the version of the github runner to be installed. The version must be specified in the format `2.277.1`. | `string` | `"2.298.1"` | no |
91+
| <a name="input_github_runner_type"></a> [github\_runner\_type](#input\_github\_runner\_type) | Defines the github runner type. Available values are: repo, org | `string` | `"repo"` | no |
92+
| <a name="input_hcloud_token"></a> [hcloud\_token](#input\_hcloud\_token) | Hetzner Cloud API token | `string` | n/a | yes |
93+
| <a name="input_hetzner_additional_public_key_ids"></a> [hetzner\_additional\_public\_key\_ids](#input\_hetzner\_additional\_public\_key\_ids) | Adds public keys to the server that are already registered at hetzner | `list(string)` | `[]` | no |
94+
| <a name="input_hetzner_ip_config"></a> [hetzner\_ip\_config](#input\_hetzner\_ip\_config) | Defines the IP configuration for the machine. The IP configuration is used to assign a static IP address to the machine. | <pre>object({<br> ipv4_enabled = bool<br> ipv6_enabled = bool<br> })</pre> | <pre>{<br> "ipv4_enabled": true,<br> "ipv6_enabled": true<br>}</pre> | no |
95+
| <a name="input_hetzner_machine_additional_packages"></a> [hetzner\_machine\_additional\_packages](#input\_hetzner\_machine\_additional\_packages) | Defines additional packages that must be installed on the machine. Each package name must be separated by a space ` `. | `string` | `""` | no |
96+
| <a name="input_hetzner_machine_location"></a> [hetzner\_machine\_location](#input\_hetzner\_machine\_location) | Specifies the location of the data center where the machine is to be deployed. | `string` | `"nbg1"` | no |
97+
| <a name="input_hetzner_machine_os"></a> [hetzner\_machine\_os](#input\_hetzner\_machine\_os) | Defines the machine operating system to be installed. | `string` | `"debian-10"` | no |
98+
| <a name="input_hetzner_machine_type"></a> [hetzner\_machine\_type](#input\_hetzner\_machine\_type) | Sets the machine type to use. | `string` | `"cx11"` | no |
99+
| <a name="input_ssh_key_name"></a> [ssh\_key\_name](#input\_ssh\_key\_name) | Defines the name for the ssh key | `string` | `"admin_ssh_key"` | no |
100+
| <a name="input_ssh_private_key"></a> [ssh\_private\_key](#input\_ssh\_private\_key) | Defines the path to the location of the private key. The private key is used together with the public key to connect to the machine. | `string` | `"~/.ssh/id_rsa"` | no |
101+
| <a name="input_ssh_public_key"></a> [ssh\_public\_key](#input\_ssh\_public\_key) | Public Key to authorized the access to the machines | `string` | `"~/.ssh/id_rsa.pub"` | no |
102+
| <a name="input_ssh_username"></a> [ssh\_username](#input\_ssh\_username) | Username that should be used to connect to the nodes | `string` | `"root"` | no |
103+
104+
## Outputs
105+
106+
| Name | Description |
107+
|------|-------------|
108+
| <a name="output_runner_ipv4_addresses"></a> [runner\_ipv4\_addresses](#output\_runner\_ipv4\_addresses) | n/a |
109+
| <a name="output_runner_ipv6_addresses"></a> [runner\_ipv6\_addresses](#output\_runner\_ipv6\_addresses) | n/a |
110+
| <a name="output_runner_machine_names"></a> [runner\_machine\_names](#output\_runner\_machine\_names) | n/a |

main.tf

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
# Configure the Hetzner Cloud Provider
2-
provider "hcloud" {
3-
token = var.hcloud_token
1+
resource "hcloud_ssh_key" "admin_ssh_key" {
2+
name = var.ssh_key_name
3+
public_key = file(var.ssh_public_key)
4+
}
5+
6+
module "hetzner_gh_runners" {
7+
source = "./modules/actions-runner"
8+
9+
ssh_private_key = file(var.ssh_private_key)
10+
ssh_username = var.ssh_username
11+
ssh_key_name = var.ssh_key_name
12+
hetzner_machine_type = var.hetzner_machine_type
13+
hetzner_machine_os = var.hetzner_machine_os
14+
hetzner_additional_public_key_ids = concat([hcloud_ssh_key.admin_ssh_key.id], var.hetzner_additional_public_key_ids)
15+
hetzner_machine_additional_packages = var.hetzner_machine_additional_packages
16+
hetzner_machine_location = var.hetzner_machine_location
17+
hetzner_ip_config = var.hetzner_ip_config
18+
19+
github_actions_runner_count = var.github_actions_runner_count
20+
github_actions_runner_labels = var.github_actions_runner_labels
21+
github_actions_runner_replace_existing = var.github_actions_runner_replace_existing
22+
github_owner = var.github_owner
23+
github_repository_name = var.github_repository_name
24+
github_authentication_user = var.github_authentication_user
25+
github_authentication_token = var.github_authentication_token
26+
github_runner_type = var.github_runner_type
27+
github_runner_release = var.github_runner_release
428
}

modules/actions-runner/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= v1.2.9 |
6+
| <a name="requirement_hcloud"></a> [hcloud](#requirement\_hcloud) | >= 1.35.1 |
7+
8+
## Providers
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="provider_hcloud"></a> [hcloud](#provider\_hcloud) | 1.35.2 |
13+
| <a name="provider_null"></a> [null](#provider\_null) | 3.1.1 |
14+
| <a name="provider_random"></a> [random](#provider\_random) | 3.4.3 |
15+
16+
## Modules
17+
18+
No modules.
19+
20+
## Resources
21+
22+
| Name | Type |
23+
|------|------|
24+
| [hcloud_server.github_runner](https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs/resources/server) | resource |
25+
| [null_resource.deprovision](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
26+
| [random_string.hetzner_machine](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
27+
28+
## Inputs
29+
30+
| Name | Description | Type | Default | Required |
31+
|------|-------------|------|---------|:--------:|
32+
| <a name="input_github_actions_runner_count"></a> [github\_actions\_runner\_count](#input\_github\_actions\_runner\_count) | Defines the number of runners to be provided. This option is equal to Machines at hetzner. | `number` | `1` | no |
33+
| <a name="input_github_actions_runner_labels"></a> [github\_actions\_runner\_labels](#input\_github\_actions\_runner\_labels) | Defines a list of labels used to identify the runners. The list is divided by separating the individual entries with `,`. | `string` | `""` | no |
34+
| <a name="input_github_actions_runner_replace_existing"></a> [github\_actions\_runner\_replace\_existing](#input\_github\_actions\_runner\_replace\_existing) | Specifies whether to replace existing Github action runners with the same name. | `bool` | `false` | no |
35+
| <a name="input_github_authentication_token"></a> [github\_authentication\_token](#input\_github\_authentication\_token) | Personal access token used to authenticate with Github. The token must have the `admin:org` scope and the necessary permissions to manage runners. | `string` | n/a | yes |
36+
| <a name="input_github_authentication_user"></a> [github\_authentication\_user](#input\_github\_authentication\_user) | Sets the user used for issuing new registration tokens. Ensure that the user has the appropriate permissions. | `string` | n/a | yes |
37+
| <a name="input_github_owner"></a> [github\_owner](#input\_github\_owner) | Defines the organisation name or repository owner. | `string` | `""` | no |
38+
| <a name="input_github_repository_name"></a> [github\_repository\_name](#input\_github\_repository\_name) | Sets the name of the repository. This option is only used if you use self-hosted Github runners at the repository level. | `string` | `""` | no |
39+
| <a name="input_github_runner_release"></a> [github\_runner\_release](#input\_github\_runner\_release) | Defines the version of the github runner to be installed. The version must be specified in the format `2.277.1`. | `string` | `"2.298.1"` | no |
40+
| <a name="input_github_runner_type"></a> [github\_runner\_type](#input\_github\_runner\_type) | Defines the github runner type. Available values are: repo, org | `string` | `"repo"` | no |
41+
| <a name="input_hetzner_additional_public_key_ids"></a> [hetzner\_additional\_public\_key\_ids](#input\_hetzner\_additional\_public\_key\_ids) | Adds public keys to the server that are already registered at hetzner | `list(string)` | `[]` | no |
42+
| <a name="input_hetzner_ip_config"></a> [hetzner\_ip\_config](#input\_hetzner\_ip\_config) | Defines the IP configuration for the machine. The IP configuration is used to assign a static IP address to the machine. | <pre>object({<br> ipv4_enabled = bool<br> ipv6_enabled = bool<br> })</pre> | <pre>{<br> "ipv4_enabled": true,<br> "ipv6_enabled": true<br>}</pre> | no |
43+
| <a name="input_hetzner_machine_additional_packages"></a> [hetzner\_machine\_additional\_packages](#input\_hetzner\_machine\_additional\_packages) | Defines additional packages that must be installed on the machine. Each package name must be separated by a space ` `. | `string` | `""` | no |
44+
| <a name="input_hetzner_machine_location"></a> [hetzner\_machine\_location](#input\_hetzner\_machine\_location) | Specifies the location of the data center where the machine is to be deployed. | `string` | `"nbg1"` | no |
45+
| <a name="input_hetzner_machine_os"></a> [hetzner\_machine\_os](#input\_hetzner\_machine\_os) | Defines the machine operating system to be installed. | `string` | `"debian-10"` | no |
46+
| <a name="input_hetzner_machine_type"></a> [hetzner\_machine\_type](#input\_hetzner\_machine\_type) | Sets the machine type to use. | `string` | `"cx11"` | no |
47+
| <a name="input_nodejs_version"></a> [nodejs\_version](#input\_nodejs\_version) | Defines the version of nodejs to be installed. | `string` | `"14"` | no |
48+
| <a name="input_ssh_key_name"></a> [ssh\_key\_name](#input\_ssh\_key\_name) | Defines the name for the ssh key | `string` | `"admin_ssh_key"` | no |
49+
| <a name="input_ssh_private_key"></a> [ssh\_private\_key](#input\_ssh\_private\_key) | Sets the value of the private key. We expect to find the public key in HCLOUD. | `string` | n/a | yes |
50+
| <a name="input_ssh_username"></a> [ssh\_username](#input\_ssh\_username) | Username that should be used to connect to the nodes | `string` | `"root"` | no |
51+
52+
## Outputs
53+
54+
| Name | Description |
55+
|------|-------------|
56+
| <a name="output_runner_ipv4_addresses"></a> [runner\_ipv4\_addresses](#output\_runner\_ipv4\_addresses) | n/a |
57+
| <a name="output_runner_ipv6_addresses"></a> [runner\_ipv6\_addresses](#output\_runner\_ipv6\_addresses) | n/a |
58+
| <a name="output_runner_machine_names"></a> [runner\_machine\_names](#output\_runner\_machine\_names) | n/a |

0 commit comments

Comments
 (0)