Skip to content

Commit c96a0be

Browse files
authored
Clarify things around secrets and encryption (#96)
Signed-off-by: Matthias Büchse <[email protected]>
1 parent 8111cbb commit c96a0be

File tree

1 file changed

+48
-13
lines changed

1 file changed

+48
-13
lines changed

dev-docs/operations/operations/zuul-ci-cd-quickstart-user-guide.md

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,15 @@ For this purpose Zuul creates its own public/private key pair for each project.
279279
public key to create secrets. But only Zuul will be able to decrypt these values. To avoid the user
280280
to be responsible for the correct encryption there is an zuul-client tool that will do this for you.
281281

282-
Example:
282+
Example (reading from stdin and writing to stdout):
283283

284284
```bash
285-
zuul-client --zuul-url ZUUL_URL encrypt --tenant TENANT --project ORGANIZATION/PROJECT --infile creds.yaml --outfile clouds.yaml.enc
285+
zuul-client --zuul-url ZUUL_URL encrypt --tenant SCS --project SovereignCloudStack/REPO
286286
```
287287

288-
The content may look like this:
288+
Add `--infile INFILE` or `--outfile OUTFILE` if you prefer to work with files directly.
289+
290+
The output might look like this:
289291

290292
```yaml
291293
- secret:
@@ -307,6 +309,22 @@ The content may look like this:
307309
You may use this content or the file to provide it as a secret. You just have to update the `<name>` and the
308310
`<fieldname>` part.
309311

312+
The secret name has to be unique across all projects. Because of this, we have a naming convention in the
313+
`SovereignCloudStack` organisation that ensures that a secret has a unique name.
314+
315+
Our convention is as follows. There is only one secret per Zuul configuration per project (for exceptions,
316+
see below). This secret always has a name in the form
317+
`SECRET_REPOSITORY_NAME`. For instance, if a secret in the `SovereignCloudStack/k8s-cluster-api-provider`
318+
repository is
319+
to be used, it is given the name `SECRET_K8S_CLUSTER_API_PROVIDER`. The name of the repository is
320+
always written in capital letters. A dash is replaced with an underscore. Any number of values
321+
(`<fieldname>: !encrypted/pkcs1-oaep`) can then be assigned to this one secret.
322+
323+
In certain cases, it can be undesireable to expose all secret information to all jobs in a project.
324+
Then additional secrets may be used, whose names have to be formed by appending an underscore and some
325+
upper-case prefix to the name of the primary secret. For instance, we might use the
326+
name `SECRET_REPOSITORY_NAME_FOOBAR`.
327+
310328
Official documentation:
311329

312330
1. [Secrets documentation](https://zuul-ci.org/docs/zuul/latest/config/secret.html#secret)
@@ -320,30 +338,47 @@ For a basic but working example the following content may be written into a `zuu
320338
# zuul.yaml content
321339
---
322340
- secret:
323-
name: mySecret
341+
name: SECRET_REPOSITORY_NAME
324342
data:
325-
secretValue: !encrypted/pkcs1-oaep
326-
- <ENCYPTED_DATA>
343+
secretValue1: !encrypted/pkcs1-oaep
344+
- <ENCRYPTED_DATA>
345+
secretValue2: !encrypted/pkcs1-oaep
346+
- <ENCRYPTED_DATA>
347+
secretValue3: !encrypted/pkcs1-oaep
348+
- <ENCRYPTED_DATA>
327349
328350
- job:
329351
name: myFirstTestJob
330352
parent: base
331353
secrets:
332-
- name: secretName # The name of the secret that is used within "playbooks/testPlaybook.yaml"
333-
secret: mySecret
354+
- name: secretName # The name of the secret that is used within "playbooks/testPlaybook.yaml"
355+
secret: SECRET_REPOSITORY_NAME
334356
run: playbooks/testPlaybook.yaml
335357
358+
- job:
359+
name: mySecondTestJob
360+
parent: base
361+
run: playbooks/testPlaybookTwo.yaml
362+
336363
- project:
337-
check:
364+
tag:
338365
jobs:
339366
- myFirstTestJob
367+
check:
368+
jobs:
369+
- mySecondTestJob
340370
```
341371

342-
This will run you job `myFirstTestJob` when ever the `check` pipeline is triggered.
343-
Within SCS this pipeline is always triggered if you open, change or reopen a pull request.
344-
The `check` pipeline can also be triggered manually if you write a comment on an already
372+
This will run the job `myFirstTestJob` whenever the `tag` pipeline is triggered, and
373+
`mySecondTestJob` whenever `check` is triggered.
374+
375+
Within SCS the `check` pipeline is always triggered if you open, change or reopen a pull request.
376+
This pipeline can also be triggered manually if you write a comment on an already
345377
existing pull request and place the string `recheck` in it.
346378

379+
Recall that the first test job cannot run on the same pipeline because it uses a secret.
380+
The `tag` pipeline is run whenever a new tag is created.
381+
347382
The path to you playbook is always the full path within the repository. The playbook
348383
contains the tasks you actually want to run on all or a specific subset of nodes.
349384
Example playbook:
@@ -354,5 +389,5 @@ Example playbook:
354389
- hosts: all
355390
tasks:
356391
- debug:
357-
msg: 'Debug print my secrets! {{ secretName.secretValue }}' # do not do this as it will expose your secrets
392+
msg: 'Debug print my secrets! {{ secretName.secretValue1 }}' # do not do this as it will expose your secrets
358393
```

0 commit comments

Comments
 (0)