I have built a .yml file with a set of users that I want to push to my 
routers with vyos_user module.
This is my *users.yml*

users:
  - full_name:               "Olof Lundgren"
    name:                    "olof"
    configured_password:     "abcd1234"
    level:                   "admin"
    ssh-key:
        name:                "olof@olof-ubuntu-work"
        type:                "ssh-rsa"
        key:                  "xxxxxxxxxxxxxxx"


  - full_name:           "T7D VyOS default user"
    name:                "vyos"
    configured_password: "vyos"
    level:               "admin"


  - full_name:           "Servicedesk operator user"
    name:                "servicedesk"
    configured_password: "password"
    level:               "operator"


I built my playbook, but I dont know how to use this list of users in the 
play.

This is my attempt: *add-users-vyos.yml*

  - hosts:                        vyos
    connection:                   network_cli
    gather_facts:                 no


    tasks:
        - name:                   Include user database
          include_vars:
            file:                 users.yml
#            name:                 vyosusers


        - name:                    add and set users
          vyos_user:
            full_name:           "{{ users.full_name }}"
            configured_password: "{{ users.configured_password }}"
            name:                "{{ users.name }}"
            level:               admin
            purge:               no
            state:               present
            update_password:     always
          loop: "{{ users }}"


First it successfully plays the task "Include user database" and I can see 
the variables are defined 
The on the next task. my error message is this: 

TASK [add and set users] 
************************************************************************************************************************************************************************************
fatal: [vyos-router.lan]: FAILED! => {"msg": "The task includes an option 
with an undefined variable. The error was: 'list object' has no attribute 
'configured_password'\n\nThe error appears to have been in 
'/home/olof/Documents/ansible/add-users-vyos.yml': line 11, column 11, but 
may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n        - name:                    add 
and set users\n          ^ here\n"}


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2786b0ea-458f-4ea2-882c-397859f2ad7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to