From 8cc2f8f21e7fa32b28f8fc4e6a9c5b9338a3d05b Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Fri, 6 Dec 2019 16:11:51 -0500 Subject: [PATCH] ceph-validate: start with ansible version test It doesn't make sense to start validating configuration if the ansible version isn't the good one. This commit moves the check_system task as the first task in the ceph-validate role. The ansible version test tasks are moved at the top of this file. Also moving the iscsi kernel tests from check_system to check_iscsi file. Signed-off-by: Dimitri Savineau (cherry picked from commit 1a77dd7e914bc96614aae0014b39e3dbe5ff526a) --- roles/ceph-validate/tasks/check_iscsi.yml | 19 ++++++++++ roles/ceph-validate/tasks/check_system.yml | 44 ++++++---------------- roles/ceph-validate/tasks/main.yml | 6 +-- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/roles/ceph-validate/tasks/check_iscsi.yml b/roles/ceph-validate/tasks/check_iscsi.yml index 0f7ff890b..0b06afe43 100644 --- a/roles/ceph-validate/tasks/check_iscsi.yml +++ b/roles/ceph-validate/tasks/check_iscsi.yml @@ -24,3 +24,22 @@ - item.status == "present" - item.chap - " '' in client_connections | selectattr('status', 'match', 'present') | map(attribute='chap') | list" + +- name: check if iscsi gateways is target on supported distros and versions + block: + - name: fail on unsupported distribution for iscsi gateways + fail: + msg: "iSCSI gateways can only be deployed on Red Hat Enterprise Linux, CentOS or Fedora" + when: ansible_distribution not in ['RedHat', 'CentOS', 'Fedora'] + + - name: fail on unsupported distribution version for iscsi gateways + command: 'grep -q {{ item }}=m {% if is_atomic|bool %}/usr/lib/ostree-boot{% else %}/boot{% endif %}/config-{{ ansible_kernel }}' + register: iscsi_kernel + changed_when: false + failed_when: iscsi_kernel.rc != 0 + loop: + - CONFIG_TARGET_CORE + - CONFIG_TCM_USER2 + - CONFIG_ISCSI_TARGET + when: ansible_distribution in ['RedHat', 'CentOS'] + when: iscsi_gw_group_name in group_names diff --git a/roles/ceph-validate/tasks/check_system.yml b/roles/ceph-validate/tasks/check_system.yml index 9863188a0..44b1c6dc2 100644 --- a/roles/ceph-validate/tasks/check_system.yml +++ b/roles/ceph-validate/tasks/check_system.yml @@ -1,4 +1,16 @@ --- +- name: fail on unsupported ansible version (1.X) + fail: + msg: "Ansible version must be >= 2.8.x, please update!" + when: ansible_version.major|int < 2 + +- name: fail on unsupported ansible version + fail: + msg: "Ansible version must be 2.8!" + when: + - ansible_version.major|int == 2 + - ansible_version.minor|int != 8 + - name: fail on unsupported system fail: msg: "System not supported {{ ansible_system }}" @@ -53,39 +65,7 @@ - ansible_distribution == 'openSUSE Leap' - ansible_distribution_major_version != '15' -- name: fail on unsupported ansible version (1.X) - fail: - msg: "Ansible version must be >= 2.8.x, please update!" - when: ansible_version.major|int < 2 - -- name: fail on unsupported ansible version - fail: - msg: "Ansible version must be 2.8!" - when: - - ansible_version.major|int == 2 - - ansible_version.minor|int != 8 - - name: fail if systemd is not present fail: msg: "Systemd must be present" when: ansible_service_mgr != 'systemd' - -- name: check if iscsi gateways is target on supported distros and versions - block: - - name: fail on unsupported distribution for iscsi gateways - fail: - msg: "iSCSI gateways can only be deployed on Red Hat Enterprise Linux, CentOS or Fedora" - when: ansible_distribution not in ['RedHat', 'CentOS', 'Fedora'] - - - name: fail on unsupported distribution version for iscsi gateways - command: 'grep -q {{ item }}=m {% if is_atomic|bool %}/usr/lib/ostree-boot{% else %}/boot{% endif %}/config-{{ ansible_kernel }}' - register: iscsi_kernel - changed_when: false - failed_when: iscsi_kernel.rc != 0 - loop: - - CONFIG_TARGET_CORE - - CONFIG_TCM_USER2 - - CONFIG_ISCSI_TARGET - when: ansible_distribution in ['RedHat', 'CentOS'] - when: iscsi_gw_group_name in group_names - diff --git a/roles/ceph-validate/tasks/main.yml b/roles/ceph-validate/tasks/main.yml index 757cd1b2c..8424eb562 100644 --- a/roles/ceph-validate/tasks/main.yml +++ b/roles/ceph-validate/tasks/main.yml @@ -1,4 +1,7 @@ --- +- name: include check_system.yml + include_tasks: check_system.yml + - name: validate repository variables in non-containerized scenario when: not containerized_deployment | bool block: @@ -134,9 +137,6 @@ - osd_objectstore == 'filestore' - osd_group_name in group_names -- name: include check_system.yml - include_tasks: check_system.yml - - name: include check_devices.yml include_tasks: check_devices.yml when: