Skip to content

Instantly share code, notes, and snippets.

@ccooke
Last active March 14, 2024 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccooke/20dc9c44f5967324090eee5a7abd6c90 to your computer and use it in GitHub Desktop.
Save ccooke/20dc9c44f5967324090eee5a7abd6c90 to your computer and use it in GitHub Desktop.
class collections::file_test {
# This resource will create File['tmp/collections-file-test'],
# setting content => template('collections/file-test.erb'),
# with a $data variable merging the stanza below with all of the
# following fragments.
collections::file { '/tmp/collections-file-test':
collector => 'file-test',
template => 'collections/file-test.erb',
data => {
list => [ 1 ],
hash => { one => 1 }
}
}
collections::file::fragment { 'Add two':
target => 'file-test',
data => {
list => [ 2 ],
hash => { two => 2 },
repl => { not_two => 7 }
}
}
collections::file::fragment { 'Overwrite':
target => 'file-test',
data => {
hash => { one => 3 },
repl => { not_two => 2 }
}
}
# With a template of "<%= @data -%>", this creates File['/tmp/collections-file-test']
# with content set to:
# {"hash"=>{"one"=>3, "two"=>2}, "repl"=>{"not_two"=>2}, "list"=>[2, 1]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment