# os\_router and quantum\_router\_interface

**URL:** <https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449>\
**Category:** Ansible Developer\
**Created:** [October 7, 2015, 1:51am UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449 "2015-10-07T01:51:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim1](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@Tim1](https://forum.ansible.com/u/Tim1)\
**Post date:** [October 7, 2015, 1:51am UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/1 "2015-10-07T01:51:02Z")

</div>

I’m trying to mirror the functionality found in quantum\_router\_interface with that supplied in os\_router and am not having success.

When I create the router with os\_router with these tasks

- name: Create a network  
os\_network:  
name: “{{ solution\_name }}-mgmt-network”  
state: “present”

- name: Create a subnet  
os\_subnet:  
state: “present”  
network\_name: “{{ solution\_name }}-mgmt-network”  
name: “{{ solution\_name }}-mgmt-subnet”  
cidr: “192.168.0.0/24”  
dns\_nameservers:

- “172.27.1.1”

- “172.27.2.1”  
allocation\_pool\_start: “192.168.0.10”  
allocation\_pool\_end: “192.168.0.100”  
enable\_dhcp: “true”  
ip\_version: “4”

- name: Create a router  
os\_router:  
state: “present”  
name: “{{ solution\_name }}-router”  
network: “ext\_net”  
interfaces:

- subnet: “{{ solution\_name }}-mgmt-subnet”

However, the result is that no subnet is attached to that internal interface.

Am I going about this wrong? The module appears to iterate over the interfaces list assigning their values to ext\_fixed\_ips which. That would mean that I can only add external gateway information but not internal interfaces? Any help would be appreciated.

Thanks,  
tim

---

<div class="post-metadata">

**Author:** ![David\_Shrewsbury1](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@David\_Shrewsbury1](https://forum.ansible.com/u/David_Shrewsbury1)\
**Post date:** [October 7, 2015, 4:46pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/2 "2015-10-07T16:46:26Z")

</div>

Hi Tim!

Sorry you’re having issues. A couple of questions:

1. Are there any error messages? (Use the -vvv option when running the playbook)
2. What version of shade do you have installed? You need a version greater than 0.13.0.

Also, make sure you have the version of os\_network that was merged with  
this PR: [https://github.com/ansible/ansible-modules-core/pull/2158](https://github.com/ansible/ansible-modules-core/pull/2158)

Having that external bit on (external=True) when creating the network helps when  
creating a router that uses it as a gateway.

-Dave

---

<div class="post-metadata">

**Author:** ![Tim1](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@Tim1](https://forum.ansible.com/u/Tim1)\
**Post date:** [October 7, 2015, 5:12pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/3 "2015-10-07T17:12:54Z")

</div>

Hey David,

The external argument might be what I am missing. I see jimi merged it, but I’m cloning the ansible tree with the submodules showing up here

[https://github.com/ansible/ansible/tree/devel/lib/ansible/modules](https://github.com/ansible/ansible/tree/devel/lib/ansible/modules)

And I dont see that patch in the core link. Let me try the module itself and see if I have better luck. Using shade 0.15.0

Thanks!  
tim

---

<div class="post-metadata">

**Author:** ![Tim1](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@Tim1](https://forum.ansible.com/u/Tim1)\
**Post date:** [October 7, 2015, 5:15pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/4 "2015-10-07T17:15:02Z")

</div>

Correction. I was looking at the wrong module. You said os\_network. Lemme try setting external there and try again.

-tim

---

<div class="post-metadata">

**Author:** ![Tim1](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@Tim1](https://forum.ansible.com/u/Tim1)\
**Post date:** [October 7, 2015, 5:41pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/5 "2015-10-07T17:41:06Z")

</div>

Ok, more information.

I mentioned shad 0.15.0 previously. No errors that I can see, I get this output.

changed: [localhost] =\> {“changed”: true, “router”: {“admin\_state\_up”: true, “external\_gateway\_info”: {“external\_fixed\_ips”: [{“ip\_address”: “10.144.73.120”, “subnet\_id”: “5a856131-36e3-4257-a618-96e0167c5fb3”}], “network\_id”: “df370e23-9efb-4422-b39d-819d927dd480”}, “id”: “6e1968a6-a1b7-42c5-a6bf-17eb219de9cd”, “name”: “dteam-cs-router”, “routes”: , “status”: “ACTIVE”, “tenant\_id”: “e761df322b8b4114b3d021964ab2ef04”}}

Which brings me to another point, I don’t have an enable\_snat key in the output of external\_gateway\_info (even though the module sets it to true) so this line

[https://github.com/ansible/ansible-modules-core/blob/devel/cloud/openstack/os\_router.py#L158](https://github.com/ansible/ansible-modules-core/blob/devel/cloud/openstack/os_router.py#L158)

raises a KeyError exception. :-/

Anyways, the networks that I am creating in the play above are all internal networks. I’m using an existing external network called “ext\_net” to hook the router’s external interface to. I need to hook the routers internal interface to the mgmt-network/subnet (need an orange line to the router in the attached image).

Previously in quantum\_router\_interface I could get away with that via this task

- name: Add router internal interface  
quantum\_router\_interface:  
state: “present”  
router\_name: “{{ solution\_name }}-router”  
subnet\_name: “{{ solution\_name }}-mgmt-subnet”

With os\_router though, when I specify the same subnets like this

- name: Create a router  
os\_router:  
state: “present”  
name: “{{ solution\_name }}-router”  
network: “ext\_net”  
interfaces:
- subnet: “{{ solution\_name }}-mgmt-subnet”

I get the behavior seen in the image. If I go back to quantum\_router\_interface, it correctly attaches the subnet and creates the orange line.

Hope that clarifies things. I’m interested in attaching internal networks to the router. External networks seem to be working fine in my case.

Thanks David!  
-tim

> **(attachments)**
>
> ![Screen Shot 2015-10-07 at 10.32.19 AM.png](https://us1.discourse-cdn.com/ansible/original/2X/5/598b3a2e87c3536a05e995b4f004c5204b306a10.png)

---

<div class="post-metadata">

**Author:** ![David\_Shrewsbury1](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@David\_Shrewsbury1](https://forum.ansible.com/u/David_Shrewsbury1)\
**Post date:** [October 7, 2015, 7:26pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/6 "2015-10-07T19:26:29Z")

</div>

Ok, I think I see the issue.

We’ll need to put in a bug fix to shade, and also to the os\_router module. Should be  
able to do that soon-ish. Thanks for pointing this out.

---

<div class="post-metadata">

**Author:** ![Tim1](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@Tim1](https://forum.ansible.com/u/Tim1)\
**Post date:** [October 7, 2015, 8:23pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/7 "2015-10-07T20:23:51Z")

</div>

Hey David,

One more question just for my own understanding. Should shade and the os\_\* modules work on both Juno and Kilo? Just curious how far back shade and the modules would be expected to work.

Thanks,  
tim

---

<div class="post-metadata">

**Author:** ![David\_Shrewsbury1](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@David\_Shrewsbury1](https://forum.ansible.com/u/David_Shrewsbury1)\
**Post date:** [October 8, 2015, 8:54pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/8 "2015-10-08T20:54:07Z")

</div>

They should, though it’s not something we specifically test. We try to test them across several providers, many of whom are running older versions. It would take a major API break across releases for something to not work. OpenStack _tries_ not to do that. 🙂

---

<div class="post-metadata">

**Author:** ![David\_Shrewsbury1](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@David\_Shrewsbury1](https://forum.ansible.com/u/David_Shrewsbury1)\
**Post date:** [October 19, 2015, 8:06pm UTC](https://forum.ansible.com/t/os-router-and-quantum-router-interface/19449/9 "2015-10-19T20:06:05Z")

</div>

Hi Tim,

If you don’t mind, and you have time, I’d love to have you test the potential fix for this:

[https://github.com/ansible/ansible-modules-core/pull/2310](https://github.com/ansible/ansible-modules-core/pull/2310)

It will require you to download and install the latest version of shade from source (unless we release 1.0 by then).

[https://github.com/openstack-infra/shade](https://github.com/openstack-infra/shade)

I’m only able to test so much and would love an additional pair of eyes on it. Feel free to comment on the PR.

-Dave
