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"}