From 72cae542da5f78f0043e35f80897115d81df6329 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Thu, 1 Nov 2018 16:03:16 +0100 Subject: [PATCH] lint: Don't compare to empty string MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit description = 'Use `when: var` rather than `when: var != ""` (or ' \ 'conversely `when: not var` rather than `when: var == ""`)' Signed-off-by: Sébastien Han --- roles/ceph-client/tasks/create_users_keys.yml | 6 +++--- roles/ceph-iscsi-gw/tasks/common.yml | 2 +- roles/ceph-mds/tasks/create_mds_filesystems.yml | 2 +- roles/ceph-osd/tasks/openstack_config.yml | 6 +++--- roles/ceph-rgw/tasks/main.yml | 2 +- roles/ceph-validate/tasks/check_iscsi.yml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/roles/ceph-client/tasks/create_users_keys.yml b/roles/ceph-client/tasks/create_users_keys.yml index b98f4bb88..ccc4978f7 100644 --- a/roles/ceph-client/tasks/create_users_keys.yml +++ b/roles/ceph-client/tasks/create_users_keys.yml @@ -104,9 +104,9 @@ osd pool create {{ item.0.name }} {{ item.0.pg_num }} {{ item.0.pgp_num }} - {{ 'replicated_rule' if item.0.rule_name | default('replicated_rule') == '' else item.0.rule_name | default('replicated_rule') }} + {{ 'replicated_rule' if not item.0.rule_name | default('replicated_rule') else item.0.rule_name | default('replicated_rule') }} {{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }} - {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile != '' %} + {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile %} {{ item.0.erasure_profile }} {%- endif %} {{ item.0.expected_num_objects | default('') }} @@ -128,7 +128,7 @@ changed_when: false when: - pools | length > 0 - - item.size | default ("") != "" + - item.size | default ("") - name: get client cephx keys copy: diff --git a/roles/ceph-iscsi-gw/tasks/common.yml b/roles/ceph-iscsi-gw/tasks/common.yml index 2d672c260..d187ad1d0 100644 --- a/roles/ceph-iscsi-gw/tasks/common.yml +++ b/roles/ceph-iscsi-gw/tasks/common.yml @@ -51,4 +51,4 @@ delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false when: - - rbd_pool_size | default ("") != "" + - rbd_pool_size | default ("") diff --git a/roles/ceph-mds/tasks/create_mds_filesystems.yml b/roles/ceph-mds/tasks/create_mds_filesystems.yml index 787fbe2bd..733952aa4 100644 --- a/roles/ceph-mds/tasks/create_mds_filesystems.yml +++ b/roles/ceph-mds/tasks/create_mds_filesystems.yml @@ -13,7 +13,7 @@ with_items: "{{ cephfs_pools | unique }}" delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false - when: item.size | default ("") != "" + when: item.size | default ("") - name: check if ceph filesystem already exists command: "{{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} fs get {{ cephfs }}" diff --git a/roles/ceph-osd/tasks/openstack_config.yml b/roles/ceph-osd/tasks/openstack_config.yml index a4312068e..4b4422f46 100644 --- a/roles/ceph-osd/tasks/openstack_config.yml +++ b/roles/ceph-osd/tasks/openstack_config.yml @@ -27,9 +27,9 @@ osd pool create {{ item.0.name }} {{ item.0.pg_num }} {{ item.0.pgp_num | default(item.0.pg_num) }} - {{ 'replicated_rule' if item.0.rule_name | default('replicated_rule') == '' else item.0.rule_name | default('replicated_rule') }} + {{ 'replicated_rule' if not item.0.rule_name | default('replicated_rule') else item.0.rule_name | default('replicated_rule') }} {{ 1 if item.0.type|default(1) == 'replicated' else 3 if item.0.type|default(1) == 'erasure' else item.0.type|default(1) }} - {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile != '' %} + {%- if (item.0.type | default("1") == '3' or item.0.type | default("1") == 'erasure') and item.0.erasure_profile %} {{ item.0.erasure_profile }} {%- endif %} {{ item.0.expected_num_objects | default('') }} @@ -48,7 +48,7 @@ with_items: "{{ openstack_pools | unique }}" delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false - when: item.size | default ("") != "" + when: item.size | default ("") - name: assign application to pool(s) command: "{{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} osd pool application enable {{ item.name }} {{ item.application }}" diff --git a/roles/ceph-rgw/tasks/main.yml b/roles/ceph-rgw/tasks/main.yml index 729e4cb93..34cbce715 100644 --- a/roles/ceph-rgw/tasks/main.yml +++ b/roles/ceph-rgw/tasks/main.yml @@ -39,4 +39,4 @@ delegate_to: "{{ groups[mon_group_name][0] }}" changed_when: false run_once: true - when: item.size | default ("") != "" + when: item.size | default ("") diff --git a/roles/ceph-validate/tasks/check_iscsi.yml b/roles/ceph-validate/tasks/check_iscsi.yml index 6c6a7670c..09abe5061 100644 --- a/roles/ceph-validate/tasks/check_iscsi.yml +++ b/roles/ceph-validate/tasks/check_iscsi.yml @@ -6,5 +6,5 @@ when: - item.status is defined - item.status == "present" - - item.chap != '' + - item.chap - " '' in client_connections | selectattr('status', 'match', 'present') | map(attribute='chap') | list" -- 2.39.5