Skip to content

Commit f338575

Browse files
authored
chore: replace references pointing to npalm/ by cattle-ops/ (#798)
## Description This PR removes all references pointing at `npalm/` resources with `cattle-ops/` as the repository was moved some time ago and everything should point to the new destination.
1 parent b9973b4 commit f338575

File tree

21 files changed

+293
-279
lines changed

21 files changed

+293
-279
lines changed

.cspell.json

+16-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"awscli",
1010
"backports",
1111
"blockquotes",
12+
"boto",
13+
"botocore",
1214
"certdir",
1315
"checkmarx",
1416
"codeowners",
@@ -19,28 +21,41 @@
1921
"endfor",
2022
"formatlist",
2123
"gitter",
24+
"godotenv",
25+
"golangci",
26+
"gruntwork",
2227
"instancelifecycle",
2328
"kics",
29+
"joho",
2430
"jsonencode",
2531
"markdownlint",
32+
"mypy",
2633
"Niek",
2734
"noexec",
35+
"nolint",
2836
"npalm",
2937
"oxsecurity",
38+
"pylint",
39+
"pylintrc",
40+
"pyright",
3041
"shuf",
3142
"signoff",
3243
"signum",
44+
"stretchr",
3345
"substr",
3446
"templatefile",
3547
"terrascan",
48+
"terratest",
3649
"tfenv",
3750
"tflint",
3851
"tftpl",
3952
"tfsec",
4053
"tfvars",
4154
"tmpfs",
4255
"trivy",
43-
"userdata"
56+
"typecheck",
57+
"userdata",
58+
"xanzy"
4459
],
4560
"flagWords": []
4661
}

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 132

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ jobs:
9191
APPLY_FIXES: all
9292
APPLY_FIXES_EVENT: pull_request
9393
APPLY_FIXES_MODE: commit
94-
9594
# Upload MegaLinter artifacts
9695
- name: Archive production artifacts
9796
if: ${{ success() }} || ${{ failure() }}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ builds/
3737
.vscode/
3838

3939
# Python
40+
.mypy_cache/
4041
venv/
4142

4243
# Terraform rendered templates
43-
debug/
44+
debug/

.mega-linter.yml

+12
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@ DISABLE_LINTERS:
1212
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
1313
# CSpell does a great job. No need for a second linter.
1414
- SPELL_MISSPELL
15+
# DevSkim as it has issues ignoring files/directories, e.g. .mypy_cache
16+
- REPOSITORY_DEVSKIM
17+
18+
PYTHON_PYLINT_PRE_COMMANDS:
19+
# find all Python requirements and install them
20+
- command: find . -name requirements.txt -exec pip install -r {} \;
21+
cwd: root
22+
23+
PYTHON_PYRIGHT_PRE_COMMANDS:
24+
# find all Python requirements and install them
25+
- command: find . -name requirements.txt -exec pip install -r {} \;
26+
cwd: root

.pylintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MASTER]
2+
init-hook="import sys; sys.path.insert(0, '/usr/local/lib/python3.11/site-packages/')"
3+
4+
[FORMAT]
5+
max-line-length=132

.ruff.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
line-length = 132

README.md

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- First line should be a H1: Badges on top please! -->
2+
<!-- markdownlint-disable MD041 -->
13
[![Terraform registry](https://img.shields.io/github/v/release/cattle-ops/terraform-aws-gitlab-runner?label=Terraform%20Registry)](https://registry.terraform.io/modules/cattle-ops/gitlab-runner/aws/)
24
[![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
35
[![Actions](https://github.com/cattle-ops/terraform-aws-gitlab-runner/workflows/CI/badge.svg)](https://github.com/cattle-ops/terraform-aws-gitlab-runner/actions)
@@ -24,7 +26,7 @@ The original setup of the module is based on the blog post: [Auto scale GitLab C
2426

2527
> 💥 BREAKING CHANGE: Due to various problems of the GitLab docker+machine driver (especially with spot instances),
2628
> the driver is switched to the version provided by [CKI](https://gitlab.com/cki-project/docker-machine).
27-
> For more details see [PR](https://github.com/npalm/terraform-aws-gitlab-runner/pull/697).
29+
> For more details see [PR](https://github.com/cattle-ops/terraform-aws-gitlab-runner/pull/697).
2830
<!-- there is no blank line in between. These are two separate quotes! -->
2931
<!-- markdownlint-disable MD028 -->
3032
> 🚚 CHANGE AHEAD: We have decided to move this repository to a dedicated org soon. No user impact expected, current
@@ -60,22 +62,22 @@ In this scenario the runner agent is running on a single EC2 node and runners ar
6062
using spot instances. Runners will scale automatically based on the configuration. The module creates a S3 cache by default,
6163
which is shared across runners (spot instances).
6264

63-
![runners-default](https://github.com/npalm/assets/raw/main/images/terraform-aws-gitlab-runner/runner-default.png)
65+
![runners-default](https://github.com/cattle-ops/terraform-aws-gitlab-runner/raw/main/assets/images/runner-default.png)
6466

6567
### GitLab CI docker-machine runner - multiple runner agents
6668

6769
In this scenario the multiple runner agents can be created with different configuration by instantiating the module multiple times.
6870
Runners will scale automatically based on the configuration. The S3 cache can be shared across runners by managing the cache
6971
outside of the module.
7072

71-
![runners-cache](https://github.com/npalm/assets/raw/main/images/terraform-aws-gitlab-runner/runner-cache.png)
73+
![runners-cache](https://github.com/cattle-ops/terraform-aws-gitlab-runner/raw/main/assets/images/runner-cache.png)
7274

7375
### GitLab Ci docker runner
7476

7577
In this scenario _not_ docker machine is used but docker to schedule the builds. Builds will run on the same EC2 instance as the
7678
agent. No auto scaling is supported.
7779

78-
![runners-docker](https://github.com/npalm/assets/raw/main/images/terraform-aws-gitlab-runner/runner-docker.png)
80+
![runners-docker](https://github.com/cattle-ops/terraform-aws-gitlab-runner/raw/main/assets/images/runner-docker.png)
7981

8082
## Prerequisites
8183

@@ -136,7 +138,7 @@ resource "aws_iam_service_linked_role" "autoscaling" {
136138

137139
If a KMS key is set via `kms_key_id`, make sure that you also give proper access to the key. Otherwise, you might
138140
get errors, e.g. the build cache can't be decrypted or logging via CloudWatch is not possible. For a CloudWatch
139-
example checkout [kms-policy.json](https://github.com/npalm/terraform-aws-gitlab-runner/blob/main/policies/kms-policy.json)
141+
example checkout [kms-policy.json](https://github.com/cattle-ops/terraform-aws-gitlab-runner/blob/main/policies/kms-policy.json)
140142

141143
### GitLab runner token configuration
142144

@@ -233,8 +235,8 @@ policy on the bucket.
233235

234236
Creation of the bucket can be disabled and managed outside this module. A good use case is for sharing the cache across multiple
235237
runners. For this purpose the cache is implemented as a sub module. For more details see the
236-
[cache module](https://github.com/npalm/terraform-aws-gitlab-runner/tree/main/modules/cache). An example implementation of this use
237-
case can be found in the [runner-public](https://github.com/npalm/terraform-aws-gitlab-runner/tree/main/examples/runner-public)
238+
[cache module](https://github.com/cattle-ops/terraform-aws-gitlab-runner/tree/main/modules/cache). An example implementation of
239+
this use case can be found in the [runner-public](https://github.com/cattle-ops/terraform-aws-gitlab-runner/tree/main/examples/runner-public)
238240
example.
239241

240242
In case you enable the access logging for the S3 cache bucket, you have to add the following statement to your S3 logging bucket
@@ -286,12 +288,12 @@ AMI. Setting the filter to `amzn2-ami-hvm-2.0.20200207.1-x86_64-ebs` will allow
286288

287289
### Scenario: Basic usage
288290

289-
Below is a basic examples of usages of the module. Regarding the dependencies such as a VPC, have a look at the [default example](https://github.com/npalm/terraform-aws-gitlab-runner/tree/main/examples/runner-default).
291+
Below is a basic examples of usages of the module. Regarding the dependencies such as a VPC, have a look at the [default example](https://github.com/cattle-ops/terraform-aws-gitlab-runner/tree/main/examples/runner-default).
290292

291293
```hcl
292294
module "runner" {
293-
# https://registry.terraform.io/modules/npalm/gitlab-runner/aws/
294-
source = "npalm/gitlab-runner/aws"
295+
# https://registry.terraform.io/modules/cattle-ops/gitlab-runner/aws/
296+
source = "cattle-ops/gitlab-runner/aws"
295297
296298
aws_region = "eu-west-1"
297299
environment = "spot-runners"
@@ -339,8 +341,8 @@ map. A simple example for this would be to set _region-specific-prefix_ to the A
339341

340342
```hcl
341343
module "runner" {
342-
# https://registry.terraform.io/modules/npalm/gitlab-runner/aws/
343-
source = "npalm/gitlab-runner/aws"
344+
# https://registry.terraform.io/modules/cattle-ops/gitlab-runner/aws/
345+
source = "cattle-ops/gitlab-runner/aws"
344346
345347
aws_region = "eu-west-1"
346348
environment = "spot-runners"
@@ -371,7 +373,7 @@ module "runner" {
371373

372374
## Examples
373375

374-
A few [examples](https://github.com/npalm/terraform-aws-gitlab-runner/tree/main/examples/) are provided. Use the
376+
A few [examples](https://github.com/cattle-ops/terraform-aws-gitlab-runner/tree/main/examples/) are provided. Use the
375377
following steps to deploy. Ensure your AWS and Terraform environment is set up correctly. All commands below should be
376378
run from the `terraform-aws-gitlab-runner/examples/<example-dir>` directory. Don't forget to remove the runners
377379
manually from your Gitlab instance as soon as your are done.
@@ -413,9 +415,9 @@ This project exists thanks to all the people who contribute.
413415

414416
<!-- this is the only option to integrate the contributors list in the README.md -->
415417
<!-- markdownlint-disable MD033 -->
416-
<a href="https://github.com/npalm/terraform-aws-gitlab-runner/graphs/contributors">
418+
<a href="https://github.com/cattle-ops/terraform-aws-gitlab-runner/graphs/contributors">
417419
<!-- markdownlint-disable MD033 -->
418-
<img src="https://contrib.rocks/image?repo=npalm/terraform-aws-gitlab-runner" />
420+
<img src="https://contrib.rocks/image?repo=cattle-ops/terraform-aws-gitlab-runner" />
419421
</a>
420422

421423
Made with [contributors-img](https://contrib.rocks).

examples/runner-certificates/README.md

+81-71
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,27 @@
22

33
In this scenario the runner agent is running on a single EC2 node.
44

5-
The example is intended to show how the runner can be configured for self-hosted Gitlab environments with certificates signed by a custom CA.
5+
The example is intended to show how the runner can be configured for self-hosted Gitlab environments with certificates
6+
signed by a custom CA.
67

7-
> This currently only works with the `docker` executor. Support for the `docker+machine` executor is not yet implemented. Contributions are welcome.
8+
> This currently only works with the `docker` executor. Support for the `docker+machine` executor is not yet
9+
> implemented. Contributions are welcome.
810
911
## Prerequisites
1012

11-
The terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using `tfenv` please check `.terraform-version` for the tested version.
13+
The terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using `tfenv` please
14+
check `.terraform-version` for the tested version.
1215

1316
Before configuring certificates, it is important to review the [Gitlab documentation](https://docs.gitlab.com/runner/configuration/tls-self-signed.html).
1417

1518
In particular, note the following docker images are involved:
1619

17-
> - The **Runner helper image**, which is used to handle Git, artifacts, and cache operations. In this scenario, the user only needs to make a certificate file available at a specific location (for example, /etc/gitlab-runner/certs/ca.crt), and the Docker container will automatically install it for the user.
18-
19-
> - The **user image**, which is used to run the user script. In this scenario, the user must take ownership regarding how to install a certificate, since this is highly dependent on the image itself, and the Runner has no way of knowing how to install a certificate in each possible scenario.
20+
- The **Runner helper image**, which is used to handle Git, artifacts, and cache operations. In this scenario, the
21+
user only needs to make a certificate file available at a specific location (for example
22+
/etc/gitlab-runner/certs/ca.crt), and the Docker container will automatically install it for the user.
23+
- The **user image**, which is used to run the user script. In this scenario, the user must take ownership regarding
24+
how to install a certificate, since this is highly dependent on the image itself, and the Runner has no way of
25+
knowing how to install a certificate in each possible scenario.
2026

2127
### Certificates for the runner-helper image
2228

@@ -49,72 +55,76 @@ For **user images**, you must:
4955

5056
1. Mount the certificates from the EC2 host into all user images.
5157

52-
The runner module can be configured to do this step. Configure the module like so:
53-
54-
```terraform
55-
module {
56-
# ...
58+
The runner module can be configured to do this step. Configure the module like so:
59+
60+
```terraform
61+
module {
62+
# ...
63+
64+
# Mount EC2 host certs in docker so all user docker images can reference them.
65+
runners_additional_volumes = ["/etc/gitlab-runner/certs/:/etc/gitlab-runner/certs:ro"]
66+
67+
# ...
68+
}
69+
```
70+
71+
2. Trust the certificates from within the user image.
5772
58-
# Mount EC2 host certs in docker so all user docker images can reference them.
59-
runners_additional_volumes = ["/etc/gitlab-runner/certs/:/etc/gitlab-runner/certs:ro"]
73+
Each user image will need to execute commands to copy the certificates into the correct place and trust them.
74+
75+
The below examples some ways to do this, assuming user images with the Ubuntu OS or similar.
76+
For Alpine OS user images, the specific commands may differ.
77+
78+
**Option 1:** Build a custom user image and update your `Dockerfile`:
79+
```docker
80+
FROM python:3 # Some base image
81+
82+
RUN apt-get -y update
83+
RUN apt-get -y upgrade
84+
85+
RUN apt-get install -y ca-certificates
86+
RUN cp /etc/gitlab-runner/certs/* /usr/local/share/ca-certificates/
87+
RUN update-ca-certificates
88+
...
89+
```
90+
91+
**Option 2:** Add a section to each pipeline using `before_script`:
92+
93+
This change would need to be added to every pipeline file which requires certificates.
94+
It could be customized depending on the OS of the pipeline user image.
95+
96+
```yaml
97+
default:
98+
before_script:
99+
# Install certificates into user image
100+
- apt-get install -y ca-certificates
101+
- cp /etc/gitlab-runner/certs/* /usr/local/share/ca-certificates/
102+
- update-ca-certificates
103+
```
104+
105+
**Option 3:** Add the script from Option 2 into `runners_pre_build_script` variable:
106+
107+
This avoids maintaining the script in each pipeline file, but expects that all user images use the same OS.
108+
109+
```terraform
110+
module {
111+
# ...
112+
113+
runners_pre_build_script = <<EOT
114+
'''
115+
apt-get install -y ca-certificates
116+
cp /etc/gitlab-runner/certs/* /usr/local/share/ca-certificates/
117+
update-ca-certificates
118+
'''
119+
EOT
120+
121+
# ...
122+
}
123+
```
60124
61-
# ...
62-
}
63-
```
64-
65-
2. Trust the certificates from within the user image.
66-
67-
Each user image will need to execute commands to copy the certificates into the correct place and trust them.
68-
69-
The below examples some ways to do this, assuming user images with the Ubuntu OS or similar.
70-
For Alpine OS user images, the specific commands may differ.
71-
72-
**Option 1:** Build a custom user image and update your `Dockerfile`:
73-
```docker
74-
FROM python:3 # Some base image
75-
76-
RUN apt-get -y update
77-
RUN apt-get -y upgrade
78-
79-
RUN apt-get install -y ca-certificates
80-
RUN cp /etc/gitlab-runner/certs/* /usr/local/share/ca-certificates/
81-
RUN update-ca-certificates
82-
...
83-
```
84-
85-
**Option 2:** Add a section to each pipeline using `before_script`:
86-
87-
This change would need to be added to every pipeline file which requires certificates.
88-
It could be customised depending on the OS of the pipeline user image.
89-
90-
```yaml
91-
default:
92-
before_script:
93-
# Install certificates into user image
94-
- apt-get install -y ca-certificates
95-
- cp /etc/gitlab-runner/certs/* /usr/local/share/ca-certificates/
96-
- update-ca-certificates
97-
```
98-
99-
**Option 3:** Add the script from Option 2 into `runners_pre_build_script` variable:
100-
101-
This avoids maintaining the script in each pipeline file, but expects that all user images use the same OS.
102-
103-
```terraform
104-
module {
105-
# ...
106-
107-
runners_pre_build_script = <<EOT
108-
'''
109-
apt-get install -y ca-certificates
110-
cp /etc/gitlab-runner/certs/* /usr/local/share/ca-certificates/
111-
update-ca-certificates
112-
'''
113-
EOT
114-
115-
# ...
116-
}
117-
```
125+
<!-- markdownlint-disable -->
126+
<!-- cSpell:disable -->
127+
<!-- markdown-link-check-disable -->
118128
119129
<!-- BEGIN_TF_DOCS -->
120130
## Requirements
@@ -160,4 +170,4 @@ module {
160170
## Outputs
161171
162172
No outputs.
163-
<!-- END_TF_DOCS -->
173+
<!-- END_TF_DOCS -->

0 commit comments

Comments
 (0)