become_user not loading environment settings

458 views
Skip to first unread message

Jamie A

unread,
Nov 27, 2015, 11:06:30 AM11/27/15
to Ansible Project
I am using Ansible to automate the deployment of a BAR file to IBM Integration Bus v9.0.0.4 Here is my playbook

--- 
- hosts: 10.0.0.5 
remote_user: jamie 
become: yes 
become_user: mqm 

tasks: 

- name: deploy bar 
shell: mqsideploy -q IB9QMGR -e EG -a MyBar.bar
 

The above playbook results in the following error: 

mqsideploy: command not found 

If I manually remote into the server the following gets echoed to the console which indicates that the server is loading additional paths into the environment for the mom user.

sudo su - mqm 
[sudo] password for jamie: 

MQSI 9.0.0.4 
/opt/ibm/mqsi/9.0.0.4 

BIP1284I: Broker 'IB9BRK' on queue manager 'IB9QMGR' is running. 
BIP8071I: Successful command completion. 
QMNAME(IB9QMGR) STATUS(Running)
 


I am curious why ansible is not loading the environment?

 

Markus Ellers

unread,
Nov 27, 2015, 12:09:55 PM11/27/15
to Ansible Project
you need to indent the shell line:

Brian Coca

unread,
Nov 27, 2015, 12:12:24 PM11/27/15
to Ansible Project
in general Ansible avoids doing logins, this will prevent many env
vars from loading, add to that the normal sudo behavior of also
removing/ignoring existing env vars and you'll probably get a very
'clean' environment.

You can use the 'environment' directive to set those vars for the task
you have directly.

--
Brian Coca
Reply all
Reply to author
Forward
0 new messages