vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.27k stars 340 forks source link

Hardcoded vars file path makes it harder to use versioned inventories #581

Closed n-borges closed 2 months ago

n-borges commented 2 months ago

Hello everyone, I might be wrong, but it seems to me that the playbooks search for variables in hardcoded paths (namely vars/main.yml). This, I think, makes it a bit harder to use this (awesome!) playbooks with multiple inventories. Consider the following usecase:

If the variables files paths were not hardcoded, i could simply clone the repo, keep my inventories in dedicated directories and run ansible-playbook <playbook name> -i <inventory dir path>, and let Ansible lookup variables in paths relative to the inventory directory.

Don't you think this would make for a slightly better user experience? Would you be open to a MR to make this kind of change?

Thanks

redy01 commented 2 months ago

Had same consideration and moved all (needed by me) variables to additional file, f.ex.: custom_config.yml and use this configuration during playbook run, like: ansible-playbook -i my_inventory -e@custom_config.yml deploy_pgcluster.yml

vitabaks commented 2 months ago

Hello @n-borges

as @redy01 (thanks!) has already correctly pointed out, you can redefine variables at the --extra-vars level, or at the inventory vars level.

In a future version of postgresql_cluster there will be a docker image that can be used as an installer, and there will mainly be used extra-vars, examples https://github.com/vitabaks/postgresql_cluster/pull/464