Skip to content

Commit 7653f6d

Browse files
authored
Merge pull request #1348 from rackerlabs/automation-accounts
feat: update nautobot/neutron/octavia post deployment jobs to use an automation account
2 parents a395028 + 95eba6c commit 7653f6d

20 files changed

+183
-234
lines changed

ansible/playbooks/keystone_bootstrap.yaml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@
1818
connection: local
1919

2020
pre_tasks:
21-
- name: Fail if ENV variables are not set
22-
ansible.builtin.fail:
23-
msg: "Environment variable {{ item }} is not set. Exiting playbook."
24-
when: lookup('env', item) == ''
25-
loop:
26-
- OS_USERNAME
27-
- OS_DEFAULT_DOMAIN
21+
- name: Check OpenStack connectivity
22+
ansible.builtin.import_tasks: ../tasks/check_openstack_auth.yml
2823

2924
roles:
3025
- role: keystone_bootstrap

ansible/playbooks/openstack_network.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@
1818
connection: local
1919

2020
pre_tasks:
21-
- name: Fail if ENV variables are not set
22-
ansible.builtin.fail:
23-
msg: "Environment variable {{ item }} is not set. Exiting playbook."
24-
when: lookup('env', item) == ''
25-
loop:
26-
- OS_CLOUD
21+
- name: Check OpenStack connectivity
22+
ansible.builtin.import_tasks: ../tasks/check_openstack_auth.yml
2723

2824
roles:
2925
- role: openstack_network

ansible/playbooks/openstack_octavia.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@
1818
connection: local
1919

2020
pre_tasks:
21-
- name: Fail if ENV variables are not set
22-
ansible.builtin.fail:
23-
msg: "Environment variable {{ item }} is not set. Exiting playbook."
24-
when: lookup('env', item) == ''
25-
loop:
26-
- OS_CLOUD
21+
- name: Check OpenStack connectivity
22+
ansible.builtin.import_tasks: ../tasks/check_openstack_auth.yml
2723

2824
roles:
2925
- role: openstack_octavia
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
- name: Authenticate to Keystone
2+
openstack.cloud.auth:
3+
timeout: 20
4+
register: auth
5+
6+
- name: Assert OpenStack authentication succeeded
7+
ansible.builtin.assert:
8+
that:
9+
- auth.auth_token is defined
10+
- auth.auth_token | length > 0
11+
success_msg: "OpenStack authentication successful"
12+
fail_msg: "OpenStack authentication failed."

components/nautobot/values.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ extraObjects:
116116
"helm.sh/hook-weight": "1"
117117
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
118118
spec:
119-
ttlSecondsAfterFinished: 300
120-
# allow the ansible container to run for 20 minutes
121-
activeDeadlineSeconds: 1200
122119
backoffLimit: 1
123120
template:
124121
spec:
@@ -135,10 +132,10 @@ extraObjects:
135132
command: ["ansible-runner", "run", "/runner", "--playbook", "nautobot-initial-setup.yaml"]
136133
resources:
137134
requests:
138-
cpu: "100m"
135+
cpu: "1000m"
139136
memory: "512Mi"
140137
limits:
141-
cpu: "500m"
138+
cpu: "1000m"
142139
memory: "512Mi"
143140
securityContext:
144141
allowPrivilegeEscalation: false

components/neutron/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kind: Kustomization
55
resources:
66
- neutron-mariadb-db.yaml
77
- neutron-rabbitmq-queue.yaml
8-
- neutron-nautobot.yaml
8+
- neutron-post-deployment-job.yaml
99
# less than ideal addition but necessary so that we can have the neutron.conf.d loading
1010
# working due to the way the chart hardcodes the config-file parameter which then
1111
# takes precedence over the directory

components/neutron/neutron-nautobot.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: neutron-post-deployment-job
6+
annotations:
7+
argocd.argoproj.io/hook: PostSync
8+
argocd.argoproj.io/sync-wave: "1"
9+
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation,HookSucceeded
10+
spec:
11+
backoffLimit: 2
12+
template:
13+
spec:
14+
securityContext:
15+
runAsNonRoot: true
16+
runAsUser: 1000
17+
fsGroup: 1000
18+
seccompProfile:
19+
type: RuntimeDefault
20+
containers:
21+
- name: ansible
22+
image: ghcr.io/rackerlabs/understack/ansible:latest
23+
imagePullPolicy: Always
24+
command: ["ansible-runner", "run", "/runner", "--playbook", "openstack_network.yaml"]
25+
resources:
26+
requests:
27+
cpu: "1000m"
28+
memory: "512Mi"
29+
limits:
30+
cpu: "1000m"
31+
memory: "512Mi"
32+
securityContext:
33+
allowPrivilegeEscalation: false
34+
capabilities:
35+
drop:
36+
- ALL
37+
readOnlyRootFilesystem: false
38+
env:
39+
- name: OS_CLOUD
40+
value: understack
41+
volumeMounts:
42+
- name: ansible-inventory
43+
mountPath: /runner/inventory/
44+
- name: ansible-group-vars
45+
mountPath: /runner/inventory/group_vars/
46+
- name: infrasetup
47+
mountPath: /etc/openstack
48+
readOnly: true
49+
volumes:
50+
- name: runner-data
51+
emptyDir: {}
52+
- name: ansible-inventory
53+
configMap:
54+
name: ansible-inventory
55+
- name: ansible-group-vars
56+
configMap:
57+
name: ansible-group-vars
58+
- name: infrasetup
59+
secret:
60+
secretName: infrasetup
61+
items:
62+
- key: clouds.yaml
63+
path: clouds.yaml
64+
restartPolicy: OnFailure

