From a1125727345b55b9e0e6898dd58f3ea009e0eccd Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Tue, 16 Mar 2021 14:51:06 +0100 Subject: [PATCH] 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 --- roles/ceph-client/tasks/create_users_keys.yml | 11 ----------- site-container.yml.sample | 17 +++++++++++++++-- site.yml.sample | 13 +++++++++++++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/roles/ceph-client/tasks/create_users_keys.yml b/roles/ceph-client/tasks/create_users_keys.yml index a754d9803..27d33c549 100644 --- a/roles/ceph-client/tasks/create_users_keys.yml +++ b/roles/ceph-client/tasks/create_users_keys.yml @@ -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 set_fact: delegated_node: "{{ groups[mon_group_name][0] if groups.get(mon_group_name, []) | length > 0 else inventory_hostname }}" diff --git a/site-container.yml.sample b/site-container.yml.sample index f8644ccb9..8a5af7667 100644 --- a/site-container.yml.sample +++ b/site-container.yml.sample @@ -49,6 +49,19 @@ - import_role: 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] - import_role: name: ceph-facts @@ -61,11 +74,11 @@ - import_role: name: ceph-container-engine 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: name: ceph-container-common 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 gather_facts: false diff --git a/site.yml.sample b/site.yml.sample index efa432990..ebd73a444 100644 --- a/site.yml.sample +++ b/site.yml.sample @@ -53,6 +53,19 @@ tasks: - import_role: 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: name: ceph-facts - import_role: