On Wed, Dec 10, 2014 at 1:35 AM, Gianmarco Carrieri <
[email protected]> wrote:
> Hi all,
>
> sorry if this is a repost, i need to use a windows env in the
> configuration of puppet.
>
> this is a piece of my conf:
>
> file { "Mozilla":
> ensure => "directory",
> recurse => "true",
> path => "%appdata%",
> purge => true,
> force => true,
> source => "puppet:///modules/winpc/Firefox_Profiles",
> # source_permissions => 'ignore'
> }
>
> how i can use the env variable %appdata%
>
You'll need to create a custom fact that contains the path. This can be
done in ruby like:
Facter.add(:local_appdata) do
confine :kernel => :windows
setcode do
require 'win32/dir'
Dir::LOCAL_APPDATA
end
or whichever well-known folder you're looking for. The constants are
defined in the win32-dir gem[1]. Then in your manifest, you would need to
do:
path => $::local_appdata
Note that you need specify the complete path for the process, not just a
single directory. For example, if you apply the following resource:
exec { 'c:\windows\sysnative\cmd.exe /c echo %PATH%':
path => 'c:\windows\system32',
logoutput => true
}
You'll see that PATH for the process is only 'c:\windows\system32':
C:\>puppet apply c:\path.pp
...
Notice: /Stage[main]/Main/Exec[c:\windows\sysnative\cmd.exe /c echo
%PATH%]/returns: c:\windows\system32
So you'll want to do something like:
path => $::local_appdata;$path
where `$path` refers to the built-in fact[2].
> thanks in advance and sorry for my english. :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/3530a4eb-8277-4841-97ac-16dcdfb1d4ac%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/3530a4eb-8277-4841-97ac-16dcdfb1d4ac%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
Josh
[1] https://github.com/djberg96/win32-dir/blob/ffi/lib/win32/dir.rb#L14-L70
[2] https://docs.puppetlabs.com/facter/2.3/core_facts.html#path
--
Josh Cooper
Developer, Puppet Labs
*Join us at **PuppetConf 2015, October 5-9 in Portland, OR - *
http://2015.puppetconf.com.
*Register early to save 40%!*
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/CA%2Bu97ungHq3oVfcvraOmWxsO90c99XYd2MKnAafyZo5Tj%2BiS3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.