components/octavia/octavia-post-deployment-job.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,38 @@ apiVersion: batch/v1
33
kind: Job
44
metadata:
55
name: octavia-post-deployment-job
6-
generateName: octavia-post-deployment-job-
76
annotations:
87
argocd.argoproj.io/hook: PostSync
9-
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
8+
argocd.argoproj.io/sync-wave: "1"
9+
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation,HookSucceeded
1010
spec:
11+
backoffLimit: 2
1112
template:
1213
spec:
14+
securityContext:
15+
runAsNonRoot: true
16+
runAsUser: 1000
17+
fsGroup: 1000
18+
seccompProfile:
19+
type: RuntimeDefault
1320
containers:
14-
- name: octavia-post-deploy
21+
- name: ansible
1522
image: ghcr.io/rackerlabs/understack/ansible:latest
1623
imagePullPolicy: Always
1724
command: ["ansible-runner", "run", "/runner", "-vvv", "--playbook", "openstack_octavia.yaml"]
25+
resources:
26+
requests:
27+
cpu: "1000m"
28+
memory: "512Mi"
29+
limits:
30+
cpu: "1000m"
31+
memory: "512Mi"
32+
securityContext:
33+
allowPrivilegeEscalation: false
34+
capabilities:
35+
drop:
36+
- ALL
37+
readOnlyRootFilesystem: false
1838
env:
1939
- name: OS_CLOUD
2040
value: understack
@@ -27,7 +47,7 @@ spec:
2747
subPath: inventory.yaml
2848
- name: ansible-group-vars
2949
mountPath: /runner/inventory/group_vars/
30-
- name: openstack-svc-acct
50+
- name: infrasetup
3151
mountPath: /etc/openstack
3252
readOnly: true
3353
volumes:
@@ -42,7 +62,10 @@ spec:
4262
- name: ansible-group-vars
4363
configMap:
4464
name: ansible-group-vars
45-
- name: openstack-svc-acct
65+
- name: infrasetup
4666
secret:
47-
secretName: openstack-svc-acct
67+
secretName: infrasetup
68+
items:
69+
- key: clouds.yaml
70+
path: clouds.yaml
4871
restartPolicy: OnFailure
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
apiVersion: generators.external-secrets.io/v1alpha1
3+
kind: Password
4+
metadata:
5+
name: "infrasetup-{{ .Values.regionName }}"
6+
spec:
7+
length: 32
8+
digits: 6
9+
symbols: 6
10+
---
11+
apiVersion: external-secrets.io/v1
12+
kind: ExternalSecret
13+
metadata:
14+
name: "infrasetup-{{ .Values.regionName }}"
15+
spec:
16+
refreshInterval: 20160m
17+
target:
18+
name: infrasetup
19+
template:
20+
engineVersion: v2
21+
type: Opaque
22+
metadata:
23+
labels:
24+
understack.rackspace.com/keystone-role: infra-readwrite
25+
understack.rackspace.com/keystone-user: "infrasetup-{{ .Values.regionName }}"
26+
data:
27+
password: "{{ `{{ .password }}` }}"
28+
clouds.yaml: |
29+
clouds:
30+
understack:
31+
auth:
32+
auth_url: "{{ .Values.keystoneUrl }}"
33+
user_domain_name: "service"
34+
username: "infrasetup-{{ .Values.regionName }}"
35+
password: "{{ `{{ .password }}` }}"
36+
project_domain_name: "infra"
37+
project_name: "baremetal"
38+
region_name: "{{ .Values.regionName }}"
39+
interface: "public"
40+
identity_api_version: 3
41+
dataFrom:
42+
- sourceRef:
43+
generatorRef:
44+
apiVersion: generators.external-secrets.io/v1alpha1
45+
kind: Password
46+
name: "infrasetup-{{ .Values.regionName }}"

0 commit comments

Comments
 (0)