I can access all vars within group_vars by using the following code.
`
host_vars = self.playbook.inventory.get_variables(hosts[0])
`
However, my playbook is based on the server name, so it loads the correct variable file. How can I access the variable within the file that it loads? I have a variable called “rpm_modules” and the values are different per host group. Maybe there’s a better way of handling this via group_vars?
- include_vars: vars/web
when: “‘web’ in ansible_hostname” - include_vars: vars/perl
when: “‘web’ not in ansible_hostname” - include_vars: vars/batch
when: “‘batch’ in ansible_hostname”