Ask Your Question

how to set environmental variables in ubuntu using puppe

asked 2015-05-15 05:15:51 -0600 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 {"": path => "/etc/profile.d/", source => "puppet:///modules/bash/", owner => "root", group => "root", mode => "655" }

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

Basically i created a script file 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

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

far4d gravatar image

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

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

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

exec { '': 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



Asked: 2015-05-15 05:15:51 -0600

Seen: 2,728 times

Last updated: May 18 '15