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:
- {db: test33, name: test111, password: secret, port: 5432 }
- {db: test33, name: test222, password: secret, port: 5432 }
-
postgresql_privs:
role: "{{ item.name }}"
database: "{{ item.database }}"
privs: "{{ item.privs }}"
type: "{{ item.type }}"
obj: "{{ item.obj }}"
with_items:
- { name: test111, database: test33, privs: ALL, type: table, obj: new }
- { name: test222, database: test33, privs: SELECT, type: table, obj:
new }
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
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a10eed08-2afa-499a-a794-2116ba25347e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.