Skip to content

Commit 080d08b

Browse files
committed
Aded setup_ksops role
1 parent b92aca6 commit 080d08b

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

roles/acm/setup_ksops/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# setup_ksops
2+
3+
Installs and sets up the KSOPS Kustomize plugin on the OpenShift GitOps Operator.
4+
5+
## Variables
6+
7+
| Variable | Default | Required | Description
8+
| ---------------- | ------- | -------- | -----------
9+
| sk_age_key | | yes | A literal age generated (age-keygen) key. If kept in a version control service, it's recommeneded to vault-encrypt it.
10+
11+
## Example of age key
12+
13+
```
14+
# created: 2025-04-16T11:28:48Z
15+
# public key: age1j24rsa89nhv86dstnl696pfhxlngktjl5gcvya6y6ykg8t5jkqgsv0ua36
16+
AGE-SECRET-KEY-16NSYF9LSS3QZKLXFEYS5K36FPQC62QLZPNA02H7YWV0SFFVXF2PQNRZPNQ
17+
```
18+
19+
## Usage examples
20+
21+
```
22+
- name: Setup the KSOPS Kustomize plugin
23+
ansible.builtin.include_role:
24+
name: redhatci.ocp.acm.setup_ksops
25+
vars:
26+
sk_age_key: |
27+
# created: 2025-04-16T11:28:48Z
28+
# public key: age1j24rsa89nhv86dstnl696pfhxlngktjl5gcvya6y6ykg8t5jkqgsv0ua36
29+
AGE-SECRET-KEY-16NSYF9LSS3QZKLXFEYS5K36FPQC62QLZPNA02H7YWV0SFFVXF2PQNRZPNQ
30+
```

roles/acm/setup_ksops/tasks/main.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
- name: Verify SOPS age key is set
2+
ansible.builtin.assert:
3+
that:
4+
- sk_age_key | length > 0
5+
6+
- name: Load the SOPS age key into the cluster
7+
kubernetes.core.k8s:
8+
definition:
9+
apiVersion: v1
10+
kind: Secret
11+
type: Opaque
12+
metadata:
13+
name: sops-age
14+
namespace: openshift-gitops
15+
data:
16+
keys.txt: "{{ sk_age_key | b64encode }}"
17+
18+
- name: Patch the OpenShift GitOps ArgoCD resource
19+
kubernetes.core.k8s:
20+
definition:
21+
apiVersion: argoproj.io/v1beta1
22+
kind: ArgoCD
23+
metadata:
24+
name: openshift-gitops
25+
namespace: openshift-gitops
26+
spec:
27+
kustomizeBuildOptions: --enable-alpha-plugins --enable-exec
28+
repo:
29+
env:
30+
- name: XDG_CONFIG_HOME
31+
value: /.config
32+
- name: SOPS_AGE_KEY_FILE
33+
value: /.config/sops/age/keys.txt
34+
volumes:
35+
- name: custom-tools
36+
emptyDir: {}
37+
- name: sops-age
38+
secret:
39+
secretName: sops-age
40+
initContainers:
41+
- name: install-ksops
42+
image: quay.io/viaductoss/ksops:v4.3.3
43+
command: ["/bin/sh", "-c"]
44+
args:
45+
- 'echo "Installing KSOPS..."; cp ksops /custom-tools/; cp $GOPATH/bin/kustomize /custom-tools/; echo "Done.";'
46+
volumeMounts:
47+
- mountPath: /custom-tools
48+
name: custom-tools
49+
volumeMounts:
50+
- mountPath: /usr/local/bin/kustomize
51+
name: custom-tools
52+
subPath: kustomize
53+
- mountPath: /.config/kustomize/plugin/viaduct.ai/v1/ksops/ksops
54+
name: custom-tools
55+
subPath: ksops
56+
- mountPath: /.config/sops/age/keys.txt
57+
name: sops-age
58+
subPath: keys.txt

0 commit comments

Comments
 (0)