facts: refact and optimize memory consumption

there's no need to run this task on all nodes.
This uses too much memory for nothing.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1856981

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit f0fe193d8e)
pull/5764/head
Guillaume Abrioux 2020-08-17 10:31:11 +02:00 committed by Dimitri Savineau
parent 593264e5f7
commit 828817489c
1 changed files with 50 additions and 37 deletions

View File

@ -104,12 +104,12 @@
# this task shouldn't run in a rolling_update situation
# because it blindly picks a mon, which may be down because
# of the rolling update
- name: is ceph running already?
command: "{{ timeout_command }} {{ _container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json"
- name: get current fsid if cluster is already running
command: "{{ timeout_command }} {{ _container_exec_cmd | default('') }} ceph --cluster {{ cluster }} fsid"
changed_when: false
failed_when: false
check_mode: no
register: ceph_current_status
register: current_fsid
run_once: true
delegate_to: "{{ groups[mon_group_name][0] if running_mon is undefined else running_mon }}"
when:
@ -117,9 +117,9 @@
# set this as a default when performing a rolling_update
# so the rest of the tasks here will succeed
- name: set_fact ceph_current_status rc 1
- name: set_fact current_fsid rc 1
set_fact:
ceph_current_status:
current_fsid:
rc: 1
when: rolling_update or groups.get(mon_group_name, []) | length == 0
@ -148,22 +148,16 @@
- rolling_update | bool
- groups.get(mon_group_name, []) | length > 0
- name: set_fact ceph_current_status (convert to json)
- name: set_fact fsid from current_fsid
set_fact:
ceph_current_status: "{{ ceph_current_status.stdout | from_json }}"
when:
- not rolling_update | bool
- ceph_current_status.rc == 0
- name: set_fact fsid from ceph_current_status
set_fact:
fsid: "{{ ceph_current_status.fsid }}"
when: ceph_current_status.fsid is defined
fsid: "{{ current_fsid.stdout }}"
run_once: true
when: current_fsid.rc == 0
- name: fsid related tasks
when:
- generate_fsid | bool
- ceph_current_status.fsid is undefined
- current_fsid.rc != 0
- not rolling_update | bool
block:
- name: generate cluster fsid
@ -225,7 +219,27 @@
- not containerized_deployment | bool
- ansible_os_family == 'Debian'
- name: set_fact rgw_hostname
- name: backward compatibility tasks related
when:
- inventory_hostname in groups.get(rgw_group_name, [])
or inventory_hostname in groups.get(nfs_group_name, [])
block:
- name: get ceph current status
command: "{{ timeout_command }} {{ _container_exec_cmd | default('') }} ceph --cluster {{ cluster }} -s -f json"
changed_when: false
failed_when: false
check_mode: no
register: ceph_current_status
run_once: true
delegate_to: "{{ groups[mon_group_name][0] if running_mon is undefined else running_mon }}"
- name: set_fact ceph_current_status
set_fact:
ceph_current_status: "{{ ceph_current_status.stdout | from_json }}"
run_once: true
when: ceph_current_status.rc == 0
- name: set_fact rgw_hostname
set_fact:
rgw_hostname: "{% set _value = ansible_hostname -%}
{% for key in (ceph_current_status['servicemap']['services']['rgw']['daemons'] | list) -%}
@ -235,7 +249,6 @@
{% endfor -%}
{{ _value }}"
when:
- inventory_hostname in groups.get(rgw_group_name, []) or inventory_hostname in groups.get(nfs_group_name, [])
- ceph_current_status['servicemap'] is defined
- ceph_current_status['servicemap']['services'] is defined
- ceph_current_status['servicemap']['services']['rgw'] is defined