don't call ceph-facts unnecessarily

We call this role for each play which isn't needed.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
guits-refact_rolling_update
Guillaume Abrioux 2020-08-21 16:30:36 +02:00
parent cec994b973
commit 28922d2ba8
6 changed files with 89 additions and 188 deletions

View File

@ -84,7 +84,6 @@
- import_role:
name: ceph-facts
- import_role:
name: ceph-infra
@ -94,6 +93,7 @@
when:
- containerized_deployment | bool
- ceph_docker_registry_auth | bool
- (group_names != ['clients']) or (inventory_hostname == groups.get('clients', [''])|first)
- import_role:
name: ceph-validate
@ -130,8 +130,11 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
tasks_from: find_running_mon.yml
when: containerized_deployment | bool
- block:
- name: get ceph cluster status
@ -280,8 +283,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- import_role:
name: ceph-handler
- import_role:
@ -316,8 +317,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- import_role:
name: ceph-handler
- import_role:
@ -338,9 +337,6 @@
tasks:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
tasks_from: container_binary.yml
- name: set osd flags
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd set {{ item }}"
@ -360,8 +356,6 @@
tasks:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- name: get osd numbers - non container
shell: "if [ -d /var/lib/ceph/osd ] ; then ls /var/lib/ceph/osd | sed 's/.*-//' ; fi"
@ -438,9 +432,6 @@
tasks:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
tasks_from: container_binary.yml
- name: set_fact container_exec_cmd_osd
set_fact:
@ -462,8 +453,6 @@
block:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- name: deactivate all mds rank > 0 if any
when: groups.get(mds_group_name, []) | length > 1
@ -548,9 +537,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- name: prevent restart from the packaging
systemd:
name: ceph-mds@{{ ansible_hostname }}
@ -594,9 +580,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- name: prevent restarts from the packaging
systemd:
name: ceph-mds@{{ ansible_hostname }}
@ -634,8 +617,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- name: stop ceph rgw when upgrading from stable-3.2
systemd:
@ -683,8 +664,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- import_role:
name: ceph-handler
- import_role:
@ -731,8 +710,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- import_role:
name: ceph-handler
- import_role:
@ -772,8 +749,6 @@
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- import_role:
name: ceph-handler
- import_role:
@ -797,16 +772,11 @@
tasks:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- import_role:
name: ceph-handler
- import_role:
name: ceph-common
when: not containerized_deployment | bool
- import_role:
name: ceph-container-common
when: containerized_deployment | bool
- import_role:
name: ceph-config
- import_role:
@ -831,9 +801,6 @@
masked: yes
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
tasks_from: container_binary.yml
- import_role:
name: ceph-handler
- import_role:
@ -854,8 +821,6 @@
tasks:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
- name: container | disallow pre-pacific OSDs and enable all new pacific-only functionality
command: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} ceph osd require-osd-release pacific"
@ -906,8 +871,6 @@
state: stopped
failed_when: false
- import_role:
name: ceph-facts
- import_role:
name: ceph-container-engine
- import_role:
@ -940,8 +903,6 @@
- prometheus
- grafana-server
- import_role:
name: ceph-facts
- import_role:
name: ceph-facts
tasks_from: grafana
@ -961,8 +922,6 @@
- name: with dashboard configuration
when: dashboard_enabled | bool
block:
- import_role:
name: ceph-facts
- import_role:
name: ceph-facts
tasks_from: grafana

View File

@ -0,0 +1,6 @@
---
- name: set_fact container_exec_cmd
set_fact:
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] if not rolling_update else hostvars[mon_host | default(groups[mon_group_name][0])]['ansible_hostname'] }}"
when:
- containerized_deployment | bool

View File

