Skip to content

Commit

Permalink
clean up post-deploy networking
Browse files Browse the repository at this point in the history
  • Loading branch information
msherman64 committed Jul 11, 2024
1 parent 94202c2 commit 961a6db
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 221 deletions.
1 change: 0 additions & 1 deletion roles/post_ironic/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
- include_tasks: networks.yml
- include_tasks: flavors.yml
- include_tasks: images.yml
- include_tasks: reservations.yml
54 changes: 0 additions & 54 deletions roles/post_ironic/tasks/networks.yml

This file was deleted.

77 changes: 70 additions & 7 deletions roles/post_networking/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,77 @@
---

# all of this section is only needed for backwards compatibility
public_networks: "{{ neutron_networks | selectattr('public', 'defined') | list }}"
# This is added for backwards compatibility
named_public_networks: "{{ neutron_networks | selectattr('name', 'equalto', 'public') | list }}"
all_public_networks: "{{ public_networks + named_public_networks }}"
public_network: "{{ all_public_networks[0] if all_public_networks }}"
public_network_physnet: "{{ all_public_networks[0] if all_public_networks }}"
public_network: "{{ public_network_physnet.public }}"

shared_networks: "{{ neutron_networks | selectattr('sharednet', 'defined') | list }}"
shared_network: "{{ shared_networks[0] if shared_networks }}"
shared_network_physnet: "{{ shared_networks[0] if shared_networks }}"
shared_network: "{{ shared_network_physnet.sharednet }}"

provisioning_networks: "{{ neutron_networks | selectattr('provisioning', 'defined') | list }}"
provisioning_network_physnet: "{{ provisioning_networks[0] if provisioning_networks }}"
provisioning_network: "{{ provisioning_network_physnet.provisioning }}"


# At this point, we've identified candidates for the public and shared networks,
# and their physical networks, in a backwards compatible way.
# We use the dicts below to set default values, as well as once that can be skipped
# if omitted.

post_deploy_networks:
default_public:
name: public
enabled: True
shared: false
external: true
provider_network_type: "{{ public_network.segment_type | default('flat') }}"
provider_segmentation_id: "{{ public_network.segment_id | default(omit) }}"
provider_physical_network: "{{ public_network_physnet.name | default('physnet1') }}"
subnet:
name: public_subnet
cidr: "{{ public_network.cidr }}"
gateway_ip: "{{ public_network.gateway }}"
dhcp: false
allocation_pool_start: "{{ public_network.ip_range_start }}"
allocation_pool_end: "{{ public_network.ip_range_end }}"
default_sharednet:
name: sharednet1
enabled: True
shared: true
external: false
provider_network_type: "{{ shared_network.segment_type | default('vlan') }}"
provider_segmentation_id: "{{ shared_network.segment_id | default(omit) }}"
provider_physical_network: "{{ shared_network_physnet.name | default('physnet1') }}"
subnet:
name: sharednet_subnet
cidr: "{{ shared_network.cidr | default('10.0.0.1/24')}}"
gateway_ip: "{{ shared_network.gateway | default(omit)}}"
dhcp: true
allocation_pool_start: "{{ shared_network.cidr | next_nth_usable(3) }}" # leave room for gw and dhcp
allocation_pool_end: "{{ shared_network.cidr | ipaddr('last_usable') }}"
ironic_provisioning:
name: ironic_provisioning
enabled: "{{ enable_ironic | bool }}"
shared: false
external: false
provider_network_type: "{{ provisioning_network.segment_type | default('vlan') }}"
provider_segmentation_id: "{{ provisioning_network.segment_id | default(omit) }}"
provider_physical_network: "{{ provisioning_network_physnet.name | default('physnet1') }}"
subnet:
name: ironic_provisioning_subnet
dhcp: true
cidr: "{{ provisioning_network.cidr | default('10.51.0.0/24' )}}"
gateway_ip: "{{ provisioning_network.cidr | next_nth_usable(1) }}"
allocation_pool_start: "{{ provisioning_network.cidr | next_nth_usable(3) }}" # leave room for gw and dhcp
allocation_pool_end: "{{ provisioning_network.cidr | ipaddr('last_usable') }}"

default_sharednet_name: sharednet1
default_sharednet_cidr: 10.0.0.1/24

# Default to using the external VIP interface for NAT
corsa_nat_external_interface: "{{ kolla_external_vip_interface }}"
post_deploy_routers:
sharednet_router:
name: sharednet_router
interfaces:
- "{{ post_deploy_networks.default_sharednet.subnet.name }}"
network: "{{ post_deploy_networks.default_public.name }}"
19 changes: 0 additions & 19 deletions roles/post_networking/tasks/corsa_nat.yml

This file was deleted.

61 changes: 55 additions & 6 deletions roles/post_networking/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
---
- name: configure public network and subnet
include_tasks: public.yml
- name: configure shared tenant network(s) and subnet(s)
include_tasks: sharednet.yml
- name: configure corsa nat interface
include_tasks: corsa_nat.yml
- name: Ensuring post-deploy networks exist
with_dict: "{{ post_deploy_networks }}"
vars:
network: "{{ item.value }}"
kolla_toolbox:
module_name: os_network
module_args:
auth: "{{ openstack_auth }}"
project: "{{ keystone_admin_project }}"
name: "{{ network.name }}"
provider_network_type: "{{ network.provider_network_type }}"
provider_segmentation_id: "{{ network.provider_segmentation_id }}"
provider_physical_network: "{{ network.provider_physical_network }}"
external: "{{ network.external }}"
shared: "{{ network.shared }}"
state: present
become: true
run_once: True
when:
- item.value.enabled

- name: Ensuring post-deploy subnets exist
with_dict: "{{ post_deploy_networks }}"
vars:
network: "{{ item.value }}"
subnet: "{{ item.value.subnet }}"
kolla_toolbox:
module_name: os_subnet
module_args:
auth: "{{ openstack_auth }}"
project: "{{ keystone_admin_project }}"
network_name: "{{ network.name }}"
name: "{{ subnet.name }}"
cidr: "{{ subnet.cidr }}"
gateway_ip: "{{ subnet.gateway_ip | default(omit) }}"
enable_dhcp: "{{ subnet.dhcp }}"
allocation_pool_start: "{{ subnet.allocation_pool_start }}"
allocation_pool_end: "{{ subnet.allocation_pool_end }}"
become: true
run_once: True
when:
- item.value.enabled

- name: Create NAT router for shared network(s).
kolla_toolbox:
module_name: os_router
module_args:
auth: "{{ openstack_auth }}"
project: "{{ keystone_admin_project }}"
name: "{{ item.value.name }}"
interfaces: "{{ item.value.interfaces }}"
network: "{{ item.value.network }}"
become: true
run_once: True
with_dict: "{{ post_deploy_routers }}"
64 changes: 0 additions & 64 deletions roles/post_networking/tasks/public.yml

This file was deleted.

70 changes: 0 additions & 70 deletions roles/post_networking/tasks/sharednet.yml

This file was deleted.

0 comments on commit 961a6db

Please sign in to comment.