Hello,

Will someone please help me understand why this is not work?

Thanks!

---
- hosts: all
  become: yes
  become_method: sudo
  become_user: root

  vars:

    stat_files:
      - name: stat_var
        stat_path: "/etc/resolv.conf"

  tasks:
    - name: "Verify file copy destination"
      stat:
        path: "{{ item.stat_path }}"
      register: "{{ item.name }}"
      with_items:
        - "{{ stat_files }}"
    - debug:
        var: "Found it!"
      when: stat_var.stat.exists

--------------------------------------------------------------------------------------------------------------------


k: [hostname] => (item={u'stat_path': u'/etc/resolv.conf', u'name': 
u'stat_var'}) => {
    "changed": false,
    "item": {
        "name": "stat_var",
        "stat_path": "/etc/resolv.conf"
    },
    "stat": {
        "atime": 1537249786.7223341,
        "attr_flags": "",
        "attributes": [],
        "block_size": 4096,
        "blocks": 8,
        "charset": "us-ascii",
        "checksum": "2f01daec7b7a510f0b791c94ee345845f211be18",
        "ctime": 1536990466.4755569,
        "dev": 64768,
        "device_type": 0,
        "executable": false,
        "exists": true,

--------------------------------------------------------------------------------------------------------------------

MSG:

The conditional check 'stat_var.stat.exists' failed. The error was: error 
while evaluating conditional (stat_var.stat.exists): 'stat_var' is undefined

-- 
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/42e82cf6-54e1-41c2-9743-4fa493149bee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to