Reputation: 10460
I was wondering how one would do try/catch/throw type exception handling in a puppet manifest. Here's how I wish puppet would work ...
class simple {
unless ( package { 'simple': ensure => present } ) {
file { '/tmp/simple.txt':
content => template( 'simple/simple.erb' ),
}
}
}
Thanks
Upvotes: 1
Views: 3558
Reputation: 2966
I don't think there is an exception handling in a programmatic way you would like in Puppet. If you declare a resource, it is expected that puppet brings your machine to that state (installed package) and if not, it will fail automatically. One thing that you can do (and I don't recommend) and that is not "puppet way" is following:
Also, if easier, you can write bash script which will do this logic and execute it from puppet using exec resource
Hope it helps.
Upvotes: 2