1 Puppet::Type.newtype(:concat_fragment) do
2 @doc = "Create a concat fragment to be used by concat.
3 the `concat_fragment` type creates a file fragment to be collected by concat based on the tag.
4 The example is based on exported resources.
7 @@concat_fragment { \"uniqe_name_${::fqdn}\":
9 order => 10, # Optional. Default to 10
10 content => 'some content' # OR
11 content => template('template.erb') # OR
12 source => 'puppet:///path/to/file'
16 newparam(:name, :namevar => true) do
36 fail Puppet::ParseError, '$order is not a string or integer.' if !(val.is_a? String or val.is_a? Integer)
37 fail Puppet::ParseError, "Order cannot contain '/', ':', or '\n'." if val.to_s =~ /[:\n\/]/
42 desc "Tag name to be used by concat to collect all concat_fragments by tag name"
46 if catalog.resources.select {|x| x.class == Puppet::Type.type(:concat_file) and (x[:path] == self[:target] || x.title == self[:target]) }.empty?
47 warning "Target Concat_file with path of #{self[:target]} not found in the catalog"
52 # Check if target is set
53 fail Puppet::ParseError, "Target not set" if self[:target].nil?
56 fail Puppet::ParseError, "Tag not set" if self[:tag].nil?
58 # Check if either source or content is set. raise error if none is set
59 fail Puppet::ParseError, "Set either 'source' or 'content'" if self[:source].nil? && self[:content].nil?
61 # Check if both are set, if so rais error
62 fail Puppet::ParseError, "Can't use 'source' and 'content' at the same time" if !self[:source].nil? && !self[:content].nil?