PaulM
PaulM

Reputation: 79

How to implement constants across custom resources in Chef?

I am writing a cookbook that defines four custom resources. There are multiple constants that should be shared across all of the resources (permissions for certain types of files, prefixes for names, relative paths etc...).

How can I share these constants across multiple custom resources?

Upvotes: 1

Views: 393

Answers (1)

coderanger
coderanger

Reputation: 54181

Put em' in a module under libraries/default.rb:

module MyCookbook
  BASE_PATH = '/foo'
end

# And then in the resource
property(:path, default: MyCookbook::BASE_PATH)

or somesuch.

Upvotes: 5

Related Questions