Last active
July 2, 2018 09:57
-
-
Save DavidS/82ff0a8b667b76f6a0b3c5d262be958f to your computer and use it in GitHub Desktop.
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
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.', | |
}, | |
}, | |
) |
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
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