Hi All,
I’ve seen some examples of using the shell module with register, but I can’t find any that allow a numerical comparison to be made on stdout. For example:
-
hosts: all
gather_facts: False
tasks: -
name: Get file count
shell: ls /tmp | wc -l
register: filecount -
name: Show a debug message
debug: msg=“{{ inventory_hostname }}”
when: filecount.stdout > 100
I am not trying to implement monitoring with Ansible It is a one-off operation and I’m trying to just print a message if the output from wc is > a number. I assume that because filecount.stdout is a string, the comparison fails, but how can I convert stdout to an integer?
- Gonzalo