It just occurred to me that it's weird that roles have a totally different DSL for attributes than cookbooks, and we should take a moment to think about how attributes should work in policyfiles. In this gist are two examples, one "role style" and one "cookbook style". Let me know what you like best (but remember there's no notifications for gist comments so you have to use some other medium to make sure I see your comments).
Last active
August 29, 2015 14:18
-
-
Save danielsdeleo/4ba0124fb96968adc338 to your computer and use it in GitHub Desktop.
Attributes Styles in Policyfiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name "cookbook-attribute-style-policy" | |
run_list "foo" | |
default_source :community | |
# This is the cookbook attribute DSL. You get auto-vivification: | |
default["abc"]["def"]["ghi"] = "xyz" | |
# basic attribute setting: | |
default["foo"] = "bar" | |
# you can pass in literal data structures (as long as they're one level deep) | |
default["baz"] = { | |
"more_nested_stuff" => "yup" | |
} | |
default["baz"]["an_array"] = ["a", "b", "c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name "role-style-policy-attrs" | |
run_list "foo" | |
default_source :community | |
# This is the same as the role DSL. You have to set | |
# everything at once (more or less). There is no auto-vivify | |
default_attributes "foo" => "bar", | |
"baz" => { | |
"more_nested_stuff" => "yup", | |
"an_array" => ["a", "b", "c"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment