]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
don't call ceph-facts unnecessarily guits-refact_rolling_update 5707/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Fri, 21 Aug 2020 14:30:36 +0000 (16:30 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 21 Aug 2020 14:48:10 +0000 (16:48 +0200)
We call this role for each play which isn't needed.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
infrastructure-playbooks/rolling_update.yml
roles/ceph-facts/tasks/container_exec_cmd.yml [new file with mode: 0644]
roles/ceph-facts/tasks/facts.yml
roles/ceph-facts/tasks/find_running_mon.yml [new file with mode: 0644]
site-container.yml.sample
site.yml.sample

index 4a8aacdd17d00854ae005eaee1f3936c6f4ffd26..87d61ab2fb13d9e2dd446e9159684d1b0bc84171 100644 (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
 
     - 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
 
         - import_role:
             name: ceph-defaults
-        - import_role:
-            name: ceph-facts
         - import_role:
             name: ceph-handler
         - import_role:
 
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
     - import_role:
         name: ceph-handler
     - import_role:
   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 }}"
   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"
   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:
       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
     - import_role:
         name: ceph-defaults
 
-    - import_role:
-        name: ceph-facts
-
     - name: prevent restart from the packaging
       systemd:
         name: ceph-mds@{{ ansible_hostname }}
     - import_role:
         name: ceph-defaults
 
-    - import_role:
-        name: ceph-facts
-
     - name: prevent restarts from the packaging
       systemd:
         name: ceph-mds@{{ ansible_hostname }}
 
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
 
     - name: stop ceph rgw when upgrading from stable-3.2
       systemd:
 
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
     - import_role:
         name: ceph-handler
     - import_role:
 
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
     - import_role:
         name: ceph-handler
     - import_role:
 
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
     - import_role:
         name: ceph-handler
     - import_role:
   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:
         masked: yes
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
-        tasks_from: container_binary.yml
     - import_role:
         name: ceph-handler
     - import_role:
   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"
             state: stopped
           failed_when: false
 
-        - import_role:
-            name: ceph-facts
         - import_role:
             name: ceph-container-engine
         - import_role:
             - prometheus
             - grafana-server
 
-        - import_role:
-            name: ceph-facts
         - import_role:
             name: ceph-facts
             tasks_from: grafana
     - name: with dashboard configuration
       when: dashboard_enabled | bool
       block:
-        - import_role:
-            name: ceph-facts
         - import_role:
             name: ceph-facts
             tasks_from: grafana
diff --git a/roles/ceph-facts/tasks/container_exec_cmd.yml b/roles/ceph-facts/tasks/container_exec_cmd.yml
new file mode 100644 (file)
index 0000000..fbb61f1
--- /dev/null
@@ -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
index 98f0aa48fd791d5ca0d16f777f84ed8c55f93e49..8c64ade523eca92da534362feeb806922f5dcc06 100644 (file)
   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
diff --git a/roles/ceph-facts/tasks/find_running_mon.yml b/roles/ceph-facts/tasks/find_running_mon.yml
new file mode 100644 (file)
index 0000000..6e75b87
--- /dev/null
@@ -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
\ No newline at end of file
index e954bdcc9c7097087053acec38d47aa1d1533c5b..cd354f5f5d6c5490145fe9ef6d8d48c37a79109e 100644 (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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
   tasks:
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
-        tasks_from: container_binary.yml
     - import_role:
         name: ceph-handler
     - import_role:
index e9796bb24b3b97a2364740b6d9f8a6982298aec0..788e6fd3f1cc22b834ae65df3aabca04e4d2ade4 100644 (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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
     - 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']
     - import_role:
         name: ceph-defaults
       tags: ['ceph_update_config']
-    - import_role:
-        name: ceph-facts
-      tags: ['ceph_update_config']
     - import_role:
         name: ceph-rgw-loadbalancer
 
   tasks:
     - import_role:
         name: ceph-defaults
-    - import_role:
-        name: ceph-facts
-        tasks_from: container_binary.yml
     - import_role:
         name: ceph-handler
     - import_role: