Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion roles/os_networks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ dict containing the following items:
internal interface.
- `network`: Unique name or ID of the external gateway network.
- `external_fixed_ips`: Optional list of IP address parameters for the
external gateway network. Each is a dictionary with the subnet name or
external gateway network. Each is a dictionary with the subnet name or
subnet ID and the IP address to assign on the subnet.
- `project`: Optionally create this router for a project other than the
authenticating project.
Expand Down Expand Up @@ -127,6 +127,21 @@ following items:

*NOTE*: RBAC assignments cannot be modified after they are created.

`os_networks_address_scopes`: List of address scopes to create.
Each item should be a dict containing the following items:
- `name`: Name of the address scope.
- `shared`: Whether the address scope is shared.
- `ip_version`: Optional IP version of the address scope.
- `state`: Optional state of the address scope, default is `present`.

`os_networks_subnet_pools`: List of subnet pools to create.
Each item should be a dict containing the following items:
- `name`: Name of the subnet pool.
- `shared`: Whether the subnet pool is shared.
- `address_scope`: Optional address scope of the subnet pool.
- `prefixes`: List of prefixes of the subnet pool.
- `state`: Optional state of the subnet pool, default is `present`.

Dependencies
------------

Expand Down
19 changes: 19 additions & 0 deletions roles/os_networks/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ os_networks_interface:
# - 'ipv6_ra_mode': Optional IPv6 router advertisement mode for the subnet.
# - 'use_default_subnetpool': Optional boolean, whether to use the default
# subnet pool.
# - 'subnet_pool': Subnet pool name or ID from which to obtain a CIDR.
# - 'prefix_length': Prefix length for subnet allocation from the pool.
# - 'project': Optional project in which to register the subnet.
# - 'state': Optional state of the subnet, default is 'present'.
os_networks: [] # noqa var-naming[no-role-prefix]
Expand Down Expand Up @@ -101,5 +103,22 @@ os_networks_security_groups: []
# in the designated way.
os_networks_rbac: []

# List of address scopes to create.
# Each item should be a dict containing the following items:
# - `name`: Name of the address scope.
# - `shared`: Whether the address scope is shared.
# - `ip_version`: Optional IP version of the address scope.
# - `state`: Optional state of the address scope, default is `present`.
os_networks_address_scopes: []

# List of subnet pools to create.
# Each item should be a dict containing the following items:
# - `name`: Name of the subnet pool.
# - `shared`: Whether the subnet pool is shared.
# - `address_scope`: Optional address scope of the subnet pool.
# - `prefixes`: List of prefixes of the subnet pool.
# - `state`: Optional state of the subnet pool, default is `present`.
os_networks_subnet_pools: []

# Upper constraints file for installation of Python dependencies.
os_networks_upper_constraints_file: https://releases.openstack.org/constraints/upper/2025.1
32 changes: 32 additions & 0 deletions roles/os_networks/tasks/networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,37 @@
port_security_enabled: "{{ item.port_security_enabled | default(omit) }}"
with_items: "{{ os_networks }}"

- name: Ensure address scope is registered with neutron
openstack.cloud.address_scope:
auth_type: "{{ os_networks_auth_type }}"
auth: "{{ os_networks_auth }}"
region_name: "{{ os_networks_region | default(omit) }}"
cacert: "{{ os_networks_cacert | default(omit) }}"
cloud: "{{ os_networks_cloud | default(omit) }}"
interface: "{{ os_networks_interface | default(omit, true) }}"
name: "{{ item.name }}"
shared: "{{ item.shared | default(omit) }}"
ip_version: "{{ item.ip_version | default(omit) }}"
state: "{{ item.state | default(omit) }}"
with_items: "{{ os_networks_address_scopes }}"
when: os_networks_address_scopes | default([]) | length > 0

- name: Ensure subnet pool is registered with neutron
openstack.cloud.subnet_pool:
auth_type: "{{ os_networks_auth_type }}"
auth: "{{ os_networks_auth }}"
region_name: "{{ os_networks_region | default(omit) }}"
cacert: "{{ os_networks_cacert | default(omit) }}"
cloud: "{{ os_networks_cloud | default(omit) }}"
interface: "{{ os_networks_interface | default(omit, true) }}"
name: "{{ item.name }}"
shared: "{{ item.shared | default(omit) }}"
prefixes: "{{ item.prefixes | default(omit) }}"
address_scope: "{{ item.address_scope | default(omit) }}"
state: "{{ item.state | default(omit) }}"
with_items: "{{ os_networks_subnet_pools }}"
when: os_networks_subnet_pools | default([]) | length > 0

- name: Ensure subnet is registered with neutron
openstack.cloud.subnet:
auth_type: "{{ os_networks_auth_type }}"
Expand All @@ -45,6 +76,7 @@
name: "{{ item.1.name }}"
network_name: "{{ item.0.name }}"
cidr: "{{ item.1.cidr | default(omit) }}"
prefix_length: "{{ item.1.prefix_length | default(omit) }}"
dns_nameservers: "{{ item.1.dns_nameservers | default(omit) }}"
enable_dhcp: "{{ item.1.enable_dhcp | default(omit) }}"
extra_specs: "{{ item.1.extra_specs | default(omit) }}"
Expand Down
Loading