Skip to content

Commit e762c1f

Browse files
authored
Merge pull request #27 from stackhpc/fix/router-workaround
Implement workaround for router name lookup bug
2 parents 926d91c + 1ffec35 commit e762c1f

File tree

2 files changed

+56
-12
lines changed

2 files changed

+56
-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+
ansible.builtin.include_tasks: router_workaround.yml
7890
with_items: "{{ os_networks_routers }}"
7991
when: item.state | default('present') == 'present'
8092

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
auth_type: "{{ os_networks_auth_type }}"
14+
auth: "{{ os_networks_auth }}"
15+
cacert: "{{ os_networks_cacert | default(omit) }}"
16+
cloud: "{{ os_networks_cloud | default(omit) }}"
17+
interface: "{{ os_networks_interface | default(omit, true) }}"
18+
register: _networks_query
19+
20+
- name: Ensure router is registered with neutron
21+
openstack.cloud.router:
22+
auth_type: "{{ os_networks_auth_type }}"
23+
auth: "{{ os_networks_auth }}"
24+
cacert: "{{ os_networks_cacert | default(omit) }}"
25+
cloud: "{{ os_networks_cloud | default(omit) }}"
26+
interface: "{{ os_networks_interface | default(omit, true) }}"
27+
name: "{{ item.name }}"
28+
interfaces: "{{ item.interfaces | default(omit) }}"
29+
network: "{{ _networks_query.networks[0].id }}"
30+
external_fixed_ips: "{{ item.external_fixed_ips | default(omit) }}"
31+
project: "{{ item.project | default(omit) }}"
32+
state: "{{ item.state | default(omit) }}"

0 commit comments

Comments
 (0)