# Error "The conditional check 'file\_stat.stat.exists == False' failed. The error was: error while evaluating conditional (file\_stat.stat.exists == False): 'file\_stat' is undefined

**URL:** <https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556>\
**Category:** Ansible Project\
**Created:** [January 17, 2023, 6:13pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556 "2023-01-17T18:13:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Franco](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Franco](https://forum.ansible.com/u/Matthew_Franco)\
**Post date:** [January 17, 2023, 6:13pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/1 "2023-01-17T18:13:51Z")

</div>

with what I am doing shouldn’t file\_stat get registered as part of the loop? What am I doing wrong?

I get the following error when trying to run my script below:

PLAY [Download and install RPMs from a local directory] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [Create directory if it does not exist] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [Download RPMs] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: “The conditional check ‘file\_stat.stat.exists == False’ failed. The error was: error while evaluating conditional (file\_stat.stat.exists == False): ‘file\_stat’ is undefined\n\nThe error appears to be in ‘/home/pvs/Build/playbooks/DownloadRPM.yml’: line 17, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n mode: 0755\n - name: Download RPMs\n ^ here\n”}

My script:

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [January 17, 2023, 6:26pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/2 "2023-01-17T18:26:05Z")

</div>

Does your “register: file\_stat” needs to be moved up to the file task?

Walter

---

<div class="post-metadata">

**Author:** ![Matthew\_Franco](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Franco](https://forum.ansible.com/u/Matthew_Franco)\
**Post date:** [January 18, 2023, 5:37pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/3 "2023-01-18T17:37:23Z")

</div>

I added the following task verifying file exists, and show the results right below it, but I do not know how to reference the results using a "when: " for when the file does not exist. the results shows: " ‘stat’: {‘charset’: ‘binary’, ‘uid’: 0, ‘exists’: True, "  
but stat is never found from the error

- name: check if file exists  
local\_action: stat path=“/home/pvs/Build/data/{{ item }}.x86\_64.rpm”  
with\_items: “{{ rpms }}”  
register: file\_stat

- name: Verifying if file exists  
debug: msg=“File {{ item }} exist”  
with\_items: “{{ file\_stat.results }}”

PLAY [Download and install RPMs from a local directory] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [Create directory if it does not exist] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [check if file exists] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost → localhost] =\> (item=Common-1.0.0-37)  
ok: [localhost → localhost] =\> (item=Database-1.0.0-122)

TASK [Verifying if file exists] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> (item={‘invocation’: {‘module\_args’: {‘checksum\_algorithm’: ‘sha1’, ‘get\_checksum’: True, ‘follow’: False, ‘path’: ‘/home/pvs/Build/data/Common-1.0.0-37.x86\_64.rpm’, ‘get\_md5’: False, ‘get\_mime’: True, ‘get\_attributes’: True}}, ‘stat’: {‘charset’: ‘binary’, ‘uid’: 0, ‘exists’: True, ‘attr\_flags’: ‘’, ‘woth’: False, ‘isreg’: True, ‘device\_type’: 0, ‘mtime’: 1585590258.0, ‘block\_size’: 4096, ‘inode’: 5856469, ‘isgid’: False, ‘size’: 205977384, ‘executable’: False, ‘isuid’: False, ‘readable’: True, ‘version’: ‘385713817’, ‘pw\_name’: ‘root’, ‘gid’: 0, ‘ischr’: False, ‘wusr’: True, ‘writeable’: True, ‘mimetype’: ‘application/x-rpm’, ‘blocks’: 402312, ‘xoth’: False, ‘islnk’: False, ‘nlink’: 1, ‘issock’: False, ‘rgrp’: True, ‘gr\_name’: ‘root’, ‘path’: ‘/home/pvs/Build/data/Common-1.0.0-37.x86\_64.rpm’, ‘xusr’: False, ‘atime’: 1673993504.3784745, ‘isdir’: False, ‘ctime’: 1673993447.9204745, ‘isblk’: False, ‘wgrp’: False, ‘checksum’: ‘5738560f3137fb2f62dd9a179ed343daef01c24b’, ‘dev’: 64770, ‘roth’: True, ‘isfifo’: False, ‘mode’: ‘0644’, ‘xgrp’: False, ‘rusr’: True, ‘attributes’: }, ‘changed’: False, ‘failed’: False, ‘item’: ‘Common-1.0.0-37’, ‘ansible\_loop\_var’: ‘item’}) =\> {  
“msg”: “File {‘invocation’: {‘module\_args’: {‘checksum\_algorithm’: ‘sha1’, ‘get\_checksum’: True, ‘follow’: False, ‘path’: ‘/home/pvs/Build/data/Common-1.0.0-37.x86\_64.rpm’, ‘get\_md5’: False, ‘get\_mime’: True, ‘get\_attributes’: True}}, ‘stat’: {‘charset’: ‘binary’, ‘uid’: 0, ‘exists’: True, ‘attr\_flags’: ‘’, ‘woth’: False, ‘isreg’: True, ‘device\_type’: 0, ‘mtime’: 1585590258.0, ‘block\_size’: 4096, ‘inode’: 5856469, ‘isgid’: False, ‘size’: 205977384, ‘executable’: False, ‘isuid’: False, ‘readable’: True, ‘version’: ‘385713817’, ‘pw\_name’: ‘root’, ‘gid’: 0, ‘ischr’: False, ‘wusr’: True, ‘writeable’: True, ‘mimetype’: ‘application/x-rpm’, ‘blocks’: 402312, ‘xoth’: False, ‘islnk’: False, ‘nlink’: 1, ‘issock’: False, ‘rgrp’: True, ‘gr\_name’: ‘root’, ‘path’: ‘/home/pvs/Build/data/Common-1.0.0-37.x86\_64.rpm’, ‘xusr’: False, ‘atime’: 1673993504.3784745, ‘isdir’: False, ‘ctime’: 1673993447.9204745, ‘isblk’: False, ‘wgrp’: False, ‘checksum’: ‘5738560f3137fb2f62dd9a179ed343daef01c24b’, ‘dev’: 64770, ‘roth’: True, ‘isfifo’: False, ‘mode’: ‘0644’, ‘xgrp’: False, ‘rusr’: True, ‘attributes’: }, ‘changed’: False, ‘failed’: False, ‘item’: ‘Common-1.0.0-37’, ‘ansible\_loop\_var’: ‘item’} exist”  
}  
ok: [localhost] =\> (item={‘invocation’: {‘module\_args’: {‘checksum\_algorithm’: ‘sha1’, ‘get\_checksum’: True, ‘follow’: False, ‘path’: ‘/home/pvs/Build/data/Database-1.0.0-122.x86\_64.rpm’, ‘get\_md5’: False, ‘get\_mime’: True, ‘get\_attributes’: True}}, ‘stat’: {‘charset’: ‘binary’, ‘uid’: 0, ‘exists’: True, ‘attr\_flags’: ‘’, ‘woth’: False, ‘isreg’: True, ‘device\_type’: 0, ‘mtime’: 1612995841.0, ‘block\_size’: 4096, ‘inode’: 1629, ‘isgid’: False, ‘size’: 12408, ‘executable’: False, ‘isuid’: False, ‘readable’: True, ‘version’: ‘235891764’, ‘pw\_name’: ‘root’, ‘gid’: 0, ‘ischr’: False, ‘wusr’: True, ‘writeable’: True, ‘mimetype’: ‘application/x-rpm’, ‘blocks’: 40, ‘xoth’: False, ‘islnk’: False, ‘nlink’: 1, ‘issock’: False, ‘rgrp’: True, ‘gr\_name’: ‘root’, ‘path’: ‘/home/pvs/Build/data/Database-1.0.0-122.x86\_64.rpm’, ‘xusr’: False, ‘atime’: 1674050294.847356, ‘isdir’: False, ‘ctime’: 1673994773.5614717, ‘isblk’: False, ‘wgrp’: False, ‘checksum’: ‘56730380852174a19f81253383a540689399ea9b’, ‘dev’: 64770, ‘roth’: True, ‘isfifo’: False, ‘mode’: ‘0644’, ‘xgrp’: False, ‘rusr’: True, ‘attributes’: }, ‘changed’: False, ‘failed’: False, ‘item’: ‘Database-1.0.0-122’, ‘ansible\_loop\_var’: ‘item’}) =\> {  
“msg”: “File {‘invocation’: {‘module\_args’: {‘checksum\_algorithm’: ‘sha1’, ‘get\_checksum’: True, ‘follow’: False, ‘path’: ‘/home/pvs/Build/data/Database-1.0.0-122.x86\_64.rpm’, ‘get\_md5’: False, ‘get\_mime’: True, ‘get\_attributes’: True}}, ‘stat’: {‘charset’: ‘binary’, ‘uid’: 0, ‘exists’: True, ‘attr\_flags’: ‘’, ‘woth’: False, ‘isreg’: True, ‘device\_type’: 0, ‘mtime’: 1612995841.0, ‘block\_size’: 4096, ‘inode’: 1629, ‘isgid’: False, ‘size’: 12408, ‘executable’: False, ‘isuid’: False, ‘readable’: True, ‘version’: ‘235891764’, ‘pw\_name’: ‘root’, ‘gid’: 0, ‘ischr’: False, ‘wusr’: True, ‘writeable’: True, ‘mimetype’: ‘application/x-rpm’, ‘blocks’: 40, ‘xoth’: False, ‘islnk’: False, ‘nlink’: 1, ‘issock’: False, ‘rgrp’: True, ‘gr\_name’: ‘root’, ‘path’: ‘/home/pvs/Build/data/Database-1.0.0-122.x86\_64.rpm’, ‘xusr’: False, ‘atime’: 1674050294.847356, ‘isdir’: False, ‘ctime’: 1673994773.5614717, ‘isblk’: False, ‘wgrp’: False, ‘checksum’: ‘56730380852174a19f81253383a540689399ea9b’, ‘dev’: 64770, ‘roth’: True, ‘isfifo’: False, ‘mode’: ‘0644’, ‘xgrp’: False, ‘rusr’: True, ‘attributes’: }, ‘changed’: False, ‘failed’: False, ‘item’: ‘Database-1.0.0-122’, ‘ansible\_loop\_var’: ‘item’} exist”  
}

TASK [Download RPMs] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“msg”: “The conditional check ‘item.stat.exists == True’ failed. The error was: error while evaluating conditional (item.stat.exists == True): ‘ansible.utils.unsafe\_proxy.AnsibleUnsafeText object’ has no attribute ‘stat’\n\nThe error appears to be in ‘/home/pvs/Build/playbooks/DownloadRPM.yml’: line 31, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Download RPMs\n ^ here\n”}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [January 18, 2023, 6:10pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/4 "2023-01-18T18:10:23Z")

</div>

Have you looked at the module docs? They show you what “results” is supposed to look like. If I may I’d like to suggest a slightly different approach. The Ansible philosophy is for each task to declare a state and let Ansible ensure the machine is in that state when it is done with the task.

Let’s break your problem down into three states:

1. a local directory needs to exist
2. RPMs need to be in that local directory
3. RPMs in that local directory need to be installed

Given those three states you have three tasks:

- name: make sure /home/pvs/Build/data exists  
file:  
path: /home/pvs/Build/data  
state: directory  
mode: 0755

The task above looks fine. It accomplishes state #1 in a single task.

- name: Make sure RPMs are in /home/pvs/Build/data  
yum:  
name: “{{ item }}”  
state: present  
enablerepo: “\*”  
dest: /home/pvs/Build/data/  
with\_items: “{{ rpms }}”

The task above doesn’t look great. I am not convinced it will download the packages to /home/pvs/Build/data. The yum module does not have a “dest” parameter. It has a download\_dir parameter. The download\_dir parameter is only effective when used in conjunction with download\_only. The next question I have is why do you want these packages downloaded to an alternate local directory? Are they in a repo you have enabled? If so why download them vs simply installing them FROM THAT REPO? This would let you accomplish states 2 and 3 in a single step and eliminate state 1 entirely.

- name: RPMs are installed from /home/pvs/Build/data  
yum:  
name: /home/pvs/Build/data/{{ item }} .x86\_64.rpm  
state: present  
installroot: /home/pvs/Build/data  
enablerepo: “\*”  
allowdowngrade: yes  
with\_items: “{{ rpms }}”  
register: yum\_result

Given what I wrote about task / state 2 it seems task 3 may be unnecessary.

Walter

---

<div class="post-metadata">

**Author:** ![Matthew\_Franco](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Franco](https://forum.ansible.com/u/Matthew_Franco)\
**Post date:** [January 18, 2023, 6:21pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/5 "2023-01-18T18:21:15Z")

</div>

Thank you for the help.  
sorry I had corrected the yum download portion (see below), but did not update here. the below solves the download only part.  
I need to be able to download it to a directory as I am not always going to be online to access repositories. I will be online at one point to get the files, but in the future may not as I switch between builds. I just do not know how to structure the when statement for downloading only when the file is not there.

- name: Download RPMs  
yum:  
name: “{{ rpms }}”  
state: present  
enablerepo: “\*”  
download\_dir: /home/pvs/Build/data/  
download\_only: true  
when: file\_stat.stat.exists == False

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [January 18, 2023, 6:54pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/6 "2023-01-18T18:54:26Z")

</div>

Ansible checks before it makes changes.

You declare a configuration state. If the machine is in that state, Ansible makes no change.

Don’t check if the package has been downloaded. Let Ansible worry about that.

It is fair to worry about whether the download folder exists. For that you only need to name the folder in the file task.

file:  
path: /home/pvs/Build/data  
state: directory  
mode: 0755

register: file\_stat

Is /home/pvs/Build/data a local folder on the control host where you run Ansible, or on each remote machine?

Walter

---

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [January 18, 2023, 7:08pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/7 "2023-01-18T19:08:49Z")

</div>

> file:  
> path: /home/pvs/Build/data  
> state: directory  
> mode: 0755
> 
> register: file\_stat

Also notice that “register” aligns with “file” and not with the params of “file”.

Walter

---

<div class="post-metadata">

**Author:** ![Matthew\_Franco](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Franco](https://forum.ansible.com/u/Matthew_Franco)\
**Post date:** [January 18, 2023, 7:51pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/8 "2023-01-18T19:51:13Z")

</div>

the folder is on each host machine. The folder may already be there for a different set of builds, so just having the folder there does not mean the files have been downloaded.

this script will end up being run locally on each system. It will essentially be on a bunch of test boxes, that people will use the script to switch between build environments.

I have seen when download task is in there and there is no network connection the script errors out. I am hoping to avoid that.

My overall intention was to have an ansible script that runs locally that grabs a list of rpms from a file, checks if the files are in the local directory, if the files are not in the local directory downloads them, then installs the builds from a local directory. Normally the system will not be on a network that can reach repositories. It will only be on that network if they need to download.

---

<div class="post-metadata">

**Author:** ![Matthew\_Franco](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Franco](https://forum.ansible.com/u/Matthew_Franco)\
**Post date:** [January 18, 2023, 10:26pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/9 "2023-01-18T22:26:41Z")

</div>

thanks I saw my indent on the when was wrong, but it still gets the same error.

I assume I am not using Ansible as intended as I am very much a novice. I apperciate your patience.

---

<div class="post-metadata">

**Author:** ![Matthew\_Franco](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Matthew\_Franco](https://forum.ansible.com/u/Matthew_Franco)\
**Post date:** [January 19, 2023, 7:30pm UTC](https://forum.ansible.com/t/error-the-conditional-check-file-stat-stat-exists-false-failed-the-error-was-error-while-evaluating-conditional-file-stat-stat-exists-false-file-stat-is-undefined/37556/10 "2023-01-19T19:30:54Z")

</div>

thanks for the help. I took a different approach we can close this thread.
