]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
clients: build filtered clients group early
authorGuillaume Abrioux <gabrioux@redhat.com>
Tue, 16 Mar 2021 13:51:06 +0000 (14:51 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 16 Mar 2021 18:38:04 +0000 (19:38 +0100)
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>
roles/ceph-client/tasks/create_users_keys.yml
site-container.yml.sample
site.yml.sample

index a754d9803c4af5dee6e7086ca831b47fd223ae20..27d33c5498349735096072549ec47b4f19f73557 100644 (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
   set_fact:
     delegated_node: "{{ groups[mon_group_name][0] if groups.get(mon_group_name, []) | length > 0 else inventory_hostname }}"
index f8644ccb9b404d54330050c729ae0bbb41b71735..8a5af7667e314d8cfd8b26038fd6bbf269c56bc8 100644 (file)
 
     - 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
     - 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
index efa432990985195bbd3c94964260ba4bd4e161fa..ebd73a44443e726a3696487eb0458754514a5cee 100644 (file)
   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: