Skip to content

Commit

Permalink
clients: build filtered clients group early
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit a112572)
  • Loading branch information
guits committed Mar 25, 2021
1 parent 7c6783a commit d6fcd78
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
12 changes: 0 additions & 12 deletions roles/ceph-client/tasks/create_users_keys.yml
@@ -1,16 +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
add_host:
name: "{{ item }}"
groups: _filtered_clients
with_items: "{{ groups[client_group_name] | intersect(ansible_play_batch) }}"
when: (hostvars[item]['ansible_facts']['ansible_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 }}"
Expand Down
17 changes: 15 additions & 2 deletions site-container.yml.sample
Expand Up @@ -50,6 +50,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_facts']['architecture'] == 'x86_64') or (not containerized_deployment | bool)

tags: [with_pkg, fetch_container_image]
- import_role:
name: ceph-facts
Expand All @@ -62,11 +75,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
Expand Down
13 changes: 13 additions & 0 deletions site.yml.sample
Expand Up @@ -54,6 +54,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_facts']['architecture'] == 'x86_64') or (not containerized_deployment | bool)

- import_role:
name: ceph-facts
- import_role:
Expand Down

0 comments on commit d6fcd78

Please sign in to comment.