[TriLUG] init script behaves different when invoked from Ansible playbook??

Brian Gerard via TriLUG trilug at trilug.org
Thu May 11 13:20:41 EDT 2017


I don't know that it will get you out of your current predicament, but a safer
way to get the path would be a combination of 'readlink' and 'dirname', thus:
SCRIPTPATH=$(dirname $(readlink -m $0))

Brian

On 05/11/2017 01:06 PM, Phillip Rhodes (Fogbeam Labs) wrote:
> 
> 
> On Thu, May 11, 2017 at 1:01 PM, Brian Gerard via TriLUG <trilug at trilug.org
> <mailto:trilug at trilug.org>> wrote:
> 
>     When you say it dies in the middle, is there a particular point at which
>     it dies every time?  Ie - you added a bunch of debugging echoes in there;
>     can you say what it's trying to do when it dies?  If not, I'd recommend
>     adding more and appending to a log in /tmp or something to see if you can
>     pinpoint where it's failing.
> 
> 
> Yes, it always fails dies (or hangs, I just realized it might still be running)
> at the same place.  It's trying to do this business:
> 
> SCRIPTPATH=$(dirname "$0")
> 
> 
>  
> 
> 
>     FWIW, the first thing that popped into my brain was the possibility that
>     Ansible might have mucked about with the shell syntax, if you're handling
>     that script as a "template" rather than a "file", but since it seems to
>     work from outside of Ansible, I'm less sure of that.  It might be worth
>     looking at anyway, just to check.  Diffing the source script and the installed
>     version, iow.
> 
> 
> Oh yeah, that's a good thought.  I was thinking in terms of "I'm not explicitly
> doing any
> substitution stuff in here" and was treating the template as equivalent to a
> static file.  That
> is probably a bad idea, even if it isn't directly the cause of my problem here.
> 
> 
> I'm trying it again now with the script spitting out $BASHPID at the beginning
> to (hopefully) I can determine if maybe it's hung, as opposed to the process
> having aborted.
> 
> 
> Phil
> 



More information about the TriLUG mailing list