Set Environment Variables with Puppet

2020-02-10 02:18发布

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?

7条回答
beautiful°
2楼-- · 2020-02-10 03:03

You could try the following, which sets the environment variable for this exec:

class foobar {
   exec { 'foobar' :
     command => "/bin/bash -c \"export Foo=${bar}\"",
   }
}
查看更多
登录 后发表回答