--- - hosts: test-servers user: gamesroot become: true become_user: root gather_facts: yes vars: mountpoint: "{{m}}"
tasks: - shell: df -h "{{mountpoint}}" | tail -n 1 | awk {'print $5 '} | sed 's/%//g' register: test - shell: rm -rf /tmp/disk.txt; touch /tmp/disk.txt delegate_to: localhost - shell: echo "{{ inventory_hostname }}" register: op - debug: msg: - "{{test.stdout}}" - "{{ op.stdout }}" - name: add lines lineinfile: dest: /tmp/disk.txt line: "{{ m }} HAS REACHED {{ test.stdout }} % ON {{ op.stdout }}, KINDLY CHECK !!!" state: present delegate_to: 127.0.0.1 register: msgtxt with_items: - "{{ test.stdout }}" - "{{ op.stdout }}" when: test.stdout|int > 5 - local_action: copy content= "{{ msgtxt.results }}" dest=/tmp/disk2.txt I have create this , everything is working fine.. Now i am giving mountpoint at the run time. Now if i want to define more then one 1 mountpoint, how can it will compete the full loop for one mount point and next it will jump on second mountpoint. e.g. vars: mountpoint: - / - /home - /backup - /dev On Friday, March 9, 2018 at 6:52:58 PM UTC+5:30, Thomas Hikade wrote: > > In addition you might like to print out the name of your FS which is too > big. For that you need the names again in the last debug loop. > You could fix that like this, using advanced looping statement > "with_together" (Ansible Loops > <https://docs.ansible.com/ansible/latest/playbooks_loops.html#looping-over-parallel-sets-of-data> > ) > > vars: > filesystems: > - / > - /tmp > > size_too_big: "20" > > tasks: > > ... > > - name: Size is big v2 > debug: > msg: "{{ item.1 }} is too big! size={{ item.0 }} " > when: item.0 > size_too_big > with_together: > - "{{ test.results|map(attribute='stdout')|list }}" > - "{{ filesystems }}" > > This will produce the following output: > > TASK [Size is big v2] > ********************************************************** > ok: [demobox] => (item=[u'37', u'/']) => { > "item": [ > "37", > "/" > ], > "msg": "/ is too big! size=37 " > } > ok: [demobox] => (item=[u'37', u'/tmp']) => { > "item": [ > "37", > "/tmp" > ], > "msg": "/tmp is too big! size=37 " > } > > > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a86c7db9-3c50-46c9-8da8-581f6ddade7e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.