LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2022, 02:00 AM   #1
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,585

Rep: Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520
Ansible: "include_tasks:" cannot find/access file


Environment: Windows 10 laptop running Oracle VirtualBox + CentOS 8. Ansible 2.10.10 (team's current development standard). Filesystem on the VM is XFS (didn't have an option about that when creating the VM).

I've been working on a gnarly playbook (nearly finished with the darned thing, too) when I added a another "include_tasks" statement and the playbook got even gnarlier when it refused to load the file. The error message it spits out says that it "Could not find or access <path-to-file> on the Ansible controller."

The contents of the problem file is nothing but a "debug/msg" statement followed by a series of "set_facts". Nothing special and files like that have never been a problem in the past.

The main playbook is issuing something like:
Code:
 - include_tasks: tasks/init_parms.yml
The security settings on the file and the "tasks" subdirectory are fine. I own them and permissions are 664. I can "stat" the file, run "ls -l" on it, "cat" it at a shell prompt but anything I try to with that file from within Ansible fails with that (essentially) "file not found" message. I've even preceded the "include_tasks" with:
Code:
- name: "access file via shell"
  shell: <cmd> tasks/init_parms.yml
  register: shell_output
where "cmd" has been set to "stat", "ls -l", "cat", you name it. The result is always the same: "Cannot find or access"

Substituting the name of a different file from that subdirectory? The above code snippet works perfectly.

Trying to open the file using:
Code:
- set_fact:
    file_contents: "{{ lookup( 'file', 'tasks/init_parms.yml' }}"
returns the same error message.

I've looked at the directory holding the file using Emacs and vi and don't see any control characters that occasionally get into file names.

I've copied the original file I've been trying to include to different files/different names and tweaked the playbook to try and access the new file... same error.

Moved the problematic "include_tasks" statement to just before another similar to it and the statement crashes in it's new location so where it appears in the main playbook doesn't matter.

None of this looks to some Ansible or YAML syntax problem---at least as far as yamllint can see (other than "line too long" warnings) and Ansible always catches stupid typos before even running the playbook.

I was thinking that, maybe, the "include_tasks" could be having trouble with a long path -- the length of the fully qualified path to the file is 114 characters (the filename has some equipment model numbers as a prefix) -- but other "problem-free" files accessed with "include_tasks" are in the same directory and some have longer filenames.

What I find odd about this is that the file that I'm unable to access is not even the first file I'm including from that directory (it's the 9th or 10th out of 36 total). None of the preceding "include_tasks" are having any trouble reading files in.

If I comment out the "include_tasks" line that's causing the error, the playbook happily runs until it eventually runs another "include_tasks" that pulls in a set of tasks that need parameters in the file that Ansible cannot include resulting in the playbook crashing (due to undefined variables, etc.). No big surprise there.

I mentioned XFS at the beginning in case someone knew of strange errors occurring while running Ansible on XFS. (This VM is the only case where I've ever used XFS.)

Any ideas what could be causing Ansible to be unable to access the file that all the other tools I've tried -- outside Ansible, that is -- are able to access without any trouble?

TIA...
 
Old 05-14-2022, 12:04 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,285
Blog Entries: 1

Rep: Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615Reputation: 1615
You could try strace to debug. Also make sure SeLinux is disabled.
 
Old 05-14-2022, 06:49 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 1,983

Rep: Reputation: 890Reputation: 890Reputation: 890Reputation: 890Reputation: 890Reputation: 890Reputation: 890
XFS is like any other FS regarding file bandling.
Maybe there is a CR in your file (from editing in WinDOS)?
 
Old 05-14-2022, 11:59 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,892

Rep: Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122
I didn't see it in your information, but did you try the full path and not a relative one?
 
Old 05-15-2022, 06:47 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,585

Original Poster
Rep: Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520
Quote:
Originally Posted by grail View Post
I didn't see it in your information, but did you try the full path and not a relative one?
Yes.
 
Old 05-15-2022, 08:54 PM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,892

Rep: Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122Reputation: 3122
It does seem like you have tried a lot of things, so i guess back to basics:

1. Can we get a long listing of the directory and files in it?

2. Have you tried creating a new file and placing the code in it?
 
Old 05-15-2022, 10:24 PM   #7
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,585

Original Poster
Rep: Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520
Quote:
Originally Posted by grail View Post
It does seem like you have tried a lot of things, so i guess back to basics:

1. Can we get a long listing of the directory and files in it?
I am able to get long listing of the directory contents. Both from the bash prompt as well as by running an "ls -l" command vie "shell:" within Ansible. It is only the one file, copies of it, or the original file after renaming that resulted in the read errors.

Quote:
2. Have you tried creating a new file and placing the code in it?
[/quote]

Yes. I did not, however, try creating an empty file and cutting-n-pasting the code into it. That's the only thing I didn't try.
 
Old 05-15-2022, 11:01 PM   #8
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,585

Original Poster
Rep: Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520Reputation: 520
Sigh...

The "Sorry, cannot access your file" error has been fixed. It may be a coincidence but the problem began occurring about the time I got one of those "you need to reboot to install patches" popups on Windows. (I liked it better when the patch downloads didn't take place in the background---no surprise popups.) The post-patch-install reboot I did after 5PM didn't change anything---I continued to have the file access problem for several hours until I finally decided to call it a day. Interestingly, the following morning the Windows boot took an inordinate amount of time as though it was installing even more patches. After that, the file access began working without having to make any changes to the playbook. Could there have been a problem in the way VirtualBox and Windows played together due to the patch downloads? I'll never know. Nobody gets release notes for patches any more. (I miss those.)

I'll mark this thread as "solved".
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ansible Guide: Manage Files using Ansible LXer Syndicated Linux News 0 04-26-2019 10:32 AM
LXer: Ansible Guide: Create Ansible Playbook for LEMP Stack LXer Syndicated Linux News 0 04-13-2019 05:03 AM
LXer: Ansible Tutorial: Introduction to simple Ansible commands LXer Syndicated Linux News 0 05-21-2018 10:28 AM
LXer: Ansible Tutorial: Intorduction to simple Ansible commands LXer Syndicated Linux News 0 01-14-2018 05:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration