Module nxos_user not recognizing fails saying role is invalid

29 views
Skip to first unread message

Eliezer Rodriguez

unread,
Feb 8, 2019, 12:39:56 PM2/8/19
to Ansible Project

Hi everybody,

I wrote this playbook to create a new role in Nexus OS and then create a new user to use that role.
The role gets created but when it's time for the second task to create the role it fails with a non-existent role error.

---
- name: Playing with Nexus OS module
  hosts: all
  gather_facts: false
  vars:
        ansible_connection: network_cli
        ansible_network_os: nxos
tasks:
   - name: create a new role
     nxos_config:
        backup: yes
        lines:
             - rule 10 permit command show policy-map interface input
             - rule 20 permit command show vrf *
             - rule 30 permit command show run vrf *
        parents: role name aegisro

   - name: create a new user
     nxos_user:
        name: aegis_new
        configured_password: <password here>
        state: present
        role: aegisro
  - name: save config
     nxos_config:
          save: yes
...


I get this when running the playbook:

$ ansible-playbook -i ../hosts.ivan --limit bs1.lab aegis-user.yml

PLAY [Playing with Nexus OS module] *********************************************************************************************************************************************************************************

TASK [create a new role] ********************************************************************************************************************************************************************************************
ok: [bs1.lab]

TASK [create a new user] ********************************************************************************************************************************************************************************************
fatal: [bs1.lab]: FAILED! => {"changed": false, "msg": "invalid role specified"}
    to retry, use: --limit @/home/elie/ansible-secbu/etc/ansible/playbooks/aegis-user.retry

PLAY RECAP **********************************************************************************************************************************************************************************************************
bs1.lab                    : ok=1    changed=0    unreachable=0    failed=1

Any ideas on how to make the second task aware of the role that just got created ?

Eliezer R.

Alex King

unread,
Feb 12, 2020, 5:13:18 PM2/12/20
to Ansible Project
I had the same problem.  It seem like it is a shortcoming of the nxos_user module.  It seems like roles are checked against a hard-coded list of standard roles, and the module can't work with user defined roles at all.

Thanks,
Alex

Eliezer Rodriguez

unread,
Mar 10, 2020, 2:07:29 PM3/10/20
to ansible...@googlegroups.com
Got it ! Thanks Alex for taking the time to respond !

Elie

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/htMqABXUmSs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/435920ed-0ee8-4529-93a2-d86ab73fb58a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages