Skip to content

Commit

Permalink
salt, build: Add reactor for certs renewal
Browse files Browse the repository at this point in the history
This reactor will be called when an expired
certificate event will be received.
It will then launch an orchestrate
`orchestrate.certs.renew`, passing the list
of expired certificates, to renew them.

Refs: #1887
  • Loading branch information
alexandre-allard committed Dec 11, 2020
1 parent f93281c commit 3db8c10
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,18 @@ def _get_parts(self) -> Iterator[str]:

Path('salt/metalk8s/service-configuration/deployed/init.sls'),

targets.TemplateFile(
task_name='salt/metalk8s/reactor/certs/renew.sls',
source=constants.ROOT.joinpath(
'salt', 'metalk8s', 'reactor', 'certs', 'renew.sls.in'
),
destination=constants.ISO_ROOT.joinpath(
'salt', 'metalk8s', 'reactor', 'certs', 'renew.sls'
),
context={'VERSION': versions.VERSION},
file_dep=[versions.VERSION_FILE],
),

Path('salt/metalk8s/repo/configured.sls'),
Path('salt/metalk8s/repo/deployed.sls'),
Path('salt/metalk8s/repo/files/apt.sources.list.j2'),
Expand Down
17 changes: 17 additions & 0 deletions salt/metalk8s/reactor/certs/renew.sls.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{%- set target = data["id"] %}
{%- set certificates = data["certificates"] |
map(attribute="cert_path") | list %}

# workaround for https://github.com/saltstack/salt/issues/50827,
# saltenv is not passed to the reactor
{%- set saltenv = "metalk8s-@@VERSION" %}

Renew expired certificates:
runner.state.orchestrate:
- args:
- mods: metalk8s.orchestrate.certs.renew
- saltenv: {{ saltenv }}
- pillar:
orchestrate:
target: {{ target }}
certificates: {{ certificates | json }}

0 comments on commit 3db8c10

Please sign in to comment.