@ -33,87 +33,9 @@
run_once: true
when: groups.get(mon_group_name, []) | length > 0
- name: find a running monitor
- name: import_tasks find_running_mon.yml
import_tasks: find_running_mon.yml
when: groups.get(mon_group_name, []) | length > 0
block:
- name: set_fact container_exec_cmd
set_fact:
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] if not rolling_update else hostvars[mon_host | default(groups[mon_group_name][0])]['ansible_hostname'] }}"
when:
- containerized_deployment | bool
- name: find a running mon container
command: "{{ container_binary }} ps -q --filter name=ceph-mon-{{ hostvars[item]['ansible_hostname'] }}"
register: find_running_mon_container
failed_when: false
run_once: true
delegate_to: "{{ item }}"
with_items: "{{ groups.get(mon_group_name, []) }}"
when:
- containerized_deployment | bool
- name: check for a ceph mon socket
shell: stat --printf=%n {{ rbd_client_admin_socket_path }}/{{ cluster }}-mon*.asok
changed_when: false
failed_when: false
check_mode: no
register: mon_socket_stat
run_once: true
delegate_to: "{{ item }}"
with_items: "{{ groups.get(mon_group_name, []) }}"
when:
- not containerized_deployment | bool
- name: check if the ceph mon socket is in-use
command: grep -q {{ item.stdout }} /proc/net/unix
changed_when: false
failed_when: false
check_mode: no
register: mon_socket
run_once: true
with_items: "{{ mon_socket_stat.results }}"
when:
- not containerized_deployment | bool
- item.rc == 0
- name: set_fact running_mon - non_container
set_fact:
running_mon: "{{ hostvars[item.item.item]['inventory_hostname'] }}"
with_items: "{{ mon_socket.results }}"
run_once: true
when:
- not containerized_deployment | bool
- item.rc is defined
- item.rc == 0
- name: set_fact running_mon - container
set_fact:
running_mon: "{{ item.item }}"
run_once: true
with_items: "{{ find_running_mon_container.results }}"
when:
- containerized_deployment | bool
- item.stdout_lines | default([]) | length > 0
- name: set_fact _container_exec_cmd
set_fact:
_container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0] if running_mon is undefined else running_mon]['ansible_hostname'] }}"
when:
- containerized_deployment | bool
# 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: 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: current_fsid
run_once: true
delegate_to: "{{ groups[mon_group_name][0] if running_mon is undefined else running_mon }}"
when:
- not rolling_update | bool
# set this as a default when performing a rolling_update
# so the rest of the tasks here will succeed

View File

@ -0,0 +1,77 @@
---
- name: import_tasks container_exec_cmd.yml
import_tasks: container_exec_cmd.yml
when: containerized_deployment | bool
- name: find a running mon container
command: "{{ container_binary }} ps -q --filter name=ceph-mon-{{ hostvars[item]['ansible_hostname'] }}"
register: find_running_mon_container
failed_when: false
run_once: true
delegate_to: "{{ item }}"
with_items: "{{ groups.get(mon_group_name, []) }}"
when:
- containerized_deployment | bool
- name: check for a ceph mon socket
shell: stat --printf=%n {{ rbd_client_admin_socket_path }}/{{ cluster }}-mon*.asok
changed_when: false
failed_when: false
check_mode: no
register: mon_socket_stat
run_once: true
delegate_to: "{{ item }}"
with_items: "{{ groups.get(mon_group_name, []) }}"
when:
- not containerized_deployment | bool
- name: check if the ceph mon socket is in-use
command: grep -q {{ item.stdout }} /proc/net/unix
changed_when: false
failed_when: false
check_mode: no
register: mon_socket
run_once: true
with_items: "{{ mon_socket_stat.results }}"
when:
- not containerized_deployment | bool
- item.rc == 0
- name: set_fact running_mon - non_container
set_fact:
running_mon: "{{ hostvars[item.item.item]['inventory_hostname'] }}"
with_items: "{{ mon_socket.results }}"
run_once: true
when:
- not containerized_deployment | bool
- item.rc is defined
- item.rc == 0
- name: set_fact running_mon - container
set_fact:
running_mon: "{{ item.item }}"
run_once: true
with_items: "{{ find_running_mon_container.results }}"
when:
- containerized_deployment | bool
- item.stdout_lines | default([]) | length > 0
- name: set_fact _container_exec_cmd
set_fact:
_container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0] if running_mon is undefined else running_mon]['ansible_hostname'] }}"
when:
- containerized_deployment | bool
# 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: 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: current_fsid
run_once: true
delegate_to: "{{ groups[mon_group_name][0] if running_mon is undefined else running_mon }}"
when:
- not rolling_update | bool

View File

@ -87,9 +87,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -131,9 +128,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -169,9 +163,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -207,9 +198,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -245,9 +233,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -283,9 +268,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -321,9 +303,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -359,9 +338,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -398,9 +374,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -440,9 +413,6 @@
tasks:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
tasks_from: container_binary.yml
- import_role:
name: ceph-handler
- import_role:

View File

@ -79,9 +79,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -120,9 +117,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -158,9 +152,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -196,9 +187,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -234,9 +222,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -272,9 +257,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -310,9 +292,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -348,9 +327,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -387,9 +363,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-handler
tags: ['ceph_update_config']
@ -426,9 +399,6 @@
- import_role:
name: ceph-defaults
tags: ['ceph_update_config']
- import_role:
name: ceph-facts
tags: ['ceph_update_config']
- import_role:
name: ceph-rgw-loadbalancer
@ -461,9 +431,6 @@
tasks:
- import_role:
name: ceph-defaults
- import_role:
name: ceph-facts
tasks_from: container_binary.yml
- import_role:
name: ceph-handler
- import_role: