Hi - I'm having trouble using the shell module with become_user. As a basic
test, I created this playbook:
- name: Retrieve environment variables for root
shell: printenv
- name: Retrieve environment variables for oracle
shell: printenv
become: yes
become_user: oracle
When I ran this with ansible-playbook and '-vvv', I noticed:
- the output received from the first task was as expected:
"stdout": "HOSTTYPE=x86_64\nSSH_CONNECTION=10.247.229.46 35330
10.247.229.191 22\nLESSCLOSE=lessclose.sh %s
%s\nXKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB\n_=/usr/bin/printenv\nLANG=POSIX\nWINDOWMANAGER=xterm\nLESS=-M
-I
-R\nHOSTNAME=ldpdd191\nCSHEDIT=emacs\nGPG_TTY=/dev/pts/0\nLESS_ADVANCED_PREPROCESSOR=no\nCOLORTERM=1\nMACHTYPE=x86_64-suse-linux\nMINICOM=-c
on\nOSTYPE=linux\nXDG_SESSION_ID=69\nUSER=root\nPAGER=less\nMORE=-sl\nPWD=/root\nHOME=/root\nLC_CTYPE=C.UTF-8\nHOST=ldpdd191\nSSH_CLIENT=10.247.229.46
35330
22\nXNLSPATH=/usr/X11R6/lib/X11/nls\nXDG_SESSION_TYPE=tty\nXDG_DATA_DIRS=/usr/share\nLIBGL_DEBUG=quiet\nPROFILEREAD=true\nSSH_TTY=/dev/pts/0\nFROM_HEADER=\nMAIL=/var/spool/mail/root\nLESSKEY=/etc/lesskey.bin\nTERM=xterm\nSHELL=/bin/bash\nXDG_SESSION_CLASS=user\nPYTHONSTARTUP=/etc/pythonstart\nSHLVL=3\nMANPATH=/usr/share/man:/usr/local/man\nLOGNAME=root\nDBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus\nXDG_RUNTIME_DIR=/run/user/0\nXDG_CONFIG_DIRS=/etc/xdg\nPATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin\nG_BROKEN_FILENAMES=1\nHISTSIZE=1000\nCPU=x86_64\nSSH_SENDS_LOCALE=yes\nLESSOPEN=lessopen.sh
%s",
but the output received from the second task (which uses 'become_user') was
not correct:
"stdout":
"_=/usr/bin/printenv\nLANG=POSIX\nSUDO_GID=0\nCOLORTERM=1\nSUDO_COMMAND=/bin/sh
-c echo BECOME-SUCCESS-ukrwuqlueafnghzqqoabhpfcwxwpieyw ;
/usr/bin/python3.6
/var/tmp/ansible-tmp-1695847065.2341652-30706-3263662880779/AnsiballZ_command.py\nUSER=oracle\nPWD=/home/oracle/.ansible/tmp/ansible-moduletmp-1695847065.5976799-u8hbo4o2\nHOME=/home/oracle\nLC_CTYPE=C.UTF-8\nSUDO_USER=root\nSUDO_UID=0\nMAIL=/var/mail/oracle\nTERM=xterm\nSHELL=/bin/bash\nSHLVL=2\nLOGNAME=oracle\nPATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin",
so, it seem that using 'become_user' perverts the function of the 'shell'
module, and the command provided is not executed as expected. Is this a
known bug/limitation?
Thanks!
tl
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1bf473a0-6bd1-4f5f-99d2-b23b388e0e29n%40googlegroups.com.