puppetlabs / puppet-specifications

Specification of the Puppet Language, Catalog, Extension points
Other
99 stars 66 forks source link

Add Module layout specification #157

Closed bastelfreak closed 4 months ago

bastelfreak commented 10 months ago

This document describes all files/directories that are allowed or mandatory within a module. The forge can use it as an allowlist and filter other files out. r10k/code-manager can use it as an allowlist as well when modules are pulled from version controll systems like github (similar to the --exclude-spec option in r10k).

donoghuc commented 10 months ago

This is a good start. i would like to see bolt_plugin.json added as well https://www.puppet.com/docs/bolt/latest/writing_plugins.html but having this as a point of reference will be helpful.

bastelfreak commented 10 months ago

@donoghuc thanks for the hint, I added it.

Ramesh7 commented 10 months ago

Just a thought : as we have consider bolt scenario here so should we consider below 2 files also to be part of specification ?

donoghuc commented 9 months ago

@Ramesh7 no those are for bolt projects. A bolt project is not a module. This spec is for modules.

joshcooper commented 7 months ago

Thoughts on adding more RFC2119 style descriptions to further explain what to expect within a module?

:+1: from me. Technically puppet accepts an empty module directory:

$ mkdir /home/josh/.puppetlabs/etc/code/environments/production/modules/foo

$ cat mod.rb 
require 'puppet'
Puppet.initialize_settings
Puppet::Util::Log.newdestination(:console)
Puppet::ApplicationSupport.push_application_context(Puppet::Util::RunMode[:user])
envs = Puppet.lookup(:environments)
env = envs.get!('production')
puts Puppet::Module.find('foo', env)

$ bx ruby mod.rb                                                          
Module foo(/home/josh/.puppetlabs/etc/code/environments/production/modules/foo)

I believe the only strict requirement is the module name must satisfy https://github.com/puppetlabs/puppet/blob/49d74c94c848d4d4f4d022b58ff8135b2f46e7b0/lib/puppet/module.rb#L481

If the module contains metadata.json (which it should), then it must contain these keys https://github.com/puppetlabs/puppet/blob/49d74c94c848d4d4f4d022b58ff8135b2f46e7b0/lib/puppet/module.rb#L253 and the dependencies key must contain a (possible empty) list of modules it depends on.