Short answer:
-------------
I can't reproduce the problem. Both host1 and host2 found the file.
TASK [show the stat results] ***
ok: [host1] => { "st3.stat.exists": true }
ok: [host2] => { "st3.stat.exists": true }
Quoting from the issue #67410:
------------------------------
Summary of the problem: "Both copy and stat fail to find a file in a
shared directory that was deleted and recreated ..."
- name: Test shared file issue
hosts: dmgr:solr
become: yes
become_user: REDACTED
become_method: sudo
tasks:
- name: stat the file from both
stat:
path: "{{ shared_dir }}/testfile"
register: st1
- name: show the stat results
debug:
msg: "{{ st1.stat }}"
- name: Remove the file from solr
file:
path: "{{ shared_dir }}/testfile"
state: absent
when: "'solr' in group_names"
- name: stat the file from both
stat:
path: "{{ shared_dir }}/testfile"
register: st2
- name: show the stat results
debug:
msg: "{{ st2.stat }}"
- name: create the file on dmgr
shell: 'echo "Hello World" > {{ shared_dir }}/testfile'
when: "'dmgr' in group_names"
- name: stat the file from both
stat:
path: "{{ shared_dir }}/testfile"
register: st3
- name: show the stat results
debug:
msg: "{{ st3.stat }}"
TASK [show the stat results] ***
ok: [DMGR REDACTED] => {
"msg": {
...
"exists": true,
...
}
ok: [SOLR REDACTED] => {
"msg": {
"exists": false
}
PLAY RECAP ***
DMGR REDACTED: ok=8 changed=1 unreachable=0 failed=0 skipped=1
rescued=0 ignored=0
SOLR REDACTED: ok=8 changed=1 unreachable=0 failed=0 skipped=1
rescued=0 ignored=0
Notes:
------
* One task is missing both in the listing of the playbook and of the output.
There are only 7 tasks reported OK not 8 as summarised in PLAY RECAP. See
#67410.
Details:
--------
* I run exactly the same playbook with unprivileged user, but changed the
debug to "var: st3.stat.exists"
* NFS server "host1" running FreeBSD 12.0-RELEASE
* NFS client "host2" running FreeBSD 12.1-RELEASE
* inventory
[dmgr]
host1 ansible_host=10.1.0.12
[solr]
host2 ansible_host=10.1.0.17
* full output:
PLAY [Test shared file issue] ***
TASK [stat the file from both] ***
ok: [host2] ok: [host1]
TASK [show the stat results] ***
ok: [host1] => { "st1.stat.exists": true }
ok: [host2] => { "st1.stat.exists": true }
TASK [Remove the file from solr] ***
skipping: [host1]
changed: [host2]
TASK [stat the file from both] ***
ok: [host2]
ok: [host1]
TASK [show the stat results] ***
ok: [host1] => { "st2.stat.exists": false }
ok: [host2] => { "st2.stat.exists": false }
TASK [create the file on dmgr] ***
skipping: [host2]
changed: [host1]
TASK [stat the file from both] ***
ok: [host2]
ok: [host1]
TASK [show the stat results] ***
ok: [host1] => { "st3.stat.exists": true }
ok: [host2] => { "st3.stat.exists": true }
PLAY RECAP ***
host1: ok=7 changed=1 unreachable=0 failed=0 skipped=1
rescued=0 ignored=0
host2: ok=7 changed=1 unreachable=0 failed=0 skipped=1
rescued=0 ignored=0
--
HTH,
-vlado