Created
December 19, 2011 18:07
-
-
Save nadavoid/1498207 to your computer and use it in GitHub Desktop.
Puppet Conditional in Template
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
--- | |
parameters: | |
server_tags: "role:all=true,role:dev=true" |
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
# filename ends with .rb, not .pp. | |
# see http://docs.puppetlabs.com/guides/custom_facts.html | |
# see http://www.scribd.com/doc/56291200/63/Puppet-Using-Facter-and-Templates | |
# see Pro Puppet, chapter 10 "Extending Facter and Puppet" | |
Facter.add("some_custom_fact") do | |
setcode do | |
'Some custom data piece. Possibly an IP address.' | |
end | |
end |
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
# To call the `has_role` function, you must prefix it with `function_`, | |
# and send it to the `scope` object. | |
# So, `has_role('foo')` becomes `scope.function_has_role('foo')`. | |
# `has_role` is a function added by the truth module. | |
<% if scope.function_has_role('dev') %> | |
# facts, including those set by ENCs, are available. | |
# some_custom_fact is a custom fact created by a custom module. | |
allow <%= some_custom_fact %>; | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment