ansible-collections / arista.eos

Ansible Network Collection for Arista EOS
GNU General Public License v3.0
82 stars 70 forks source link

eos_user does not set variables on first task execution #411

Open jorisc90 opened 1 year ago

jorisc90 commented 1 year ago
SUMMARY

eos_user requires a second task to set variables such as privilege level and role. The first time the task runs it creates the user, but fails to set the extra variables

ISSUE TYPE
COMPONENT NAME

eos_user

ANSIBLE VERSION
ansible [core 2.12.8]
  config file = /home/coder/.ansible.cfg
  configured module search path = ['/home/coder/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /home/coder/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION

# /home/coder/.ansible/collections/ansible_collections
Collection Version
---------- -------
arista.eos 5.0.1  
CONFIGURATION
HOST_KEY_CHECKING(/home/coder/.ansible.cfg) = False
OS / ENVIRONMENT

Ansible running on CentOS VM:

Linux 2ace49c7c14b 5.4.132-1.el7.elrepo.x86_64 #1 SMP Wed Jul 14 07:42:43 EDT 2021 x86_64 GNU/Linux

Target OS is cEOS-lab:

Software image version: 4.27.2F-26069621.4272F (engineering build)
STEPS TO REPRODUCE

Create new user using eos_user module, providing extra variables such as privilege level and role

---
  - hosts: leaf1-DC2
    gather_facts: no
    tasks:
    - name: Add User
      eos_user:
        name: automator 
        nopassword: yes
        privilege: 15
        role: network-admin
        state: present

    - name: Add SSH key
      eos_user:
        name: automator
        sshkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
        state: present
EXPECTED RESULTS

Expected the following output in EOS CLI: leaf1-DC2#show run sec automator username automator privilege 15 role network-admin nopassword username automator ssh-key ssh-rsa <key>

ACTUAL RESULTS

Playbook produces the following output on first execution:

username automator nopassword
username automator ssh-key ssh-rsa <key> 

https://gist.github.com/jorisc90/f808d51f86b87fde4194c937da267d45

Playbook produces the expected result when running the same task again:

username automator privilege 15 role network-admin nopassword
username automator ssh-key ssh-rsa <key>

https://gist.github.com/jorisc90/b00280bab3630c15093dae13413fe8cb

kirk444 commented 4 weeks ago

I can confirm that I see the same behavior as the original submitter.