Openstack module: Unable to create a router from specific users

29 views
Skip to first unread message

Robson Ramos Barreto

unread,
Mar 15, 2017, 3:09:45 PM3/15/17
to Ansible Project
Hi,

I'm trying create a router from specfic user using auth instead of cloud option and I'm getting the following message error:

TASK [os_router : create a virtual router]
*************************************************************************************************************************************
fatal
:
 
[localhost]: FAILED! => {"changed": false, "failed": true, "msg":
"You are not authorized to perform the requested action: admin_required
(HTTP 403)"
}




However, if I create it from a command line it works properly:

$ neutron --os-auth-url http://controller:5000/v2.0/ --os-tenant-name
demo
--os-username demo --os-password demo router-create teste
Created a new router:
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| admin_state_up        | True                                 |
| external_gateway_info |                                      |
| id                    | 97fb7592-31cb-420e-977b-91a51265a761 |
| name                  | teste                                |
| routes                |                                      |
| status                | ACTIVE                               |
| tenant_id             | 0ebcc72d070e495fa1ad09478bc7b43a     |
+-----------------------+--------------------------------------+



I'm using the following role:

$ cat roles/os_router/tasks/main.yml
---
- name: create a virtual router
  os_router
:
   
#cloud: "{{ os_cloud }}"
    auth
:
      auth_url
: "{{ os_auth_url }}"
      username
: "{{ os_user }}"
      password
: "{{ os_user_password }}"
      project_name
: "{{ os_project }}"
    state
: "{{ os_router_state }}"
    name
: "{{ os_router_name }}"
    project
: "{{ os_project }}"
    network
: "{{ os_network_public }}"
    interfaces
:
     
- "{{ os_subnet_name }}"



I'm using ansible 2.3.0 and shade 1.16.0 version

Thank you



Robson Ramos Barreto

unread,
Mar 16, 2017, 3:18:21 PM3/16/17
to Ansible Project
Hi

I did something like below and it worked as I wanted:

- name: check if router exists
  shell
: neutron --os-username="{{ os_user }}" --os-password="{{ os_user_password }}" --os-tenant-name="{{ os_project }}" --os-auth-url="{{ os_auth_url }}" router-list | awk '/{{ os_router_name }}/' | wc -l
 
register: router

- name: create a router if it does not exist
 
when: router.stdout == "0"
  shell
: |
    neutron
--os-username="{{ os_user }}" --os-password="{{ os_user_password }}" --os-tenant-name="{{ os_project }}" --os-auth-url="{{ os_auth_url }}" router-create "{{ os_router_name }}"
    neutron
--os-username="{{ os_user }}" --os-password="{{ os_user_password }}" --os-tenant-name="{{ os_project }}" --os-auth-url="{{ os_auth_url }}" router-interface-add "{{ os_router_name }}" "{{ os_subnet_name }}"
    neutron
--os-username="{{ os_user }}" --os-password="{{ os_user_password }}" --os-tenant-name="{{ os_project }}" --os-auth-url="{{ os_auth_url }}" router-gateway-set "{{ os_router_name }}" "{{ os_network_public }}"
   
exit 0

Instead, I want to use the standard os_router module to do just like the roles posted before

I do not know if I'm doing something wrong or if there is a bug on the os_router module


Thank you
Reply all
Reply to author
Forward
0 new messages