clients: build filtered clients group early

when the group `_filtered_clients` is built, the order can change from
the original `clients` group which can cause issues since we run
`ceph-container-engine` on the first client only. It means later in the
playbook we can make call to the container CLI on a node where the
container engine wasn't installed.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/6346/head
Guillaume Abrioux 2021-03-16 14:51:06 +01:00
parent 49668378fb
commit a112572734
3 changed files with 28 additions and 13 deletions

View File

@ -1,15 +1,4 @@
--- ---
# dummy container setup is only supported on x86_64
# when running with containerized_deployment: true this task
# creates a group that contains only x86_64 hosts.
# when running with containerized_deployment: false this task
# will add all client hosts to the group (and not filter).
- name: create filtered clients group
group_by:
key: _filtered_clients
parents: "{{ client_group_name }}"
when: (ansible_facts['architecture'] == 'x86_64') or (not containerized_deployment | bool)
- name: set_fact delegated_node - name: set_fact delegated_node
set_fact: set_fact:
delegated_node: "{{ groups[mon_group_name][0] if groups.get(mon_group_name, []) | length > 0 else inventory_hostname }}" delegated_node: "{{ groups[mon_group_name][0] if groups.get(mon_group_name, []) | length > 0 else inventory_hostname }}"

View File

@ -49,6 +49,19 @@
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
# dummy container setup is only supported on x86_64
# when running with containerized_deployment: true this task
# creates a group that contains only x86_64 hosts.
# when running with containerized_deployment: false this task
# will add all client hosts to the group (and not filter).
- name: create filtered clients group
add_host:
name: "{{ item }}"
groups: _filtered_clients
with_items: "{{ groups.get(client_group_name, []) | intersect(ansible_play_batch) }}"
when: (hostvars[item]['ansible_architecture'] == 'x86_64') or (not containerized_deployment | bool)
tags: [with_pkg, fetch_container_image] tags: [with_pkg, fetch_container_image]
- import_role: - import_role:
name: ceph-facts name: ceph-facts
@ -61,11 +74,11 @@
- import_role: - import_role:
name: ceph-container-engine name: ceph-container-engine
tags: with_pkg tags: with_pkg
when: (group_names != ['clients']) or (inventory_hostname == groups.get('clients', [''])|first) when: (group_names != ['clients'] and group_names != ['clients', '_filtered_clients'] and group_names != ['_filtered_clients', 'clients']) or (inventory_hostname == groups.get('_filtered_clients', [''])|first)
- import_role: - import_role:
name: ceph-container-common name: ceph-container-common
tags: fetch_container_image tags: fetch_container_image
when: (group_names != ['clients']) or (inventory_hostname == groups.get('clients', [''])|first) when: (group_names != ['clients'] and group_names != ['clients', '_filtered_clients'] and group_names != ['_filtered_clients', 'clients']) or (inventory_hostname == groups.get('_filtered_clients', [''])|first)
- hosts: mons - hosts: mons
gather_facts: false gather_facts: false

View File

@ -53,6 +53,19 @@
tasks: tasks:
- import_role: - import_role:
name: ceph-defaults name: ceph-defaults
# dummy container setup is only supported on x86_64
# when running with containerized_deployment: true this task
# creates a group that contains only x86_64 hosts.
# when running with containerized_deployment: false this task
# will add all client hosts to the group (and not filter).
- name: create filtered clients group
add_host:
name: "{{ item }}"
groups: _filtered_clients
with_items: "{{ groups.get(client_group_name, []) | intersect(ansible_play_batch) }}"
when: (hostvars[item]['ansible_architecture'] == 'x86_64') or (not containerized_deployment | bool)
- import_role: - import_role:
name: ceph-facts name: ceph-facts
- import_role: - import_role: