Ask Your Question
0

how to set environmental variables in ubuntu using puppe

asked 2015-05-15 05:15:51 -0500

anilkumar_2654@yahoo.com gravatar image

I am newbie to Puppet and been learning the tool to automate some of things in Our Office.In order to run our web application we need JDK and Ant.

The below is the manifest i have written for setting environmental variables in Ubuntu for Java and Ant. When i executed the manifest, i have no errors but the environmental variables are not getting reflected in the current shell. If I open new terminal, they are.

file {"env.sh": path => "/etc/profile.d/env.sh", source => "puppet:///modules/bash/env.sh", owner => "root", group => "root", mode => "655" }

exec { "Source env.sh file" : provider => shell, command => " . /etc/profile.d/env.sh", cwd => "/etc/profile.d", user => root, require => [ File['env.sh'] ] }

Basically i created a script file env.sh containing the HOME and PATH variables of Java and Ant and placing them in /etc/profile.d/ and sourceing the script to get reflected in the current shell.

Please let me know if i my approach is wrong. If so how can i accomplish what i want.

Thanks Anil.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-05-18 05:09:39 -0500

far4d gravatar image

updated 2015-05-18 05:26:40 -0500

IIRC: Puppet strips all environment variables when calling "exec". Please look at this thread at stackoverflow for possible solutions: Set Environment Variables with Puppet

edit flag offensive delete link more
0

answered 2015-11-17 01:03:03 -0500

exec { 'myniftycommand.sh': environment => [JAVAHOME=/usr/java/jdk1.6.026, CATALINAHOME=/usr/share/apache-tomcat-6.0.37, SERVICEMIXHOME=/opt/apache-servicemix-3.3.2, ANTHOME=/opt/opt/apache-ant-1.8.4 ], path => "$JAVAHOME/bin:$CATALINAHOME/bin:$SERVICEMIXHOME/bin:$ANT_HOME/bin:$PATH" }

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-05-15 05:15:51 -0500

Seen: 1,972 times

Last updated: May 18 '15