ansible shell calling maven exec fails

39 views
Skip to first unread message

g.ro...@prometheuscomputing.com

unread,
Feb 28, 2017, 9:38:51 AM2/28/17
to Ansible Project
All,

I would assume ansible would run a bash script exactly as if it were run from the CLI, but apparently not.  Can any one help me understand the differences?

I am using ansible shell to start a set of five long running processes.  Each process is a bash script that starts a java program. Each script is set up with an & so the process runs in the background.  To wit:

shell
: ./start.sh &

All process work as expected when started manually by logging in to the hosts one by one and running the exact same command that would be run using shell.  Three of the processes do indeed work when started from ansible shell, but two fail to start at all.  These two have something in common:  Both use maven exec:exec to start them.   The others do not. 

Is there any reason for this?

Thanks mucho for any insights.

Kai Stian Olstad

unread,
Feb 28, 2017, 11:33:02 AM2/28/17
to ansible...@googlegroups.com
With shell module you would not get the users environment, so you
probably missing correct PATH and/or other environment variables need
for starting.

--
Kai Stian Olstad

g.ro...@prometheuscomputing.com

unread,
Feb 28, 2017, 2:54:24 PM2/28/17
to Ansible Project, ansible-pr...@olstad.com
Thanks Kai

Is there anyway to get the user's env?

Kai Stian Olstad

unread,
Mar 1, 2017, 4:36:46 AM3/1/17
to ansible...@googlegroups.com
> Is there anyway to get the user's env?
>

It depends somewhat on you setup.

You could use environment in Ansible
https://docs.ansible.com/ansible/playbooks_environment.html

If the environment is in a file, you could source it if you use the
shell module.
The shell module uses /bin/sh in Ansible so this might not be
straightforward.

You could make a startup script that contained all you would need to
start the program.

The best option is probably to create init file and start them as a
service.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages