Doing more troubleshooting now :
Macbook Pro :
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ pwd 127 ↵
/Users/x/ResilioSync/motorforker/SHONKO
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ ls -al
total 0
drwxr-xr-x 7 x staff 224 29 Mar 08:49 .
drwxr-xr-x@ 34 x staff 1088 29 Mar 08:48 ..
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .puncho
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .vulgar
-rw-r--r-- 1 x staff 0 29 Mar 08:48 bogus
-rw-r--r-- 1 x staff 0 29 Mar 08:48 shitshow
-rwx------ 1 x staff 0 29 Mar 08:49 shonko.expect
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ chmod 644 shonko.expect
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ ls -al
total 0
drwxr-xr-x 7 x staff 224 29 Mar 08:49 .
drwxr-xr-x@ 34 x staff 1088 29 Mar 08:48 ..
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .puncho
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .vulgar
-rw-r--r-- 1 x staff 0 29 Mar 08:48 bogus
-rw-r--r-- 1 x staff 0 29 Mar 08:48 shitshow
-rw-r--r-- 1 x staff 0 29 Mar 08:49 shonko.expect
Brix running RHEL 8 :
╭─x@phoebe.local ~/ResilioSync/motorforker/SHONKO
╰─➤ ls -al 2 ↵
total 4
drwxr-xr-x. 2 x x 86 Mar 29 08:49 .
drwxrwxr-x. 23 x x 4096 Mar 29 08:48 ..
-rw-r--r--. 1 x x 0 Mar 29 08:48 bogus
-rw-r--r--. 1 x x 0 Mar 29 08:49 .puncho
-rw-r--r--. 1 x x 0 Mar 29 08:48 shitshow
-rwx------. 1 x x 0 Mar 29 08:49 shonko.expect
-rw-r--r--. 1 x x 0 Mar 29 08:49 .vulgar
** Ansible playbook** :
╭─x@titan ~/ResilioSync/motorforker/ansy
╰─➤ cat file3.yml
---
- name: file module demo
hosts: all
gather_facts: no
vars:
mydiry: "~x/ResilioSync/motorforker/SHONKO/*"
myfile: "~x/ResilioSync/motorforker/SHONKO/shonko.expect"
become: false
tasks:
# - name: check permission
# ansible.builtin.file:
# path: "{{ mydiry }}"
# # state: directory
# mode: '0600'
- name: check permission
ansible.builtin.file:
path: "{{ myfile }}"
# state: file
mode: '0700'
Kick it off :
╭─x@titan ~/ResilioSync/motorforker/ansy
╰─➤ ansible-playbook file3.yml
_________________________
< PLAY [file module demo] >
-------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
_________________________
< TASK [check permission] >
-------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
ok: [titan]
[WARNING]: Platform linux on host beere253 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [beere253]
[WARNING]: Platform linux on host telesto is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [telesto]
ok: [bebhionn]
ok: [phoebe]
ok: [rhel8000]
ok: [orenmwy]
[WARNING]: Platform freebsd on host baphomet is using the discovered Python interpreter at /usr/local/bin/python3.7, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [baphomet]
[WARNING]: Platform darwin on host methone is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
changed: [methone]
ok: [fenriz]
____________
< PLAY RECAP >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
baphomet : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
bebhionn : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
beere253 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
fenriz : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
methone : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
orenmwy : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
phoebe : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
rhel8000 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
telesto : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
titan : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Macbook Pro:
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ ls -al
total 0
drwxr-xr-x 7 x staff 224 29 Mar 08:49 .
drwxr-xr-x@ 34 x staff 1088 29 Mar 08:48 ..
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .puncho
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .vulgar
-rw-r--r-- 1 x staff 0 29 Mar 08:48 bogus
-rw-r--r-- 1 x staff 0 29 Mar 08:48 shitshow
-rwx------ 1 x staff 0 29 Mar 08:49 shonko.expect
So, it works on a SPECIFIC file (shonko.expect) - but - NOT when I try to do it using WILDCARDS (wildcard section commented out of playbook)! There are ways of doing thing using SHELL or COMMAND stuff - but - THAT’S NOT the ansible way - I should be using the API and YAML Ansible code, not escaping out to a shell (otherwise I might has well just running my SHELL scripts!
So - here - I uncomment that extra “wildcard” code from my file3.yml playbook :
Ansible playbook :
---
- name: file module demo
hosts: all
gather_facts: no
vars:
mydiry: "~x/ResilioSync/motorforker/SHONKO/*"
myfile: "~x/ResilioSync/motorforker/SHONKO/shonko.expect"
become: false
tasks:
- name: check permission
ansible.builtin.file:
path: "{{ mydiry }}"
# state: directory
mode: '0600'
- name: check permission
ansible.builtin.file:
path: "{{ myfile }}"
# state: file
mode: '0700'
Then over on the Macbook :
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ chmod 644 shonko.expect
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ ls -al
total 0
drwxr-xr-x 7 x staff 224 29 Mar 08:49 .
drwxr-xr-x@ 34 x staff 1088 29 Mar 08:48 ..
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .puncho
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .vulgar
-rw-r--r-- 1 x staff 0 29 Mar 08:48 bogus
-rw-r--r-- 1 x staff 0 29 Mar 08:48 shitshow
-rw-r--r-- 1 x staff 0 29 Mar 08:49 shonko.expect
Run that sucker :
╭─x@titan ~/ResilioSync/motorforker/ansy
╰─➤ ansible-playbook file3.yml
_________________________
< PLAY [file module demo] >
-------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
_________________________
< TASK [check permission] >
-------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
fatal: [titan]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
[WARNING]: Platform linux on host beere253 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
fatal: [beere253]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
[WARNING]: Platform linux on host telesto is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
fatal: [telesto]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
fatal: [bebhionn]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
fatal: [fenriz]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
fatal: [phoebe]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
fatal: [rhel8000]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
fatal: [orenmwy]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "file (/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/home/x/ResilioSync/motorforker/SHONKO/*"}
[WARNING]: Platform freebsd on host baphomet is using the discovered Python interpreter at /usr/local/bin/python3.7, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
fatal: [baphomet]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/local/bin/python3.7"}, "changed": false, "msg": "file (/mnt/BARGEARSE/home/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/mnt/BARGEARSE/home/x/ResilioSync/motorforker/SHONKO/*"}
[WARNING]: Platform darwin on host methone is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
fatal: [methone]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "file (/Users/x/ResilioSync/motorforker/SHONKO/*) is absent, cannot continue", "path": "/Users/x/ResilioSync/motorforker/SHONKO/*"}
____________
< PLAY RECAP >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
baphomet : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
bebhionn : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
beere253 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
fenriz : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
methone : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
orenmwy : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
phoebe : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
rhel8000 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
telesto : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
titan : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The Macbook AFTER running that shonky code :
╭─x@methone.local ~/ResilioSync/motorforker/SHONKO
╰─➤ ls -al
total 0
drwxr-xr-x 7 x staff 224 29 Mar 08:49 .
drwxr-xr-x@ 34 x staff 1088 29 Mar 08:48 ..
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .puncho
-rw-r--r-- 1 x staff 0 29 Mar 08:49 .vulgar
-rw-r--r-- 1 x staff 0 29 Mar 08:48 bogus
-rw-r--r-- 1 x staff 0 29 Mar 08:48 shitshow
-rw-r--r-- 1 x staff 0 29 Mar 08:49 shonko.expect
So - it’s broken… somehow or other - I was able to get it to do the expect script, but none of the others, now when it barfs, it seems to barf on everything, and does NOTHING… My issue is obviously wildcards - but when I search for “wildcard” and “ansible.builtin.file” - I get NO help! I get plenty of generic samples about using that module, but NO mention of wildcards, or globbing or whatever - however - GLOBBING is working on things like tilde “~” for home directory of user…
Tried using some other ansible code - and it just barfs completely and never tries to run at all (stole it from here : How to use wild card while giving file permission using Ansible? - Stack Overflow) :
Playbook (file3.yml) :
---
- name: file module demo
hosts: all
gather_facts: no
vars:
mydiry: "~x/ResilioSync/motorforker/SHONKO/*"
myfile: "~x/ResilioSync/motorforker/SHONKO/shonko.expect"
become: false
tasks:
# - name: check permission
# ansible.builtin.file:
# path: "{{ mydiry }}"
# # state: directory
# mode: '0600'
- name: check permission
ansible.builtin.file:
path: "{{ myfile }}"
# state: file
mode: '0700'
- file:
path: '{{ mydiry }}'
# owner: tomcat
# group: tomcat
mode: 0600
with_fileglob:
- "~x/ResilioSync/motorforker/SHONKO/*"
Run playbook :
╭─x@titan ~/ResilioSync/motorforker/ansy
╰─➤ ansible-playbook file3.yml
ERROR! Syntax Error while loading YAML.
did not find expected '-' indicator
The error appears to be in '/home/x/ResilioSync/motorforker/ansy/file3.yml': line 25, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
mode: 0600
with_fileglob:
^ here
I guess that serves me right for trying shit code from stack overflow… I know the issue is probably indentation or something - but I can’t be arsed (I did actually try) debugging that…
I know one fix: but that’s the wrong answer - anticipate EVERY single file and explicitly specify that file ! Lotsa (too much) administrative overhead…
I just need to figure out how to get that SHITTY “ansible.builtin.file” module to accept wildcards… 
update - made some progress - 2 steps forward, 1 step back…
dir.yml :
╭─x@titan ~/ResilioSync/motorforker/ansy
╰─➤ cat dir.yml
---
- name: testicles
hosts: arm_debian, x86_64_ubuntu, x86_64_RHEL
gather_facts: no
vars:
dirdir : "~x/ResilioSync/motorforker/SHONKO"
tasks:
- name: tweak permissions
file:
dest: "{{ item }}"
mode: 0600
with_fileglob:
- '{{ dirdir }}/*'
- '{{ dirdir }}/.*'
- name: tweak exec permissions
file:
dest: "{{ item }}"
mode: 0700
with_fileglob:
- '{{ dirdir }}/*.expect'
The “file” builtin (assume it’s a builtin) is too dumb to know that “~x” means $HOME on FreeBSD and/or MacOS
(yeah - I know @Akito - serves me right for using BSD and MacOS [i.e. great chunks of FreeBSD code on Apple’s MACH kernel]). So - I guess I can rely on ansible to do this job on my Linux boxes, but the shell script solution for FreeBSD and Macintosh?