Method: Puppet::Type#autorelation
- Defined in:
- lib/puppet/type.rb
#autorelation(rel_type, rel_catalog = nil) ⇒ Object
TODO:
needs details - see the param rel_catalog, and type of this param
Adds dependencies to the catalog from added autorelations. See autorequire for how to add an auto-requirement.
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 |
# File 'lib/puppet/type.rb', line 2076 def autorelation(rel_type, rel_catalog = nil) rel_catalog ||= catalog raise Puppet::DevError, _("You cannot add relationships without a catalog") unless rel_catalog reqs = [] auto_rel = "eachauto#{rel_type}".to_sym self.class.send(auto_rel) { |type, block| # Ignore any types we can't find, although that would be a bit odd. next unless Puppet::Type.type(type) # Retrieve the list of names from the block. list = instance_eval(&block) next unless list list = [list] unless list.is_a?(Array) # Collect the current prereqs list.each { |dep| next if dep.nil? # Support them passing objects directly, to save some effort. unless dep.is_a?(Puppet::Type) # Skip autorelation that we aren't managing dep = rel_catalog.resource(type, dep) next unless dep end if [:require, :subscribe].include?(rel_type) reqs << Puppet::Relationship.new(dep, self) else reqs << Puppet::Relationship.new(self, dep) end } } reqs end |