How to use user vars or unset default ones

80 views
Skip to first unread message

Ivan Garcia

unread,
Jun 11, 2015, 10:35:50 AM6/11/15
to ansible...@googlegroups.com
Hi all,

I'm working to automate some Tomcat deployments and I have a problem with the enconding. When I start the Tomcat, Ansible use its default LANG=C and LC_TYPE=C variables and the application is not deployed properly, some characters doesn't appear right.

Following you can see the PID info and notice that it's putting the default variables instead of using the user variables (root as I'm using sudo):

# cat /proc/18107/environ                   
TOMCAT_HOME=/opt/tomcatTERM=linuxSHELL=/bin/bashCATALINA_HOME=/opt/tomcat TOMCAT_START=/opt/tomcat/bin/startup.shUSER=tomcatJAVA_OPTS=-server -Xms1024m -Xmx2048m -XX:PermSize=256m  -XX:MaxPermSize=512m -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager JRE_HOME=/op /java/latestSUDO_USER=atlasSUDO_UID=50000USERNAME=rootMAIL=/var/mail/at PATH=/sbin:/usr/sbin:/bin:/usr/binPWD=/opt/tomcat/webapps/simyoJAVA_HOME=/opt/jav /latest LANG=CHOME=/home/tomcatSUDO_COMMAND=/bin/sh -c echo SUDO-SUCCESS-bdoirfizidenadwclaoujhbewakdemoh;  LANG=C LC_CTYPE=C /usr/bin/python /home/at //.ansible/tmp/ansible-tmp-1434028812.49-238808986274644/command;  rm -rf /home/atlas//.ansible/tmp/ansible-tmp-1434028812.49-238808986274644/ >/dev/null  2>&1SHLVL=5TOMCAT_STOP=/opt/tomcat/bin/shutdown.shLOGNAME=tomcat LC_CTYPE=CSUDO_GID=50000_=/opt/java/latest/bin/javaLD_LIBRARY_PATH=/opt/java/jdk1.6.0_2 /jre/lib/i386/server: /opt/java/jdk1.6.0_24/jre/lib/i386:/opt/java/jdk1.6.0_24/jre/../lib/i386

Do you know if there's any way to use the user variables instead of the "ansible_env" vars? If not, there's any way to unset this vars at playbook level?

I've seen this docu but there's nothing about unset vars --> https://docs.ansible.com/playbooks_environment.html

Cheers,

Ivan G.

Brian Coca

unread,
Jun 11, 2015, 10:45:14 AM6/11/15
to ansible...@googlegroups.com
if you unset LC/LANG variables they default to C/POSIX, so i would
actually set them to what you need.
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6d0253ae-43ff-4d5a-aee9-f693f3ca654f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Ivan Garcia

unread,
Jun 11, 2015, 12:29:57 PM6/11/15
to ansible...@googlegroups.com
Thanks for your answer Brian. Apart from that I'd really like to know if there's a way to use the user's variables of the user that is specified in the playbook. In my case I'm doing a sudo: yes.

Cheers,

Ivan

Brian Coca

unread,
Jun 11, 2015, 12:37:23 PM6/11/15
to ansible...@googlegroups.com
Yes and no, ansible avoids using a login shell, so vars defined for
the user that rely on that won't be picked up. Sudo , by default, also
removes most vars from the source user and can set it's own vars for
the target user, it also does not normally pickup vars that depend on
login to be set.




--
Brian Coca

Ivan Garcia

unread,
Jun 12, 2015, 10:20:32 AM6/12/15
to ansible...@googlegroups.com
Brian thanks for your answers!

Cheers,

Ivan G.


El jueves, 11 de junio de 2015, 16:35:50 (UTC+2), Ivan Garcia escribió:
Reply all
Reply to author
Forward
0 new messages