Hi all,

I have a list of files where I need to check existence and fail if one doesn't 
exist.

I'd expect the fail module to *just* output the defined message when the 
condition is true
but instead the complete item is printed.

Is there a way to make the output less verbose (but keep msg)?

Thanks,

        Uwe

#### playbook ####
---
- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - set_fact:
        files:
          - /tmp/test1
          - /tmp/test2

    - stat:
        path: '{{ item }}'
      with_items: '{{ files }}'
      register: r

    - fail:
        msg: '{{ item["invocation"]["module_args"]["path"] }} not found'
      when: not item.stat.exists
      with_items: ' {{ r.results }}'
      loop_control:
        label: '{{ item["invocation"]["module_args"]["path"] }}'
##################

##### output #####
PLAY [localhost] 
**********************************************************************************

TASK [set_fact] 
***********************************************************************************
ok: [localhost]

TASK [stat] 
***************************************************************************************
ok: [localhost] => (item=/tmp/test1)
ok: [localhost] => (item=/tmp/test2)

TASK [fail] 
***************************************************************************************
skipping: [localhost] => (item=/tmp/test1)
failed: [localhost] (item=/tmp/test2) => {"changed": false, "item": {"changed": 
false, "failed": false, "invocation":
{"module_args": {"checksum_algorithm": "sha1", "follow": false, 
"get_attributes": true, "get_checksum": true, "get_md5": null,
"get_mime": true, "path": "/tmp/test2"}}, "item": "/tmp/test2", "stat": 
{"exists": false}}, "msg": "/tmp/test2 not found"}
        to retry, use: --limit @/tmp/test.retry

PLAY RECAP 
****************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1
##################

-- 
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/5abac1aa-edb4-f683-4b81-b62d5dd670f4%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to