Ask Your Question
1

Modify $path variable between Exec resources

asked 2013-05-23 20:33:17 -0500

louis gravatar image

updated 2013-05-24 17:54:19 -0500

Hi,

I am trying to set a session environment variable in order for other resources to use the location of a .exe file.

In this case i am expecting that the notify prints the new updated $path

exec { 'modify path':
  command => 'C:\Windows\System32\cmd.exe /k set PATH="C:\Hello World\bin;%path%"',
  logoutput => true

}

notify {"The new path is ${path} ":
    withpath => true,
    require => Exec['modify path']
}
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
3

answered 2013-05-28 23:57:17 -0500

jgoldschrafe gravatar image

updated 2013-05-28 23:58:15 -0500

There's three things going on here that I can see.

The first is, I think, that your mental model of what Puppet's actually doing isn't quite mapping to the way Puppet is designed, and that's going to bite you down the road. When you invoke the Puppet agent to perform a run, it calls Facter one time and determines some basic pieces of information about your system. It passes that to the Puppetmaster, which parses all of your manifest files and sends back data about what resources should be defined on your host. It does this ... (more)

edit flag offensive delete link more

Comments

I think i was doing #1 but it doesn't look for presentations :). I guess i will use #3. Thank you so much for a great explanation.

louis gravatar imagelouis ( 2013-05-29 09:07:59 -0500 )edit
0

answered 2013-05-27 13:56:05 -0500

louis gravatar image

I understand that setx might help you when you need to add user/system environment variables. But the thing is that puppet need to use my own session defined environment variables between execution of dependent modules.

For example:

I have a module that installs mercurial and adds the hg.exe directory path to the PATH system environment. However, if something use hg.exe like the Puppet VcsRepo Module then it expects that you already have it on the PATH and that is the reason why i need to use session environment variables.

I am not sure if the $path facter ... (more)

edit flag offensive delete link more
0

answered 2013-05-27 11:54:09 -0500

dgmorales gravatar image

That's because with that cmd command you are changing the PATH only for that cmd session. It's not a problem in Puppet or the puppet code per se.

Google for "windows permanently set path from cmd", and will you find nice questions on stackoverflow about that (I can't post the links, have insufficient karma for that).

It seems there a new command setx that you can use for that.

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

1 follower

Stats

Asked: 2013-05-23 20:33:17 -0500

Seen: 1,135 times

Last updated: May 28 '13