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

Brian Gerard via TriLUG trilug at trilug.org
Thu May 11 13:01:06 EDT 2017


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.

Also, is there anything written anywhere in /var/log or the like?  Or
maybe does existdb keep its own logs somewhere else you could look?

Good call on putting 'env' in there, too.  That was going to be my next
suggestion.  :)

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.

And my $0.02 is not to use a 'template' for scripts and that sort of thing.
The syntaxes can just be a trifle too close for my comfort level.  When I've
needed template-like behavior when installing a script via Ansible in the past,
I've generally kept the script as a static file and created a config file that
the script can read in at runtime as a template.  So Ansible modifies the
config rather than the script that uses it.  YMMV, of course.  :)

Brian

On 05/11/2017 12:14 PM, Phillip Rhodes via TriLUG wrote:
> Gang:
> 
> I've run into something which has me stumped.  I have an ansible
> playbook which is meant to automate the installation of a project
> called existdb.  To that end, I have an 'existdb' init script as a
> template in the playbook, and I copy it into /etc/init.d and then
> later run "service existdb start".
> 
> The /etc/init.d/existdb script in turn calls another script (which I
> didn't write).  So here's the weird part.  When I run the ansible
> playbook, the service doesn't start.  I've added "echo 1", "echo 2"
> type lines throughout the second shell script to verify that it's
> called, and it is, but it just mysteriously dies in the middle.   But,
> if I ssh into the box, 'sudo su -'  to become root, and then run
> "service existdb start" it all works fine.
> 
> This feels like some kind of environment issue, but I am stumped on
> what it could be.  I would think that invoking an init script using
> the "service" command would be identical regardless of whether it's
> done by root logged in locally, or using sudo and ssh remotely.   Is
> there something obvious I should be looking for, that is likely to be
> different between those two scenarios?
> 
> FWIW, I stuck a call to 'env' in the second script and it appears that
> everything reported by env is identical whether it's done from ansible
> or done locally.   I'm not a shell guru, so I'm not really sure how to
> debug this.   If anybody has any ideas, they would be greatly
> appreciated.
> 
> 
> Phil
> ~~~
> 
> 
> This message optimized for indexing by NSA PRISM
> 



More information about the TriLUG mailing list