]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
defaults: fix rgw_hostname v3.1.0rc21
authorSébastien Han <seb@redhat.com>
Tue, 21 Aug 2018 18:50:31 +0000 (20:50 +0200)
committerSébastien Han <seb@redhat.com>
Wed, 22 Aug 2018 17:57:59 +0000 (19:57 +0200)
A couple if things were wrong in the initial commit:

* ceph_release_num[ceph_release] >= ceph_release_num['luminous'] will
never work since the ceph_release fact is set in the roles after. So
either ceph-common or ceph-docker-common set it

* we can easily re-use the initial command to check if a cluster is
running, it's more elegant than running it twice.

* set the fact rgw_hostname on rgw nodes only

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1618678
Signed-off-by: Sébastien Han <seb@redhat.com>
(cherry picked from commit 6d7fa99ff74b3ec25d1a6010b1ddb25e00c123be)

roles/ceph-common/tasks/facts_mon_fsid.yml
roles/ceph-common/tasks/main.yml
roles/ceph-defaults/handlers/main.yml
roles/ceph-defaults/tasks/facts.yml

index f1038426e915e9692738de596ea0bac86a30117a..8b6bc2a4eab0b6afa3ece2bf69fdf854d9e17a1d 100644 (file)
@@ -9,7 +9,6 @@
     msg: "/var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring not found"
   when:
     - not initial_mon_keyring.stat.exists
-    - ceph_current_fsid.rc == 0
 
 - name: get existing initial mon keyring if it already exists but not monitor_keyring.conf in {{ fetch_directory }}
   shell: |
@@ -17,7 +16,6 @@
   register: monitor_keyring
   when:
     - not monitor_keyring_conf.stat.exists
-    - ceph_current_fsid.rc == 0
 
 - name: test existing initial mon keyring
   command: ceph --connect-timeout 3 --cluster {{ cluster }} --keyring /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring -n mon. fsid
index 6eea5b546e0257893f68760b47d8d093387b8c09..f49b1903a54c86e1123fd1ef2581a0ddbb31c09a 100644 (file)
@@ -95,9 +95,9 @@
   run_once: true
   when:
     - cephx
-    - not monitor_keyring_conf.stat.exists
-    - ceph_current_fsid.rc == 0
     - mon_group_name in group_names
+    - not monitor_keyring_conf.stat.exists
+    - ceph_current_status.fsid is defined
 
 - name: include create_rbd_client_dir.yml
   include: create_rbd_client_dir.yml
index 11e1a16de5cd11f1f9c51d0320c23bd705a3361d..691a9693ebe0a7ac47aae25714ba1fbd55a12b79 100644 (file)
@@ -89,7 +89,7 @@
     # We do not want to run these checks on initial deployment (`socket_osd_container.results[n].rc == 0`)
     # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified
     - osd_socket_stat.rc == 0
-    - ceph_current_fsid.rc == 0
+    - ceph_current_status.fsid is defined
     - handler_health_osd_check
     - hostvars[item]['_osd_handler_called'] | default(False)
   with_items: "{{ groups[osd_group_name] }}"
index d4f347677a1236d19343d23bad7c3f4907297c6e..7c8dda9713176b25e4fb3a6a59559d068a237ade 100644 (file)
 # because it blindly picks a mon, which may be down because
 # of the rolling update
 - name: is ceph running already?
-  command: "timeout 5 {{ docker_exec_cmd }} ceph --cluster {{ cluster }} fsid"
+  command: "timeout 5 {{ docker_exec_cmd }} ceph --cluster {{ cluster }} -s -f json"
   changed_when: false
   failed_when: false
   check_mode: no
-  register: ceph_current_fsid
+  register: ceph_current_status
   run_once: true
   delegate_to: "{{ groups[mon_group_name][0] }}"
   when:
@@ -54,9 +54,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_fsid rc 1
+- name: set_fact ceph_current_status rc 1
   set_fact:
-    ceph_current_fsid:
+    ceph_current_status:
       rc: 1
   when:
     - rolling_update or groups.get(mon_group_name, []) | length == 0
   when:
     - (cephx or generate_fsid)
 
-- name: set_fact fsid ceph_current_fsid.stdout
+- name: set_fact ceph_current_status (convert to json)
   set_fact:
-    fsid: "{{ ceph_current_fsid.stdout }}"
+    ceph_current_status: "{{ ceph_current_status.stdout | from_json }}"
   when:
-    - ceph_current_fsid.get('rc', 1) == 0
+    - not rolling_update
+    - 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
 
 # Set ceph_release to ceph_stable by default
 - name: set_fact ceph_release ceph_stable_release
@@ -91,7 +98,7 @@
   become: false
   when:
     - generate_fsid
-    - ceph_current_fsid.rc != 0
+    - ceph_current_status.fsid is undefined
 
 - name: reuse cluster fsid when cluster is already running
   local_action:
     creates: "{{ fetch_directory }}/ceph_cluster_uuid.conf"
   become: false
   when:
-    - ceph_current_fsid.get('rc', 1) == 0
+    - ceph_current_status.fsid is defined
 
 - name: read cluster fsid if it already exists
   local_action:
     - containerized_deployment
     - ceph_docker_image | search("rhceph")
 
-- block:
-    - name: get current cluster status (if already running)
-      command: "{{ docker_exec_cmd }} ceph --cluster {{ cluster }} -s -f json"
-      changed_when: false
-      failed_when: false
-      check_mode: no
-      run_once: true
-      delegate_to: "{{ groups[mon_group_name][0] }}"
-      when:
-        - not rolling_update
-        - groups.get(mon_group_name, []) | length > 0
-      register: ceph_current_status
-
-    - name: set_fact ceph_current_status (convert to json)
-      set_fact:
-        ceph_current_status: "{{ ceph_current_status.stdout | from_json }}"
-
-    - name: set_fact rgw_hostname
-      set_fact:
-        rgw_hostname: "{% for key in ceph_current_status['servicemap']['services']['rgw']['daemons'].keys() %}{% if key == ansible_fqdn %}{{ key }}{% endif %}{% endfor %}"
-      when: ceph_current_status['servicemap']['services']['rgw'] is defined
-  when:
-    - ceph_current_fsid.get('rc', 1) == 0
-    - inventory_hostname in groups.get(rgw_group_name, [])
-    # no servicemap before luminous
-    - ceph_release_num[ceph_release] >= ceph_release_num['luminous']
+- name: set_fact rgw_hostname - fqdn
+  set_fact:
+    rgw_hostname: "{% for key in ceph_current_status['servicemap']['services']['rgw']['daemons'].keys() %}{% if key == ansible_fqdn %}{{ key }}{% endif %}{% endfor %}"
+  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 # that's the way to cover ceph_release_num[ceph_release] >= ceph_release_num['luminous']
     - ansible_hostname != ansible_fqdn
 
-- name: set_fact rgw_hostname
+- name: set_fact rgw_hostname - no fqdn
   set_fact:
     rgw_hostname: "{{ ansible_hostname }}"
   when:
+    - inventory_hostname in groups.get(rgw_group_name, []) or inventory_hostname in groups.get(nfs_group_name, [])
     - rgw_hostname is undefined
\ No newline at end of file