On Thursday, September 6, 2012 6:26:39 AM UTC-5, Fabrice Bacchella wrote:
>
> I tried to conditionally run etckeeper at the end of a puppet run.
>
> For that I defined the following class :
> class os::etckeeper::commit {
> $cmd = "$operatingsystem" ? {
> 'debian' => '/usr/sbin/etckeeper',
> default => '/usr/bin/etckeeper',
> }
> exec {"etckeeper commit":
> command => "${cmd} commit -m 'puppet run'",
> cwd => "/etc",
> provider => 'posix',
> returns => [0,1],
> refreshonly => true,
> }
> File <| |> ~> Exec['etckeeper commit']
> User <| |> ~> Exec['etckeeper commit']
> Group <| |> ~> Exec['etckeeper commit']
> Service <| |> ~> Exec['etckeeper commit']
> }
>
>
>
> But with the file selector, it fails with :
> err: Could not retrieve catalog from remote server: Error 400 on SERVER:
> undefined method `<<' for {}:Hash on node mynode
>
> If I removed only this one, everything is fine.
>
> What might prevent the file selector to work ?
>
According to the language docs, "Control variables in selectors must be *
variables* or *functions that return values.* You cannot use expressions as
control variables" (emphasis in the original). Putting quotes around
$operatingsystem makes the result an expression instead of a variable.
Remove them, and I think you'll be fine.
I confess I find that behavior a little surprising, and I had to look it
up. If it bothers you sufficiently, then you could consider filing an RFE
ticket.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/YsariX0Pd40J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.