Skip to content

Instantly share code, notes, and snippets.

@DavidS
Last active July 2, 2018 09:57
Show Gist options
  • Save DavidS/82ff0a8b667b76f6a0b3c5d262be958f to your computer and use it in GitHub Desktop.
Save DavidS/82ff0a8b667b76f6a0b3c5d262be958f to your computer and use it in GitHub Desktop.
require 'puppet/resource_api'
Puppet::ResourceApi.register_type(
name: 'file_test',
docs: <<-EOS,
This type provides Puppet with the capabilities to manage ...
EOS
features: [],
title_patterns: [
{
pattern: %r{^(?<target>.*)#(?<key>[^#]*)$},
desc: 'Provide the target and the key in one piece, separated with a hash (`#`). For example: `/etc/puppet/puppet.conf#noop` ',
},
],
attributes: {
ensure: {
type: 'Enum[present, absent]',
desc: 'Whether this resource should be present or absent on the target system.',
default: 'present',
},
target: {
type: 'String',
desc: 'The file containing the record.',
behaviour: :namevar,
},
key: {
type: 'String',
desc: 'The key of the record.',
behaviour: :namevar,
},
value: {
type: 'String',
desc: 'The value of the record.',
},
},
)
david@davids:~/git/david-testmod$ bundle exec puppet resource --modulepath ./spec/fixtures/modules/ file_test "/etc/puppet/puppet.conf#noop"
file_test { '/etc/puppet/puppet.conf#noop':
ensure => 'absent',
target => '/etc/puppet/puppet.conf',
key => 'noop',
}
david@davids:~/git/david-testmod$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment