Skip to content

Commit 23e840f

Browse files
fmounttosky
authored andcommitted
ceph_migrate: rewrite a variable to avoid linting issues
This change does not change the behavior of the code, but it works with newer ansible-lint. The version of ansible-lint was ancient and now it needs to be updated due to some changes in ansible itself which led to: ModuleNotFoundError: No module named 'ansible.parsing.yaml.constructor' The update led to a new error when parsing the definition of the pct variable, namely: tests/roles/ceph_migrate/tasks/ceph_validate.yaml:42:10: jinja[invalid][/]: Error rendering template: float division by zero Actual code change by Francesco Pantano. Commit message by Luigi Toscano.
1 parent bcf0eb0 commit 23e840f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/roles/ceph_migrate/tasks/ceph_validate.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
vars:
4040
num_up_osds: "{{ ceph | community.general.json_query('osdmap.num_up_osds') | default(0) }}"
4141
num_osds: "{{ ceph | community.general.json_query('osdmap.num_osds') | default(1) }}"
42-
pct: "{{ (num_up_osds | float | default(0.0) / num_osds | float | default(1.0)) * 100 }}"
42+
pct: >-
43+
{%- set up_osds = (num_up_osds | float | default(0.0)) -%}
44+
{%- set total_osds = (num_osds | float | default(1.0)) -%}
45+
{{ (up_osds / total_osds * 100) if total_osds > 0 else 0 }}
4346
block:
4447
- name: OSDMap
4548
ansible.builtin.debug:

0 commit comments

Comments
 (0)