# fill items from file

**URL:** <https://forum.ansible.com/t/fill-items-from-file/26424>\
**Category:** Ansible Project\
**Created:** [January 5, 2018, 3:54pm UTC](https://forum.ansible.com/t/fill-items-from-file/26424 "2018-01-05T15:54:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marek\_Bazant](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@Marek\_Bazant](https://forum.ansible.com/u/Marek_Bazant)\
**Post date:** [January 5, 2018, 3:54pm UTC](https://forum.ansible.com/t/fill-items-from-file/26424/1 "2018-01-05T15:54:17Z")

</div>

Hello,

i want to fill items from file. example below work nice, but if i tried items fill from separate file, then it doesnt work.

- postgresql\_user:  
db: “{{ item.db }}”  
name: “{{ item.name }}”  
password: “{{ item.password }}”  
port: “{{ item.port }}”  
with\_items:

- postgresql\_privs:  
role: “{{ item.name }}”  
database: “{{ item.database }}”  
privs: “{{ item.privs }}”  
type: “{{ item.type }}”  
obj: “{{ item.obj }}”  
with\_items:

i tried example below but it doesnt work as i expect. I also tried to include file, but it didnt help too

- name: get list of users  
include\_vars:  
file: …/vars/main.yml  
name: users

role/name/vars/main.yml  
users:

- { name: user144, username: test144, db: test33, password: secret, priv: ALL }

role/name/tasks/main.yml

- postgresql\_user:  
db: “{{ item.db }}”  
name: “{{ item.username }}”  
password: “{{ item.password }}”  
priv: “{{ item.priv }}”  
with\_items:
  - “{{ users }}”

result:  
fatal: [default]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘password’\n\nThe error appears to have been in ‘/home/m/Documents/Vagrant/postgresql/tests/roles/psql/tasks/main.yml’: line 6, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- postgresql\_user:\n ^ here\n\nexception type: \<class ‘ansible.errors.AnsibleUndefinedVariable’\>\nexception: ‘dict object’ has no attribute ‘password’”}

thank you
