Set Environment Variables with Puppet

bgrantdev picture bgrantdev · Aug 23, 2013 · Viewed 35.2k times · Source

I am using vagrant with puppet to set up virtual machines for development environments. I would like to simply set a few environment variables in the .pp file. Using virtual box and a vagrant base box for Ubuntu 64 bit.

I have this currently.

$bar = 'bar'

class foobar {
   exec { 'foobar':
     command => "export Foo=${bar}",
   }
}

but when provisioning I get an error: Could not find command 'export'.

This seems like it should be simple enough am I missing some sort of require or path for the exec type? I noticed in the documentation there is an environment option to set up environment variables, should I be using that?

Answer

John picture John · Aug 24, 2013

If you only need the variables available in the puppet run, whats wrong with :

Exec { environment => [ "foo=$bar" ] }

?