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

Em quarta-feira, 15 de março de 2017 16:09:45 UTC-3, Robson Ramos Barreto 
escreveu:
>
> 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
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/72c05f98-eb5a-4310-88d9-8857db8f89a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to