os_router and quantum_router_interface

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

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

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

-Dave

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

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

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

-tim

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

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)

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.

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

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. :slight_smile:

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

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

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