diff --git a/roles/ceph-common/handlers/main.yml b/roles/ceph-common/handlers/main.yml index 62422a066..ca7102645 100644 --- a/roles/ceph-common/handlers/main.yml +++ b/roles/ceph-common/handlers/main.yml @@ -8,8 +8,8 @@ when: socket.rc == 0 and ansible_distribution != 'Ubuntu' and - mon_group_name in group_names and not - is_ceph_infernalis + mon_group_name in group_names and + is_before_infernalis - name: restart ceph mons with systemd service: @@ -19,7 +19,7 @@ socket.rc == 0 and ansible_distribution != 'Ubuntu' and mon_group_name in group_names and - is_ceph_infernalis + is_after_hammer - name: restart ceph mons on ubuntu command: initctl restart ceph-mon cluster={{ cluster }} id={{ monitor_name }} @@ -34,7 +34,7 @@ socket.rc == 0 and ansible_distribution != 'Ubuntu' and osd_group_name in group_names and - not is_ceph_infernalis + is_before_infernalis # This does not just restart OSDs but everything else too. Unfortunately # at this time the ansible role does not have an OSD id list to use @@ -47,7 +47,7 @@ socket.rc == 0 and ansible_distribution != 'Ubuntu' and osd_group_name in group_names and - is_ceph_infernalis + is_after_hammer - name: restart ceph osds on ubuntu shell: | @@ -99,7 +99,7 @@ socketrgw.rc == 0 and ansible_distribution != 'Ubuntu' and rgw_group_name in group_names and - not is_ceph_infernalis + is_before_infernalis - name: restart ceph rgws on red hat command: /etc/init.d/ceph-radosgw restart @@ -107,7 +107,7 @@ socketrgw.rc == 0 and ansible_os_family == 'RedHat' and rgw_group_name in group_names and - not is_ceph_infernalis + is_before_infernalis - name: restart ceph rgws with systemd service: @@ -117,7 +117,7 @@ socketrgw.rc == 0 and ansible_distribution != 'Ubuntu' and rgw_group_name in group_names and - is_ceph_infernalis + is_after_hammer - name: restart apache2 service: diff --git a/roles/ceph-common/tasks/facts.yml b/roles/ceph-common/tasks/facts.yml new file mode 100644 index 000000000..240305b55 --- /dev/null +++ b/roles/ceph-common/tasks/facts.yml @@ -0,0 +1,51 @@ +--- + +- name: get ceph version + command: ceph --version + changed_when: false + register: ceph_version + +- set_fact: + ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}" + +# NOTE (leseb/jsaintrocc): You are supposed to quote variables +# that follow colons to avoid confusion with dicts but this +# causes issues with the boolean, so we keep this syntax styling... +# is_before facts +- set_fact: + is_before_hammer={{ ceph_version | version_compare('0.94.0', '<') }} + +- set_fact: + is_before_infernalis={{ ceph_version | version_compare('9.0.0', '<') }} + +- set_fact: + is_before_jewel={{ ceph_version | version_compare('10.0.0', '<') }} + +- set_fact: + is_before_kraken={{ ceph_version | version_compare('11.0.0', '<') }} + +# is_after facts +- set_fact: + is_after_hammer={{ ceph_version | version_compare('0.95.0', '>') }} + +- set_fact: + is_after_infernalis={{ ceph_version | version_compare('9.4.0', '>') }} + +- set_fact: + is_after_jewel={{ ceph_version | version_compare('10.4.0', '>') }} + +- set_fact: + is_after_kraken={{ ceph_version | version_compare('11.4.0', '>') }} + +# is_version facts +- set_fact: + is_hammer={{ ceph_version | version_compare('0.94.0', '>=') | version_compare('9.0.0', '<') }} + +- set_fact: + is_infernalis={{ ceph_version | version_compare('9.0.0', '>=') and ceph_version | version_compare('10.0.0', '<') }} + +- set_fact: + is_jewel={{ ceph_version | version_compare('10.0.0', '>=') and ceph_version | version_compare('11.0.0', '<') }} + +- set_fact: + is_kraken={{ ceph_version | version_compare('11.0.0', '>=') and ceph_version | version_compare('12.0.0', '<') }} diff --git a/roles/ceph-common/tasks/main.yml b/roles/ceph-common/tasks/main.yml index b297c57cb..3513e63ca 100644 --- a/roles/ceph-common/tasks/main.yml +++ b/roles/ceph-common/tasks/main.yml @@ -64,95 +64,83 @@ tags: - package-install -- name: get ceph version - command: ceph --version - changed_when: false - register: ceph_version - -- set_fact: - ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}" - -# NOTE (leseb/jsaintrocc): Your supposed to qoute variables -# that follow colons to avoid confusion with dicts but this -# causes issues with the boolean, so we keep this syntax styling... -- set_fact: - is_ceph_infernalis={{ ceph_version | version_compare('9.2.0', '>=') }} +- include: facts.yml - set_fact: dir_owner: ceph dir_group: ceph dir_mode: "0755" - when: is_ceph_infernalis + when: is_after_hammer - set_fact: dir_owner: root dir_group: root dir_mode: "0755" - when: not is_ceph_infernalis + when: is_before_infernalis - set_fact: key_owner: root key_group: root key_mode: "0600" - when: not is_ceph_infernalis + when: is_before_infernalis - set_fact: key_owner: ceph key_group: ceph key_mode: "0600" - when: is_ceph_infernalis + when: is_after_hammer - set_fact: activate_file_owner: ceph activate_file_group: ceph activate_file_mode: "0644" - when: is_ceph_infernalis + when: is_after_hammer - set_fact: activate_file_owner: root activate_file_group: root activate_file_mode: "0644" - when: not is_ceph_infernalis + when: is_before_infernalis - set_fact: rbd_client_directory_owner: root when: - not is_ceph_infernalis and + is_before_infernalis and (rbd_client_directory_owner is not defined or not rbd_client_directory_owner) - set_fact: rbd_client_directory_owner: ceph when: - is_ceph_infernalis and + is_after_hammer and (rbd_client_directory_owner is not defined or not rbd_client_directory_owner) - set_fact: rbd_client_directory_group: root when: - not is_ceph_infernalis and + is_before_infernalis and (rbd_client_directory_group is not defined or not rbd_client_directory_group) - set_fact: rbd_client_directory_group: ceph when: - is_ceph_infernalis and + is_after_hammer and (rbd_client_directory_group is not defined or not rbd_client_directory_group) - set_fact: rbd_client_directory_mode: "1777" when: - not is_ceph_infernalis and + is_before_infernalis and (rbd_client_directory_mode is not defined or not rbd_client_directory_mode) - set_fact: rbd_client_directory_mode: "0770" when: - is_ceph_infernalis and + is_after_hammer and (rbd_client_directory_mode is not defined or not rbd_client_directory_mode) diff --git a/roles/ceph-mds/tasks/pre_requisite.yml b/roles/ceph-mds/tasks/pre_requisite.yml index 813d5a306..be9c0478e 100644 --- a/roles/ceph-mds/tasks/pre_requisite.yml +++ b/roles/ceph-mds/tasks/pre_requisite.yml @@ -87,7 +87,7 @@ failed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer - name: start and add that the metadata service to the init sequence (ubuntu) command: initctl emit ceph-mds cluster={{ cluster }} id={{ mds_name }} @@ -104,7 +104,7 @@ changed_when: false when: ansible_distribution != "Ubuntu" and - not is_ceph_infernalis + is_before_infernalis - name: start and add that the metadata service to the init sequence (for or after infernalis) service: @@ -114,4 +114,4 @@ changed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer diff --git a/roles/ceph-mon/tasks/deploy_monitors.yml b/roles/ceph-mon/tasks/deploy_monitors.yml index 884dcdc93..9b0ad0834 100644 --- a/roles/ceph-mon/tasks/deploy_monitors.yml +++ b/roles/ceph-mon/tasks/deploy_monitors.yml @@ -50,7 +50,7 @@ creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring when: cephx and - is_ceph_infernalis + is_after_hammer - name: ceph monitor mkfs without keyring (for or after infernalis release) command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }} @@ -58,7 +58,7 @@ creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db when: not cephx and - is_ceph_infernalis + is_after_hammer - name: ceph monitor mkfs with keyring (before infernalis release) command: ceph-mon --mkfs -i {{ monitor_name }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ monitor_name }} @@ -66,7 +66,7 @@ creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring when: cephx and - not is_ceph_infernalis + is_before_infernalis - name: ceph monitor mkfs without keyring (before infernalis release) command: ceph-mon --mkfs -i {{ monitor_name }} --fsid {{ fsid }} @@ -74,4 +74,4 @@ creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db when: not cephx and - not is_ceph_infernalis + is_before_infernalis diff --git a/roles/ceph-mon/tasks/start_monitor.yml b/roles/ceph-mon/tasks/start_monitor.yml index 529a2591f..ce9225dba 100644 --- a/roles/ceph-mon/tasks/start_monitor.yml +++ b/roles/ceph-mon/tasks/start_monitor.yml @@ -25,7 +25,7 @@ changed_when: false when: ansible_distribution != "Ubuntu" and - not is_ceph_infernalis + is_before_infernalis - name: enable systemd unit file for mon instance (for or after infernalis) file: @@ -36,7 +36,7 @@ failed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer - name: start and add that the monitor service to the init sequence (for or after infernalis) service: @@ -46,7 +46,7 @@ changed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer - name: collect admin and bootstrap keys command: ceph-create-keys --cluster {{ cluster }} --id {{ monitor_name }} diff --git a/roles/ceph-osd/tasks/activate_osds.yml b/roles/ceph-osd/tasks/activate_osds.yml index 47e488cfc..9473b2e7a 100644 --- a/roles/ceph-osd/tasks/activate_osds.yml +++ b/roles/ceph-osd/tasks/activate_osds.yml @@ -57,7 +57,7 @@ ansible_selinux != false and ansible_selinux['status'] == 'enabled' and ansible_selinux['config_mode'] != 'disabled' and - not is_ceph_infernalis + is_before_infernalis - name: start and add that the osd service(s) to the init sequence (before infernalis) service: @@ -66,7 +66,7 @@ enabled: yes when: ansible_distribution != "Ubuntu" and - not is_ceph_infernalis + is_before_infernalis - name: get osd id (for or after infernalis) shell: "ls /var/lib/ceph/osd/ |grep -oh '[0-9]*'" @@ -75,7 +75,7 @@ register: osd_id when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer - name: enable osd service instance(s) (for or after infernalis) file: @@ -86,7 +86,7 @@ failed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer - name: start and add that the osd service(s) to the init sequence (for or after infernalis) service: @@ -97,4 +97,4 @@ changed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer diff --git a/roles/ceph-rbd-mirror/tasks/start_rbd_mirror.yml b/roles/ceph-rbd-mirror/tasks/start_rbd_mirror.yml index cf2c47fb5..92a47ccc4 100644 --- a/roles/ceph-rbd-mirror/tasks/start_rbd_mirror.yml +++ b/roles/ceph-rbd-mirror/tasks/start_rbd_mirror.yml @@ -12,7 +12,7 @@ changed_when: false when: ansible_distribution != "Ubuntu" and - not is_ceph_infernalis + is_before_infernalis - name: enable systemd unit file for the rbd mirror service (for or after infernalis) file: @@ -23,7 +23,7 @@ failed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer - name: start and add that the rbd mirror service to the init sequence (for or after infernalis) service: @@ -33,4 +33,4 @@ changed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer diff --git a/roles/ceph-rgw/tasks/start_radosgw.yml b/roles/ceph-rgw/tasks/start_radosgw.yml index 72b402fa6..c0689ff3b 100644 --- a/roles/ceph-rgw/tasks/start_radosgw.yml +++ b/roles/ceph-rgw/tasks/start_radosgw.yml @@ -25,7 +25,7 @@ enabled: yes when: ansible_os_family == 'RedHat' and - not is_ceph_infernalis + is_before_infernalis - name: enable systemd unit file for rgw instance (for or after infernalis) file: @@ -36,7 +36,7 @@ failed_when: false when: ansible_distribution != "Ubuntu" and - is_ceph_infernalis + is_after_hammer - name: start rgw on red hat (after infernalis) service: @@ -45,4 +45,4 @@ enabled: yes when: ansible_os_family == 'RedHat' and - is_ceph_infernalis + is_after_hammer