# os\_network module and changing project names not working

**URL:** <https://forum.ansible.com/t/os-network-module-and-changing-project-names-not-working/20896>\
**Category:** Ansible Project\
**Created:** [March 16, 2016, 10:55pm UTC](https://forum.ansible.com/t/os-network-module-and-changing-project-names-not-working/20896 "2016-03-16T22:55:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Gale](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@Michael\_Gale](https://forum.ansible.com/u/Michael_Gale)\
**Post date:** [March 16, 2016, 10:55pm UTC](https://forum.ansible.com/t/os-network-module-and-changing-project-names-not-working/20896/1 "2016-03-16T22:55:35Z")

</div>

Hello,

I have an ansible playbook that is responsible for creating all of the projects we have defined in our projects.yml file.

This playbook currently:

- creates all of our projects
- adds our admin\_group to the projects

I am trying to use os\_network to create a default private network and subnet under each project, however the network is always created under my admin project space.

I originally had this code:  
–snip–

- name: Creating Project Networks  
os\_network:  
name: “{{ item.1.network.name }}”  
state: “{{ item.0.state }}”  
shared: False  
external: False  
with\_subelements:
- “{{ projects }}”
- networks

–snip–

My credentials are currently set to the default admin account and are loaded via the OS\_ environment variables by sourcing an openrc file. When I execute the above code all the networks and subnets are created under the admin tenant.

I tried using the following with a hardcoded project\_name:  
–snip–

- name: Creating Project Networks  
os\_network:  
auth:  
username: admin  
password: my\_special\_password  
auth\_url: http://\<my\_ip\>:5000/v3  
project\_name: testproject1  
auth\_type: password  
name: “{{ item.1.network.name }}”  
state: “{{ item.0.state }}”  
shared: False  
external: False  
with\_subelements:
- “{{ projects }}”
- networks

–snip–

However the networks are still created under the admin tenant, is it safe to assume that previous os\_\* modules have cached an auth token? Is there a better way to interact with multiple projects when using the os\_\* modules?

Thanks  
Michael

---

<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:** [March 17, 2016, 6:19pm UTC](https://forum.ansible.com/t/os-network-module-and-changing-project-names-not-working/20896/2 "2016-03-17T18:19:09Z")

</div>

What you’re trying to do is not currently supported, but lucky for you,  
a community member has already been working on this:

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

This also requires a new release of the shade library to support the  
new project parameter.

---

<div class="post-metadata">

**Author:** ![Michael\_Gale](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@Michael\_Gale](https://forum.ansible.com/u/Michael_Gale)\
**Post date:** [March 17, 2016, 8:30pm UTC](https://forum.ansible.com/t/os-network-module-and-changing-project-names-not-working/20896/3 "2016-03-17T20:30:58Z")

</div>

Thanks for the info, I am looking forward to that change 🙂

Currently I am making it work via the following method:  
–snip–

- name: Creating Project Networks  
os\_network:  
name: “{{ item.0.name }}\_{{ item.1.network.name }}”  
state: “{{ item.0.state }}”  
shared: False  
external: False  
environment:  
OS\_PROJECT\_NAME: “{{ item.0.name }}”  
OS\_TENANT\_NAME: “{{ item.0.name }}”  
OS\_TENANT\_ID: “”

–snip–

Changing the OS\_ environment vars for this task seem to work, I wouldn’t attempt to try anything complicated with this approach. However it is meeting my needs of adding some defaults to newly created projects.

Michael
