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 }}"
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