Exec resource and environment parameter

48 views
Skip to first unread message

Felipe Salum

unread,
Oct 10, 2012, 4:52:06 PM10/10/12
to puppet...@googlegroups.com
I'm trying to use the environment parameter on Exec but it is not working. Any idea what's wrong ?

exec { 'test':
     path        => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
     environment => ["HOME=test", "HOME2=test2"],
    command    => "echo $HOME > /tmp/key",
    user        => 'root',
    group      => 'root',
   }

I'm using Puppet 3.0

Thanks,
Felipe

Tom

unread,
Oct 11, 2012, 2:52:18 AM10/11/12
to puppet...@googlegroups.com, Felipe Salum
On 10/10/12 21:52, Felipe Salum wrote:
> exec { 'test':
> path =>
> '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
> environment => ["HOME=test", "HOME2=test2"],
> command => "echo $HOME > /tmp/key",
> user => 'root',
> group => 'root',
> }
Hi. You need to escape the $ character!

For instance: "echo \$HOME > /tmp/key"

If you had defined $HOME within your manifest, then that would be the
value that puppet substituted:

$HOME = 'HI'
exec { 'test':
path =>
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
environment => ["HOME=test", "HOME2=test2"],
command => "echo $HOME > /tmp/key",
user => 'root',
group => 'root',
}


Cheers. Tom.
Reply all
Reply to author
Forward
0 new messages