location of `group_vars/` for included playbooks changed in 2.4+ ?

Hello,

I am updating some playbooks written initially for Ansible 2.2. and 2.3 to remove the features that were deprecated in Ansible 2.4+

The playbook is divided across multiple files, where main.yml would include: roles/play_a.yml (at playbook level), and then play_a.yml would call roles (e.g.) a1, a2, etc. Global variables are defined in group_vars/all, where group_vars/ is a sibling of main.yml:

playbook_dir
>
+- main.yml
+- group_vars/
> >
> `- all
+- roles/
>
+- play_a.yml
+- a1/
+- a2/
...

Now, if I change playbook-level include: in main.yml to import_playbook: then group variables are no longer available to roles included in the play… I have to make an additional group_vars/all file in the roles/ subdirectory.

Is this the expected behavior? Did I miss some important warning about the (relatively) new import_playbook: ?

Thanks,
Riccardo

This is documented at https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_2.4.html#initial-playbook-relative-group-vars-and-host-vars

Effectively, you want to make sure your group_vars is relative to your inventory file, and not your playbook file.

Thank you very much for your reply, Matt – indeed this was rather clearly documented in the 2.4 porting guide…

Effectively, you want to make sure your group_vars is relative to your inventory file, and not your playbook file.

Won’t be possible in my case (inventory is generated and placed in a temp directory, whereas group vars are effectively parts of the playbooks); I’ll see whether it’s better to maintain symlinks or switch to explicitly loading with vars_files:

Thanks,
Riccardo