Skip to content

Commit

Permalink
FIx error in task "Make RAID0 device" on Ansible 2.9
Browse files Browse the repository at this point in the history
Starting Ansible 2.9, task "Make RAID0 device" (only active when using SSD disks on Google Cloud) can fail with this error:

```
The conditional check 'localssd_all_devices_count > 0' failed. The error was: Unexpected templating type error occurred on ({% if localssd_all_devices_count > 0 %} True {% else %} False {% endif %}): '>' not supported between instances of 'AnsibleUnsafeText' and 'int'
```

This rather ad-hoc fix coerces the "unsafe text" into an integer.
There might be more issues like this with Ansible 2.9, if anything
that's inputed from external processes is marked as "unsafe" and needs
to somehow be washed before using in conditionals and templates.

Thanks to X. Y. Han for reporting the issue and testing the fix!
  • Loading branch information
riccardomurri committed Jan 30, 2020
1 parent 3e3e759 commit 98ab269
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@
{{ localssd_all_devices|join(" ") }}
args:
creates: '/dev/md/google-local-ssd'
when: 'localssd_all_devices_count > 0'
when: 'localssd_all_devices_count|int > 0'

- name: Format RAID0 device
filesystem:
dev: '/dev/md/google-local-ssd'
fstype: ext4
opts: '-m 0 -L /srv/google-local-ssd'
when: 'localssd_all_devices_count > 0'
when: 'localssd_all_devices_count|int > 0'

- name: Make mountpoint
file:
dest: '/srv/google-local-ssd'
state: directory
when: 'localssd_all_devices_count > 0'
when: 'localssd_all_devices_count|int > 0'

- name: Mount local SSD filesystem
mount:
Expand All @@ -63,4 +63,4 @@
state: mounted
fstype: ext4
opts: 'rw,nofail'
when: 'localssd_all_devices_count > 0'
when: 'localssd_all_devices_count|int > 0'

0 comments on commit 98ab269

Please sign in to comment.