Skip to content
Draft
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
30 changes: 29 additions & 1 deletion roles/os_networks/tasks/networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@
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) }}"
with_items: "{{ os_address_scopes }}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The variable os_address_scopes is not defined in the role's defaults. If it's not provided by the user, this task will fail. To make it optional and prevent errors, please provide a default value. This will make the role more robust by simply skipping the loop if the variable is not defined.

  with_items: "{{ os_address_scopes | default([]) }}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loop: instead of with_items:


- 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 }}"
address_scope: "{{ item.address_scope }}"
with_items: "{{ os_subnet_pools }}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to os_address_scopes, the variable os_subnet_pools is not defined in the role's defaults. This will cause the task to fail if the variable is not set. Please provide a default value to make it optional and avoid potential playbook failures.

  with_items: "{{ os_subnet_pools | default([]) }}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


- name: Ensure subnet is registered with neutron
openstack.cloud.subnet:
auth_type: "{{ os_networks_auth_type }}"
Expand All @@ -45,6 +72,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 All @@ -60,7 +88,7 @@
ipv6_address_mode: "{{ item.1.ipv6_address_mode | default(omit) }}"
ipv6_ra_mode: "{{ item.1.ipv6_ra_mode | default(omit) }}"
use_default_subnetpool: "{{ item.1.use_default_subnetpool | default(omit) }}"
subnetpool: "{{ item.1.subnetpool | default(omit) }}"
subnet_pool: "{{ item.1.subnet_pool | default(omit) }}"
project: "{{ item.1.project | default(omit) }}"
state: "{{ item.1.state | default(omit) }}"
with_subelements:
Expand Down
1 change: 1 addition & 0 deletions roles/os_networks/tasks/router_workaround.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
interfaces: "{{ item.interfaces | default(omit) }}"
network: "{{ _networks_query.networks[0].id if _networks_query is not skipped else omit }}"
external_fixed_ips: "{{ item.external_fixed_ips | default(omit) }}"
enable_snat: "{{ item.enable_snat | default(omit) }}"
project: "{{ item.project | default(omit) }}"
state: "{{ item.state | default(omit) }}"
Loading