Across a number of different flavors of Linux as well as AIX, I need to 
clean up our splunkforwarder space. I've tried numerous different 
approaches and am running into errors. This should be rather simple, but it 
is proving not to be.  Below is my latest iteration and some of the 
relevant errors. 

My next approach will to be straight up df -h (df -g for aix) with some awk 
stuff...also checking if the mount even exists (it doesn't necessarily on 
every system). But, I think this should be simpler to do with normal 
Ansible modules.

Any ideas on the obvious bits I'm missing?

*Relevant playbook portion:*

  tasks:
#    - name: Test for 20% disk space available
#      assert:
#        that:
#          - not {{ item.mount == '/opt/splunkforwarder' and ( 
item.size_available > (item.size_total|float * 0.6) ) }}
#      with_items: '{{ ansible_mounts }}'
#      ignore_errors: yes
#      register: disk_free

    - name: Test for 20% disk space available on {{ mountname }}
      assert:
        that: mount.size_available > mount.size_total|float * 0.2
        msg: Disk space has reached the 80% threshold
      register: disk_free

    - name: For full systems, run splunk clean
      command: "/opt/splunkforwarder/bin/splunk clean all -f"
      when: disk_free|failed

  vars:
    mountname: '/opt/splunkforwarder' 
    mount: "{{ ansible_mounts | selectattr('mount','equalto', mountname) | 
first }}"

*Errors:*
FAILED! => {"msg": "The conditional check '{ mount.size_available > 
mount.size_total|float * 0.2 }' failed. The error was: template error while 
templating string: expected token ':', got '}'. String: {% if { 
mount.size_available > mount.size_total|float * 0.2 } %} True {% else %} 
False {% endif %}\n\nThe error appears to have been in 
'/app/ansible-playbooks/splunk-clean.yml': line 18, column 7, but may\nbe 
elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n    - name: For full systems, run splunk 
clean\n      ^ here\n"}

FAILED! => {"msg": "The conditional check 'mount.size_available > 
mount.size_total|float * 0.2' failed. The error was: error while evaluating 
conditional (mount.size_available > mount.size_total|float * 0.2): {{ 
ansible_mounts | selectattr('mount','equalto', mountname) | first }}: No 
first item, sequence was empty."}



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0fe4e996-1bd9-45b0-b177-e65ed9680621%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to