# ansible os\_network cannot delete openstack network

**URL:** <https://forum.ansible.com/t/ansible-os-network-cannot-delete-openstack-network/20119>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [January 4, 2016, 5:35pm UTC](https://forum.ansible.com/t/ansible-os-network-cannot-delete-openstack-network/20119 "2016-01-04T17:35:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![R\_Melton](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@R\_Melton](https://forum.ansible.com/u/R_Melton)\
**Post date:** [January 4, 2016, 5:35pm UTC](https://forum.ansible.com/t/ansible-os-network-cannot-delete-openstack-network/20119/1 "2016-01-04T17:35:42Z")

</div>

I am using Ansible version ansible 2.1.0 (devel 0c013f592a) last updated 2015/12/21 14:26:10 (GMT -700)  
I am using Ubuntu on 14.04 on the target system with OpenStack **Kilo** release.  
i am using the Ansible os\_network module which is described here: [http://goo.gl/UhzIWl](http://goo.gl/UhzIWl)

I can create openstack network (using os\_network), subnet and start virtual machine using Ansible os\_ modules.  
I can delete the virtual machine (using os\_server) and subnet using os\_network but when I try to delete the network  
with os\_network, I get ‘service catalog is empty’ error. Here is the task and error message:

- name: remove network  
become: no  
os\_network:  
name: mynetwork  
state: absent  
endpoint\_type: internal  
timeout: 200  
wait: yes  
auth:  
auth\_url: “{{ os\_auth\_url }}”  
project\_domain\_id: “{{ os\_project\_domain\_id }}”  
user\_domain\_id: “{{ os\_user\_domain\_id }}”  
username: “{{ os\_username }}”  
password: “{{ os\_password }}”  
register: mynet\_results

TASK [os\_test : remove network] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [3.0.0.10]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “Error fetching network list: The service catalog is empty.”}

I can create and delete networks using openstack CLI (or Horizon) and it works correctly.  
I have tried various values for the os\_network endpoint\_type and get same error.  
All OpenStack neutron commands work correctly at the command line.  
Any idea **why I cannot delete the OpenStack network** (with os\_network) which I have just created?

thanks,  
Rod

---

<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:** [January 5, 2016, 5:06pm UTC](https://forum.ansible.com/t/ansible-os-network-cannot-delete-openstack-network/20119/2 "2016-01-05T17:06:28Z")

</div>

Hi Rod,

> I am using Ansible version ansible 2.1.0 (devel 0c013f592a) last updated 2015/12/21 14:26:10 (GMT -700)  
> I am using Ubuntu on 14.04 on the target system with OpenStack **Kilo** release.  
> i am using the Ansible os\_network module which is described here: [http://goo.gl/UhzIWl](http://goo.gl/UhzIWl)
> 
> I can create openstack network (using os\_network), subnet and start virtual machine using Ansible os\_ modules.  
> I can delete the virtual machine (using os\_server) and subnet using os\_network but when I try to delete the network  
> with os\_network, I get ‘service catalog is empty’ error. Here is the task and error message:
> 
> - name: remove network  
> become: no  
> os\_network:  
> name: mynetwork  
> state: absent  
> endpoint\_type: internal  
> timeout: 200  
> wait: yes  
> auth:  
> auth\_url: “{{ os\_auth\_url }}”  
> project\_domain\_id: “{{ os\_project\_domain\_id }}”  
> user\_domain\_id: “{{ os\_user\_domain\_id }}”  
> username: “{{ os\_username }}”  
> password: “{{ os\_password }}”  
> register: mynet\_results
> 
> TASK [os\_test : remove network] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> fatal: [3.0.0.10]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “Error fetching network list: The service catalog is empty.”}

That is a REALLY strange error. I honestly cannot imagine a scenario that would cause that.

> I can create and delete networks using openstack CLI (or Horizon) and it works correctly.  
> I have tried various values for the os\_network endpoint\_type and get same error.  
> All OpenStack neutron commands work correctly at the command line.  
> Any idea **why I cannot delete the OpenStack network** (with os\_network) which I have just created?
> 
> thanks,  
> Rod

I have no idea what could cause that problem. Can you provide some more details that might  
help us debug this? Can we see the playbook that reproduces this (this simpler the better)?  
What cloud provider are you using?

-Dave

---

<div class="post-metadata">

**Author:** ![R\_Melton](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@R\_Melton](https://forum.ansible.com/u/R_Melton)\
**Post date:** [January 11, 2016, 8:38pm UTC](https://forum.ansible.com/t/ansible-os-network-cannot-delete-openstack-network/20119/3 "2016-01-11T20:38:12Z")

</div>

My playbook will create an OpenStack (Kilo) compute node and then run a minimal self test on the new compute node. The os\_network error is happening in the ‘os\_test’ role in the playbook. The self test will

1. create neutron network and subnet
2. start new VM instance
3. list running VMs
4. remove/delete the VM  
5.delete the subnet and network

attachments:

1. i set ANSIBLE\_KEEP\_REMOTE\_FILES=1 and the os\_network script was saved on the target. Ihave attached the os\_network script which was generated by ansible. I notice that when I run this script  
manually on the target, it seems to complete correctly and the openstack network is deleted.  
Here is the output when i run the os\_network manually:

./os\_network  
{“invocation”: {“auth\_type”: null, “timeout”: 200, “name”: “mynetwork”, “admin\_state\_up”: true, “verify”: true, “api\_timeout”: null, “state”: “absent”, “auth”: {“username”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”, “password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”, “auth\_url”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”, “user\_domain\_id”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”, “project\_domain\_id”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”}, “cacert”: null, “cert”: null, “endpoint\_type”: “internal”, “external”: false, “key”: null, “availability\_zone”: null, “shared”: false, “wait”: true, “cloud”: null, “region\_name”: null}, “changed”: true}

1. i attached the playbook ‘compute\_playbook.yml’; the error is happening in the ‘os\_test’ role.

2. i attached the main.yml task list for the os\_test role. The error is happening on the ‘remove network task’ within this task list. Just focus on what is happening in this task list and don’t worry about the whole playbook.

If you could help me know why the os\_network script is failing (see red error msg above) to delete  
the network, that would be great.

Thanks,  
Rod

> **(attachments)**
>
> [os\_network](https://forum.ansible.com/uploads/short-url/rj6VhDU8wqQXuFODzbDyZNij9iM) (79.9 KB)  
> [main.yml](https://forum.ansible.com/uploads/short-url/lNwjeRnepJAWkKfeihvP3k2EUls.yml) (4.05 KB)  
> [compute\_playbook.yml](https://forum.ansible.com/uploads/short-url/ev25CscOgOE3paLSaMFFNkFmjY6.yml) (1.34 KB)

---

<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:** [January 25, 2016, 8:27pm UTC](https://forum.ansible.com/t/ansible-os-network-cannot-delete-openstack-network/20119/4 "2016-01-25T20:27:57Z")

</div>

You specify a different endpoint type when deleting the network (internal) for  
some reason. Try removing that. I don’t know what cloud provider you are using  
so I’m not sure how they have their endpoints setup.

Also, have you tried simplifying the issue with a smaller playbook? Try one  
that simply creates a network then immediately deletes it.

---

<div class="post-metadata">

**Author:** ![R\_Melton](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@R\_Melton](https://forum.ansible.com/u/R_Melton)\
**Post date:** [January 28, 2016, 7:44pm UTC](https://forum.ansible.com/t/ansible-os-network-cannot-delete-openstack-network/20119/5 "2016-01-28T19:44:01Z")

</div>

I figured out why the os\_network delete task was failing. I assidentially ommited one line in the credentials (the project name).  
The following os\_network task will correctly delete the nework:

- name: remove network  
become: no  
os\_network:  
name: mynetwork  
state: absent  
timeout: 200  
wait: yes  
auth:  
auth\_url: “{{ os\_auth\_url }}”  
project\_domain\_id: “{{ os\_project\_domain\_id }}”  
user\_domain\_id: “{{ os\_user\_domain\_id }}”  
username: “{{ os\_username }}”  
password: “{{ os\_password }}”  
project\_name: “{{ os\_project\_name }}” \<\< this is the line i left out in my original code  
register: mynet\_results
