cat vars/users

users:
  - username: test
    homedir: /home/test
    shell: /bin/bash
  - username: test1
    homedir: /home/test1
    shell: /bin/bash
  - username: test2
    homedir: /home/test2
    shell: /bin/bash

cat arrays.yaml
---
- name: show arrays
  hosts: ansible1
  vars_files:
    - vars/users
  tasks:
    - name: print array values
      debug:
        msg: "User {{ users.test.username }} has homedirectory {{ 
users.test.homedir }} and shell {{ users.test.shell }}"
~
I got the error below:
fatal: [ansible1]: FAILED! => {"msg": "The task includes an option with an 
undefined variable. The error was: 'list object' has no attribute 
'test'\n\nThe error appears to be in '/home/ansible/arrays.yml': line 7, 
column 7, but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: 
print array values\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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/28a8f74e-2697-4a4c-ad87-7813f6c74592n%40googlegroups.com.

Reply via email to