puppet bug in File selector ?

25 views
Skip to first unread message

Fabrice Bacchella

unread,
Sep 6, 2012, 7:26:39 AM9/6/12
to puppet...@googlegroups.com
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 ?

Is that a bug in puppet or in my head ?

jcbollinger

unread,
Sep 7, 2012, 10:37:51 AM9/7/12
to puppet...@googlegroups.com


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

Reply all
Reply to author
Forward
0 new messages