Skip to content
Snippets Groups Projects
Commit da80a71b authored by Zuul's avatar Zuul Committed by Gerrit Code Review
Browse files

Merge "Fix: configure etc-hosts for overcloud group"

parents e460099e 498de81e
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,4 @@
customize_etc_hosts: true
# List of hosts to add to /etc/hosts.
etc_hosts_hosts: "{{ ansible_play_hosts_all }}"
etc_hosts_hosts: "{{ groups['overcloud'] }}"
---
gather_facts_delegated_limit_hosts: "{{ ansible_play_hosts_all }}"
gather_facts_delegated_batch_index: "{{ gather_facts_delegated_limit_hosts.index(inventory_hostname) }}"
gather_facts_delegated_batch_size: "{{ gather_facts_delegated_limit_hosts | length }}"
gather_facts_delegated_limit_hosts: "{{ groups['overcloud'] }}"
gather_facts_delegated_batch_index: "{{ ansible_play_batch.index(inventory_hostname) }}"
gather_facts_delegated_batch_count: "{{ ansible_play_batch | length }}"
# Use a python list slice to divide the group up.
# Syntax: [<start index>:<end index>:<step size>]
gather_facts_delegated_delegate_hosts: >-
{{ gather_facts_delegated_limit_hosts[gather_facts_delegated_batch_index | int::gather_facts_delegated_batch_size | int] }}
{{ gather_facts_delegated_limit_hosts[gather_facts_delegated_batch_index | int::gather_facts_delegated_batch_count | int] }}
---
- name: Gather facts for delegated host
any_errors_fatal: true
setup:
filter: "{{ kayobe_ansible_setup_filter }}"
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
delegate_facts: True
delegate_to: "{{ delegated_host }}"
# NOTE: Without this, the host's ansible_host variable will not be respected
# when using delegate_to.
vars:
ansible_host: "{{ hostvars[delegated_host].ansible_host | default(delegated_host) }}"
---
- name: Gather facts for all hosts (if using --limit)
setup:
filter: "{{ kayobe_ansible_setup_filter }}"
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
delegate_facts: True
delegate_to: "{{ item }}"
with_items: "{{ gather_facts_delegated_delegate_hosts }}"
include_tasks: gather-facts-delegated.yml
vars:
delegated_host: "{{ gather_facts_delegated_delegate_hosts[item | int] }}"
# Loop over the index into each host's batch, so tasks are not all included serially.
with_sequence: start=0 end="{{ gather_facts_delegated_delegate_hosts | length | int - 1 }}"
when:
- not hostvars[item].ansible_facts
- item | int < gather_facts_delegated_delegate_hosts | length
- not hostvars[gather_facts_delegated_delegate_hosts[item | int]].ansible_facts
---
fixes:
- |
Fixes the bug where /etc/hosts was not populated correctly when running
Kayobe using a host limit.
`LP#2051714 <https://launchpad.net/bugs/2051714>`__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment