- Mastering Puppet 5
- Ryan Russell Yates Jason Southgate
- 119字
- 2021-07-16 17:46:16
Using the desc method to add inline documentation
Users of your new type can use the puppet describe and puppet doc commands to fetch the inline documentation you've configured. For a full description of all the types currently configured in your environment, including custom resources, run the following command:
$ puppet describe –list
Let's finish our type example now by adding some inline documentation using the desc method:
Puppet::Type.newtype(:mynewtype) do
ensurable
newparam(:override) do
desc 'whether or not to override'
defaultto :true
newvalues(:true, :false)
end
newproperty(:version) do
desc 'the version to use for mynewtype'
validate do |value|
fail("Invalid version") unless value =~
/^(\d+\.)?(\d+\.)?(\*|\d+)$/
end
end
newparam(:identifier) do
desc 'the identifier for mynewtype'
munge do |value|
Integer(value)
end
end
end