-
Notifications
You must be signed in to change notification settings - Fork 6
Create external exterwork post deployment #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,4 @@ | |
| - common-osp | ||
| - controlplane | ||
| - dataplane | ||
| - post | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| external_net_name: public | ||
| external_net_cidr: 172.19.0.0/16 | ||
| external_net_gateway: 172.19.0.1 | ||
| external_net_alloc_start: 172.19.100.1 | ||
| external_net_alloc_end: 172.19.254.254 | ||
| external_net_physical_network: datacentre | ||
| external_network_vlan_id: 19 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| - name: Create vlan interface on external interface | ||
| vars: | ||
| vlan_interface: "{{ iface_2 }}.{{ external_network_vlan_id }}" | ||
| shell: | | ||
| ip link add link {{ iface_2 }} name {{ vlan_interface }} type vlan id {{ external_network_vlan_id }} | ||
| ip link set dev {{ iface_2 }} up | ||
| ip link set dev {{ vlan_interface }} up | ||
| ip a a {{ external_net_gateway }}/{{ external_net_cidr.split('/')[1] }} dev {{ vlan_interface }} | ||
| become: true | ||
|
Comment on lines
+2
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major VLAN interface creation is not idempotent. The Suggested fix for idempotency - name: Create vlan interface on external interface
vars:
vlan_interface: "{{ iface_2 }}.{{ external_network_vlan_id }}"
shell: |
+ if ip link show {{ vlan_interface }} >/dev/null 2>&1; then
+ echo "Interface {{ vlan_interface }} already exists, skipping creation"
+ else
+ ip link add link {{ iface_2 }} name {{ vlan_interface }} type vlan id {{ external_network_vlan_id }}
+ fi
- ip link add link {{ iface_2 }} name {{ vlan_interface }} type vlan id {{ external_network_vlan_id }}
ip link set dev {{ iface_2 }} up
ip link set dev {{ vlan_interface }} up
- ip a a {{ external_net_gateway }}/{{ external_net_cidr.split('/')[1] }} dev {{ vlan_interface }}
+ ip addr replace {{ external_net_interface_ip }}/{{ external_net_cidr.split('/')[1] }} dev {{ vlan_interface }}
become: trueNote: Using 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Create external network | ||
| shell: | | ||
| oc rsh -n openstack openstackclient openstack network create \ | ||
| --external \ | ||
| --provider-network-type vlan \ | ||
| --provider-physical-network {{ external_net_physical_network }} \ | ||
| --provider-segment {{ external_network_vlan_id }} \ | ||
| {{ external_net_name }} | ||
|
|
||
| - name: Create external subnet | ||
| shell: | | ||
| oc rsh -n openstack openstackclient openstack subnet create \ | ||
| --network {{ external_net_name }} \ | ||
| --subnet-range {{ external_net_cidr }} \ | ||
| --gateway {{ external_net_gateway }} \ | ||
| --allocation-pool start={{ external_net_alloc_start }},end={{ external_net_alloc_end }} \ | ||
| --no-dhcp \ | ||
| {{ external_net_name }}-subnet | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 9 assigns the gateway IP to the host VLAN interface.
This uses
external_net_gatewayas the interface address, which can conflict with the actual gateway and break routing. Use a dedicated host-side VLAN IP variable instead.Suggested fix
🤖 Prompt for AI Agents