On Thursday, April 30, 2015 at 1:00:45 PM UTC-5, Christopher Wood wrote:
>
> I'm trying to pass ensure=> values in variables (and set resource defaults
> conditionally) and it doesn't seem to work that way. If there's some way of
> getting this working I am very happy to hear about it.
>
> In my site.pp I have this sort of thing:
>
> if $::devstyle and str2bool($::devstyle) {
> notify { 'et': message => 'devstyle on' }
>
> File {
> ensure => present,
> }
> $filefe = present
> }
> else {
> $filefe = file
> }
>
> The idea is that puppet will treat all file resources as ensure=>present
> anywhere that devstyle=true (it's an external fact). I do see the notify
> text in syslog when the agent run proceeds.
>
> However, two things are not happening:
>
> 1) not getting the resource default when the resource does not have
> ensure=>
> (puppet reverts my manually modified file)
>
> 2) ensure => $::filefe is not ensuring 'present' when devstyle=true
> (special corporate bits censored out):
>
> notify { 'mrt1':
> message => "filefe=${::filefe}"
> }
>
> file { '/etc/mrouted.conf':
> ensure => $::filefe,
> content => "whatever\n",
> }
>
> The notify reports the expected value of $::filefe is as I expect, but the
> file's contents are still managed.
>
>
Yes. You have specified that it should be so.
Evidently you have a misconception about the meaning of 'ensure =>
present'. That does *not* mean "ignore all the other properties specified
for this resource". It means only "I don't care whether the target is a
directory, symlink, or regular file, so long as it's present". It is
unusual to combine that with any value for 'content', as doing so implies
that you *do* care what kind of filesystem object it is: it must be a
regular file or a symlink pointing to a regular file.
Possibly you are looking for `replace => false`, instead.
John
--
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/4b6d2e84-5b00-4af6-90fa-86b2a4fcab6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.