Skip to content

Commit

Permalink
Make inventory group 'balancers' optional in Ansible tasks
Browse files Browse the repository at this point in the history
With this commit, we've adjusted our Ansible tasks to treat the 'balancers' group as optional.
Previously, if this group wasn't defined in the inventory file, it would result in a task failure. We've addressed this issue by utilizing the default filter, which handles the 'balancers' group as an empty list if not defined, thus preventing any associated errors.

Please note that this change doesn't impact the 'postgres_cluster' group, which remains as a required group in the inventory.

Issue: #388
  • Loading branch information
vitabaks committed Jul 3, 2023
1 parent 53edccd commit 16c63c5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion roles/deploy-finish/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
- name: Create list of nodes
run_once: true
set_fact:
haproxy_nodes: "{% for host in groups['balancers'] %}{{ hostvars[host]['inventory_hostname'] }}{% if not loop.last %},{% endif %}{% endfor %}"
haproxy_nodes: "{% for host in groups['balancers'] | default([]) %}{{ hostvars[host]['inventory_hostname'] }}{% if not loop.last %},{% endif %}{% endfor %}"
postgres_cluster_nodes: "{% for host in groups['postgres_cluster'] %}{{ hostvars[host]['inventory_hostname'] }}{% if not loop.last %},{% endif %}{% endfor %}"

- name: PostgreSQL Cluster connection info
Expand Down

0 comments on commit 16c63c5

Please sign in to comment.