Skip to content

Commit 0ed105f

Browse files
author
Scott Davidson
committed
Implement workaround for router name lookup bug
1 parent 926d91c commit 0ed105f

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

roles/os_networks/tasks/networks.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,31 @@
6262
- "{{ os_networks }}"
6363
- subnets
6464

65+
# - name: Ensure router is registered with neutron
66+
# openstack.cloud.router:
67+
# auth_type: "{{ os_networks_auth_type }}"
68+
# auth: "{{ os_networks_auth }}"
69+
# cacert: "{{ os_networks_cacert | default(omit) }}"
70+
# cloud: "{{ os_networks_cloud | default(omit) }}"
71+
# interface: "{{ os_networks_interface | default(omit, true) }}"
72+
# name: "{{ item.name }}"
73+
# interfaces: "{{ item.interfaces | default(omit) }}"
74+
# network: "{{ item.network }}"
75+
# external_fixed_ips: "{{ item.external_fixed_ips | default(omit) }}"
76+
# project: "{{ item.project | default(omit) }}"
77+
# state: "{{ item.state | default(omit) }}"
78+
# loop: "{{ os_networks_routers }}"
79+
# when: item.state | default('present') == 'present'
80+
81+
# Workaround bug https://bugs.launchpad.net/ansible-collections-openstack/+bug/2049658
82+
# by looking up external network information using networks_info and then explicitly
83+
# passing the network ID into the openstack.cloud.router. Remove this workaround and
84+
# uncomment code above when bug is fixed.
85+
6586
- name: Ensure router is registered with neutron
66-
openstack.cloud.router:
67-
auth_type: "{{ os_networks_auth_type }}"
68-
auth: "{{ os_networks_auth }}"
69-
cacert: "{{ os_networks_cacert | default(omit) }}"
70-
cloud: "{{ os_networks_cloud | default(omit) }}"
71-
interface: "{{ os_networks_interface | default(omit, true) }}"
72-
name: "{{ item.name }}"
73-
interfaces: "{{ item.interfaces | default(omit) }}"
74-
network: "{{ item.network | default(omit) }}"
75-
external_fixed_ips: "{{ item.external_fixed_ips | default(omit) }}"
76-
project: "{{ item.project | default(omit) }}"
77-
state: "{{ item.state | default(omit) }}"
87+
# Can't loop over blocks in Ansible so have to
88+
# include separate tasks file instead :(
89+
include_tasks: router_workaround.yml
7890
with_items: "{{ os_networks_routers }}"
7991
when: item.state | default('present') == 'present'
8092

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Workaround bug https://bugs.launchpad.net/ansible-collections-openstack/+bug/2049658
2+
# by looking up external network information using networks_info and then explicitly
3+
# passing the network ID into the openstack.cloud.router's network field.
4+
5+
# NOTE: When the item.network parameter is an ID then we are effectively querying a
6+
# network by ID just to extract it's ID... but since the 'name' field of
7+
# openstack.cloud.networks_info makes no distinction between names and IDs we can't
8+
# really avoid this.
9+
10+
- name: Fetch external network information
11+
openstack.cloud.networks_info:
12+
name: "{{ item.network }}"
13+
register: _networks_query
14+
15+
- name: Ensure router is registered with neutron
16+
openstack.cloud.router:
17+
auth_type: "{{ os_networks_auth_type }}"
18+
auth: "{{ os_networks_auth }}"
19+
cacert: "{{ os_networks_cacert | default(omit) }}"
20+
cloud: "{{ os_networks_cloud | default(omit) }}"
21+
interface: "{{ os_networks_interface | default(omit, true) }}"
22+
name: "{{ item.name }}"
23+
interfaces: "{{ item.interfaces | default(omit) }}"
24+
network: "{{ _networks_query.networks[0].id }}"
25+
external_fixed_ips: "{{ item.external_fixed_ips | default(omit) }}"
26+
project: "{{ item.project | default(omit) }}"
27+
state: "{{ item.state | default(omit) }}"

0 commit comments

Comments
 (0)