Openstack ansible service variables
Hi, We have an OSA setup. I see that common-playbooks/haproxy-service-config.yml has the following: --- - hosts: "{{ service_group }}" gather_facts: false run_once: true tasks: - name: "Temporarily copy haproxy_service_configs value from {{ service_group }} to haproxy_all" add_host: name: "{{ item }}" haproxy_service_configs: "{{ hostvars[inventory_hostname][service_variable] }}" with_items: "{{ groups['haproxy_all'] }}" How does the openstack ansible collect haproxy configuration for a specific service as in this case for repo service ? Where is this defined in the code ? How does it even generate specific haproxy variables for each service ? How does it specifically know what haproxy variables to collect ?
Hi, Start by looking in playbooks/repo-install.yml file, to see how the code you pasted is called: https://opendev.org/openstack/openstack-ansible/src/branch/master/playbooks/... You can see that "service_group" is set to "repo_all", so these are the hosts targetted by this play, with the host_group vars for the "repo_all" group being in scope. See https://opendev.org/openstack/openstack-ansible/src/branch/stable/2023.1/pla... If you then look at the group_vars for the repo_all group, you will see the definition of the haproxy config for those hosts https://opendev.org/openstack/openstack-ansible/src/branch/master/inventory/... This is all standard use of the ansible group_vars concept. The only subtle thing here is the use of add_host to allow the haproxy_all group to access variables from, in this case, the repo_all group. This is necessary becasue ultimately the play runs against the haproxy_all group here to write out the config files https://opendev.org/openstack/openstack-ansible/src/branch/stable/2023.1/pla... Regards, Jonathan. On 21/02/2024 11:56, Gk Gk wrote:
Hi,
We have an OSA setup. I see that common-playbooks/haproxy-service-config.yml has the following:
--- - hosts: "{{ service_group }}" gather_facts: false run_once: true tasks: - name: "Temporarily copy haproxy_service_configs value from {{ service_group }} to haproxy_all" add_host: name: "{{ item }}" haproxy_service_configs: "{{ hostvars[inventory_hostname][service_variable] }}" with_items: "{{ groups['haproxy_all'] }}"
How does the openstack ansible collect haproxy configuration for a specific service as in this case for repo service ? Where is this defined in the code ? How does it even generate specific haproxy variables for each service ? How does it specifically know what haproxy variables to collect ?
participants (2)
-
Gk Gk
-
Jonathan Rosser