Trying to automate some per-host configuration, which requires a list of items (databases to be created per database host in this case).
The inventory file is at ./inventory/hosts:
[dbservers]
intweb
Which has no group_vars associated, and the following host_vars located at ./inventory/host_vars/intweb.yml:
---
testvalue: test
anothertestvalue:
- value1
- value2
- value3
yetanothervalue: test
When running the following task in a play:
[...other lines...]
- name: Test list variables
debug:
msg: "List item is {{ item }}"
with_items: "{{ anothertestvalue }}"
- name: Test list variable as string
debug:
msg: "{{ anothertestvalue }}"
- name: Test simple variables
debug:
msg: "{{ testvalue }}"
When running the playbook via
> ansible-playbook plays/default.yml --limit dbservers --start-at-task="Test list variables"
the relevant output is the following (which seems to ignore the list completely):
[...]
TASK [mariadb : Test list variables] ****************************************************
TASK [mariadb : Test list variable as string] *******************************************
ok: [intweb] => {
"msg": []
}
TASK [mariadb : Test simple variables] **************************************************
ok: [intweb] => {
"msg": "test"
}
What is the correct syntax to have a list such as the above defind in host_vars?