PLAY [foo] ***********************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [debug] *********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "main | group var message"
}
TASK [debug] *********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "main | host var message"
}
PLAY [foo] ***********************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [debug] *********************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: '_group_vars_msg' is undefined\n\nThe error appears to have been in '/home/ansible/playbooks/sub.yml': line 4, 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 - debug: msg=\"sub | {{ _group_vars_msg }}\"\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: '_group_vars_msg' is undefined"}
to retry, use: --limit @/home/ansible/main.retry
PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=1
The imported playbook fails to resolve the variables. can someone explain in more details why my main.yml is not considered to be the "top" playbook in this case or is importing playbooks not what is meant by "chain" in the documentation ?
I have of course tried to set the playbook_vars_root to all too to no avail.
I understand that I can move/link/whatever my group_vars and host_vars to inventories or playbooks, but the behaviour doesn't seem consistent with the documentation and I don't understand why. if playbook_vars_root is useless/unsupported it would be nice to remove it from the documentation or at least make it clear that it doesn't do anything.