0

I'm having issues with vars precedence, hope you can help me here.

I'm currently using geerlingguy.ansible-role-postgresql as a dependency of my own postgresql role. Is define as a dependency in meta and I'm using import_role on my main task.

I was using vars/main.yml on my own role to override the defaults but now I need to extend my own role a bit like defining diferent variables depending from which group is the server in the inventory.

For this I use group_vars but with the vars/main.yml hack is impossible to override.

What would be the best practice here?

1 Answers1

3

The problem here is that role vars (defined in role/vars/main.yml) have a higher variable precedence than group vars. There are two options to deal with this:

  1. it should be possible to use the include_vars module to load the group_vars needed with a higher precedence
  2. fork the role and alter it to your needs

Forking the role would be my preferred option.

Henrik Pingel
  • 9,380
  • 2
  • 28
  • 39