Skip to content

Commit 90d3f2c

Browse files
authored
Merge pull request #857 from rackerlabs/puc-844-provisioning-network
feat: PUC-844: use ansible to create provisioning network
2 parents c5af433 + 6f63eb4 commit 90d3f2c

File tree

6 files changed

+106
-58
lines changed

6 files changed

+106
-58
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
# Copyright (c) 2025 Rackspace Technology, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
# not use this file except in compliance with the License. You may obtain
6+
# a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations
14+
# under the License.
15+
16+
- name: Openstack Network
17+
hosts: neutron
18+
connection: local
19+
20+
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
27+
28+
roles:
29+
- role: openstack_network
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
3+
- name: Get network info
4+
openstack.cloud.networks_info:
5+
name: "{{ item.network_name }}"
6+
loop: "{{ fabric_wide_layer_3_infrastructure_networks }}"
7+
loop_control:
8+
label: "{{ item.network_name }}"
9+
register: existing_networks
10+
11+
- name: Create network if not exists
12+
openstack.cloud.network:
13+
name: "{{ item.item.network_name }}"
14+
provider_network_type: "{{ item.item.network_type }}"
15+
state: present
16+
when: item.networks | length == 0
17+
loop: "{{ existing_networks.results }}"
18+
loop_control:
19+
label: "{{ item.item.network_name }}"

workflows/openstack/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ resources:
2121
- sensors/sensor-neutron-event-network-segment-range.yaml
2222
- sensors/sensor-ironic-reclean.yaml
2323
- secrets/nautobot-token.yaml
24+
- secrets/openstack-svc-acct.yaml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: external-secrets.io/v1beta1
2+
kind: ExternalSecret
3+
metadata:
4+
name: openstack-svc-acct
5+
spec:
6+
refreshInterval: 1h
7+
secretStoreRef:
8+
kind: ClusterSecretStore
9+
name: openstack
10+
target:
11+
name: openstack-svc-acct
12+
template:
13+
engineVersion: v2
14+
data:
15+
clouds.yaml: |
16+
clouds:
17+
understack:
18+
auth_url: http://keystone-api.openstack.svc.cluster.local:5000/v3
19+
user_domain_name: {{ .user_domain }}
20+
username: {{ .username }}
21+
password: {{ .password }}
22+
project_domain_name: infra
23+
project_name: baremetal
24+
dataFrom:
25+
- extract:
26+
key: svc-acct-argoworkflow
27+
# necessary to avoid argoproj/argo-cd#13004
28+
conversionStrategy: Default
29+
decodingStrategy: None
30+
metadataPolicy: None

workflows/openstack/sensors/sensor-k8s-neutron-deployment.yaml

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,63 +28,31 @@ spec:
2828
template:
2929
spec:
3030
containers:
31-
- name: create-network
32-
image: docker.io/openstackhelm/openstack-client:2024.2
33-
command:
34-
- /bin/bash
35-
- '-c'
36-
- >-
37-
openstack network create --description "${PROVISIONING_NETWORK_DESCRIPTION}" \
38-
--no-share --provider-network-type "${PROVISIONING_NETWORK_TYPE}" \
39-
--provider-physical-network "${PROVISIONING_PHYSICAL_NETWORK}" \
40-
--tag "${PROVISIONING_NETWORK_TAGS}" \
41-
"${PROVISIONING_NETWORK_NAME}"
31+
- name: create-provisioning-network
32+
image: ghcr.io/rackerlabs/understack/ansible:pr-857
33+
imagePullPolicy: Always
34+
command: ["ansible-runner", "run", "/runner", "--playbook", "openstack_network.yaml"]
4235
env:
43-
- name: PROVISIONING_NETWORK_NAME
44-
valueFrom:
45-
configMapKeyRef:
46-
name: provisioning-network-config
47-
key: network_name
48-
- name: PROVISIONING_NETWORK_TYPE
49-
valueFrom:
50-
configMapKeyRef:
51-
name: provisioning-network-config
52-
key: network_type
53-
- name: PROVISIONING_PHYSICAL_NETWORK
54-
valueFrom:
55-
configMapKeyRef:
56-
name: provisioning-network-config
57-
key: physical_network
58-
- name: PROVISIONING_NETWORK_TAGS
59-
valueFrom:
60-
configMapKeyRef:
61-
name: provisioning-network-config
62-
key: tags
63-
- name: PROVISIONING_NETWORK_DESCRIPTION
64-
valueFrom:
65-
configMapKeyRef:
66-
name: provisioning-network-config
67-
key: description
68-
- name: OS_AUTH_URL
69-
value: "http://keystone-api.openstack.svc.cluster.local:5000/v3"
70-
- name: OS_PROJECT_DOMAIN_NAME
71-
value: "infra"
72-
- name: OS_PROJECT_NAME
73-
value: "baremetal"
74-
- name: OS_USER_DOMAIN_NAME
75-
valueFrom:
76-
secretKeyRef:
77-
name: svc-acct-argoworkflow
78-
key: user_domain
79-
- name: OS_USERNAME
80-
valueFrom:
81-
secretKeyRef:
82-
name: svc-acct-argoworkflow
83-
key: username
84-
- name: OS_PASSWORD
85-
valueFrom:
86-
secretKeyRef:
87-
name: svc-acct-argoworkflow
88-
key: password
89-
imagePullPolicy: IfNotPresent
36+
- name: OS_CLOUD
37+
value: understack
38+
volumeMounts:
39+
- name: ansible-inventory
40+
mountPath: /runner/inventory/
41+
- name: ansible-group-vars
42+
mountPath: /runner/inventory/group_vars/
43+
- name: openstack-svc-acct
44+
mountPath: /etc/openstack
45+
readOnly: true
46+
volumes:
47+
- name: runner-data
48+
emptyDir: {}
49+
- name: ansible-inventory
50+
configMap:
51+
name: ansible-inventory
52+
- name: ansible-group-vars
53+
configMap:
54+
name: ansible-group-vars
55+
- name: openstack-svc-acct
56+
secret:
57+
secretName: openstack-svc-acct
9058
restartPolicy: OnFailure

0 commit comments

Comments
 (0)