Ask Your Question
0

Is there a "failing autorequire" for custom type developement?

asked 2016-01-05 21:15:39 -0500

Arney gravatar image

A resource of this minimal custom type

Puppet::Type.newtype(:database) do
  autorequire(:file) do
    '/etc/my.conf'
  end
end

will ...

  • be synced after File['/etc/my.conf'] if the latter is defined
  • be synced without failure otherwise

Question: Can I cause the compilation to fail if File['/etc/my.conf'] is not defined?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-01-06 00:20:56 -0500

You can say:

unless defined(File['/etc/my.conf']) {
  fail("expected catalog to contain File['/etc/my.conf']")
}
edit flag offensive delete link more

Comments

D'Oh, I should [RTFM](https://docs.puppetlabs.com/references/latest/function.html#defined), thanks!

Arney gravatar imageArney ( 2016-01-07 04:36:36 -0500 )edit

It helps knowing where to look. :)

Alex Harvey gravatar imageAlex Harvey ( 2016-01-07 05:33:35 -0500 )edit

... but then again this only works in manifests, not in custom types ...

Arney gravatar imageArney ( 2016-01-12 18:08:22 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-01-05 21:15:39 -0500

Seen: 49 times

Last updated: Jan 06 '16