]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
infra: rename osd-configure to add-osd and improve it
authorSébastien Han <seb@redhat.com>
Thu, 27 Sep 2018 14:31:22 +0000 (16:31 +0200)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Wed, 17 Oct 2018 11:26:11 +0000 (11:26 +0000)
The playbook has various improvements:

* run ceph-validate role before doing anything
* run ceph-fetch-keys only on the first monitor of the inventory list
* set noup flag so PGs get distributed once all the new OSDs have been
added to the cluster and unset it when they are up and running

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1624962
Signed-off-by: Sébastien Han <seb@redhat.com>
infrastructure-playbooks/add-osd.yml [new file with mode: 0644]
infrastructure-playbooks/osd-configure.yml [deleted file]
roles/ceph-osd/tasks/main.yml

diff --git a/infrastructure-playbooks/add-osd.yml b/infrastructure-playbooks/add-osd.yml
new file mode 100644 (file)
index 0000000..4a99cd3
--- /dev/null
@@ -0,0 +1,94 @@
+---
+# This playbook is used to add a new OSD to
+# an existing cluster without the need for running
+# the ceph-docker-common or ceph-common and ceph-mon role again against all
+# of the existing monitors.
+#
+# It can run from any machine. Even if the fetch directory is not present
+# it will be created.
+#
+# Ensure that all monitors are present in the mons
+# group in your inventory so that the ceph configuration file
+# is created correctly for the new OSD(s).
+#
+# It is expected to edit your inventory file to only point to the OSD hosts
+# you want to play the playbook on. So you need to comment already deployed OSD
+# and let uncommented the new OSDs.
+#
+- hosts:
+  - mons
+  - osds
+
+  gather_facts: False
+
+  vars:
+    delegate_facts_host: True
+
+  pre_tasks:
+    - name: gather facts
+      setup:
+      when:
+        - not delegate_facts_host | bool
+
+    - name: gather and delegate facts
+      setup:
+      delegate_to: "{{ item }}"
+      delegate_facts: True
+      with_items:
+        - "{{ groups['mons'] }}"
+        - "{{ groups['osds'] }}"
+      run_once: True
+      when:
+        - delegate_facts_host | bool
+
+  roles:
+    - ceph-defaults
+    - ceph-validate
+
+- hosts: "{{ groups['mons'][0] }}"
+  gather_facts: False
+  become: True
+
+  roles:
+    - role: ceph-defaults
+    - role: ceph-fetch-keys
+
+  post_tasks:
+    - name: set_fact docker_exec_cmd if containerized_deployment
+      set_fact:
+        docker_exec_cmd: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
+      when: containerized_deployment
+
+- hosts: osds
+  gather_facts: False
+  become: True
+
+  pre_tasks:
+    # this task is needed so we can skip the openstack_config.yml include in roles/ceph-osd
+    - name: set_fact add_osd
+      set_fact:
+        add_osd: True
+
+    - name: set noup flag
+      command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd set noup"
+      delegate_to: "{{ groups['mons'][0] }}"
+      run_once: True
+      changed_when: False
+
+  roles:
+    - role: ceph-defaults
+    - role: ceph-handler
+    - role: ceph-infra
+    - role: ceph-docker-common
+      when: containerized_deployment | bool
+    - role: ceph-common
+      when: not containerized_deployment | bool
+    - role: ceph-config
+    - role: ceph-osd
+
+  post_tasks:
+    - name: unset noup flag
+      command: "{{ docker_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd unset noup"
+      delegate_to: "{{ groups['mons'][0] }}"
+      run_once: True
+      changed_when: False
\ No newline at end of file
diff --git a/infrastructure-playbooks/osd-configure.yml b/infrastructure-playbooks/osd-configure.yml
deleted file mode 100644 (file)
index b35e121..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
----
-# This playbook is used to add a new OSD to
-# an existing cluster without the need for running
-# the ceph-common or ceph-mon role again against all
-# of the existing monitors.
-#
-# Ensure that all monitors are present in the mons
-# group in your inventory so that the ceph.conf is
-# created correctly for the new OSD.
-- hosts: mons
-  become: True
-  roles:
-    - ceph-defaults
-    - ceph-fetch-keys
-
-- hosts: osds
-  become: True
-  roles:
-    - ceph-defaults
-    - ceph-osd
index 3b88fe19dcb417ed8a832c0a485d5faea3d4e971..9e098c06f878a1f2f5a48828ef3d198a7b2359e4 100644 (file)
@@ -80,6 +80,7 @@
     openstack_keys_tmp: "{{ openstack_keys_tmp|default([]) + [ { 'key': item.key, 'name': item.name, 'caps': { 'mon': item.mon_cap, 'osd': item.osd_cap|default(''), 'mds': item.mds_cap|default(''), 'mgr': item.mgr_cap|default('') } , 'mode': item.mode } ] }}"
   with_items: "{{ openstack_keys }}"
   when:
+    - not add_osd|default(False)
     - openstack_config
     - item.get('mon_cap', None) # it's enough to assume we are running an old-fashionned syntax simply by checking the presence of mon_cap since every key needs this cap
 
   set_fact:
     openstack_keys: "{{ openstack_keys_tmp }}"
   when:
+    - not add_osd|default(False)
     - openstack_keys_tmp is defined
 
 # Create the pools listed in openstack_pools
 - name: include openstack_config.yml
   include_tasks: openstack_config.yml
   when:
+    - not add_osd|default(False)
     - openstack_config
     - inventory_hostname == groups[osd_group_name] | last