hello_world

pdk
Example puppet 5 module with complete test coverage.

Tim Gurney

tgurney

4,244 downloads

4,244 latest version

5.0 quality score

Version information

  • 0.1.0 (latest)
released May 15th 2018
This version is compatible with:
  • Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >= 4.7.0 < 6.0.0
  • CentOS
    ,
    Debian
    ,
    Ubuntu

Start using this module

Documentation

tgurney/hello_world — version 0.1.0 May 15th 2018

Build Status Software License Release Github commits (since latest release) GitHub repo size in bytes GitHub contributors

hello_world

This 'hello world' module has been written as a demonstration of how to write a puppet 5 module which includes a full set of testing.

It has been built using the Puppet Development Kit (PDK) and was created using the following commands:

pdk new module hello_world

pdk new class hello_world

This will create the basic module with a single (empty) class and all of the required files and configuration for the module, this will inculde basic testing, travel and gitlab ci based configuration and much more.

The default directory structure that is generated is:

.
├── examples
├── files
├── manifests
├── spec
│   └── classes
├── tasks
└── templates

The default rake configuration that is generated is:

rake beaker                                  # Run beaker acceptance tests
rake beaker:sets                             # List available beaker nodesets
rake beaker:ssh[set,node]                    # Try to use vagrant to login to the Beaker node
rake build                                   # Build puppet module package
rake check:dot_underscore                    # Fails if any ._ files are present in directory
rake check:git_ignore                        # Fails if directories contain the files specified in .gitignore
rake check:symlinks                          # Fails if symlinks are present in directory
rake check:test_file                         # Fails if .pp files present in tests folder
rake clean                                   # Clean a built module package
rake compute_dev_version                     # Print development version of module
rake help                                    # Display the list of available rake tasks
rake lint                                    # Run puppet-lint
rake metadata_lint                           # Run metadata-json-lint
rake module:bump                             # Bump module version to the next patch
rake module:bump:full                        # Bump module version to the next FULL version
rake module:bump:major                       # Bump module version to the next MAJOR version
rake module:bump:minor                       # Bump module version to the next MINOR version
rake module:bump:patch                       # Bump module version to the next PATCH version
rake module:bump_commit                      # Bump version and git commit
rake module:bump_commit:full                 # Bump module version to the next FULL version and git commit
rake module:bump_commit:major                # Bump module version to the next MAJOR version and git commit
rake module:bump_commit:minor                # Bump module version to the next MINOR version and git commit
rake module:bump_commit:patch                # Bump module version to the next PATCH version and git commit
rake module:clean                            # Runs clean again
rake module:dependency[module_name,version]  # Set specific module dependency version
rake module:push                             # Push module to the Puppet Forge
rake module:release                          # Release the Puppet module, doing a clean, build, tag, push, bump_commit and git push
rake module:tag                              # Git tag with the current module version
rake module:version                          # Get current module version
rake module:version:next                     # Get next module version
rake module:version:next:major               # Get the next MAJOR version
rake module:version:next:minor               # Get the next MINOR version
rake module:version:next:patch               # Get the next PATCH version
rake parallel_spec                           # Parallel spec tests
rake release_checks                          # Runs all necessary checks on a module in preparation for a release
rake rubocop                                 # Run RuboCop
rake rubocop:auto_correct                    # Auto-correct RuboCop offenses
rake spec                                    # Run spec tests and clean the fixtures directory if successful
rake spec_clean                              # Clean up the fixtures directory
rake spec_list_json                          # List spec tests in a JSON document
rake spec_prep                               # Create the fixtures directory
rake spec_standalone                         # Run RSpec code examples
rake syntax                                  # Syntax check Puppet manifests and templates
rake syntax:hiera                            # Syntax check Hiera config files
rake syntax:manifests                        # Syntax check Puppet manifests
rake syntax:templates                        # Syntax check Puppet templates
rake validate                                # Check syntax of Ruby files and call :syntax and :metadata_lint

For more information read the following:

Additional configuration was then added to allow for unit and integration testing, all of which can be run from rake.

rake beaker                                  # Run beaker acceptance tests
rake beaker:centos-6-docker                  # Run the Beaker acceptance tests for the node set 'centos-6-docker'
rake beaker:centos-6-vagrant                 # Run the Beaker acceptance tests for the node set 'centos-6-vagrant'
rake beaker:centos-7-docker                  # Run the Beaker acceptance tests for the node set 'centos-7-docker'
rake beaker:centos-7-vagrant                 # Run the Beaker acceptance tests for the node set 'centos-7-vagrant'
rake beaker:debian-7-docker                  # Run the Beaker acceptance tests for the node set 'debian-7-docker'
rake beaker:debian-7-vagrant                 # Run the Beaker acceptance tests for the node set 'debian-7-vagrant'
rake beaker:debian-8-docker                  # Run the Beaker acceptance tests for the node set 'debian-8-docker'
rake beaker:debian-8-vagrant                 # Run the Beaker acceptance tests for the node set 'debian-8-vagrant'
rake beaker:debian-9-docker                  # Run the Beaker acceptance tests for the node set 'debian-9-docker'
rake beaker:default                          # Run the Beaker acceptance tests for the node set 'default'
rake beaker:default-docker                   # Run the Beaker acceptance tests for the node set 'default-docker'
rake beaker:default-vagrant                  # Run the Beaker acceptance tests for the node set 'default-vagrant'
rake beaker:sets                             # List available beaker nodesets
rake beaker:ssh[set,node]                    # Try to use vagrant to login to the Beaker node
rake beaker:ssh:centos-6-docker[node]        # Use vagrant to login to a node from the set 'centos-6-docker'
rake beaker:ssh:centos-6-vagrant[node]       # Use vagrant to login to a node from the set 'centos-6-vagrant'
rake beaker:ssh:centos-7-docker[node]        # Use vagrant to login to a node from the set 'centos-7-docker'
rake beaker:ssh:centos-7-vagrant[node]       # Use vagrant to login to a node from the set 'centos-7-vagrant'
rake beaker:ssh:debian-7-docker[node]        # Use vagrant to login to a node from the set 'debian-7-docker'
rake beaker:ssh:debian-7-vagrant[node]       # Use vagrant to login to a node from the set 'debian-7-vagrant'
rake beaker:ssh:debian-8-docker[node]        # Use vagrant to login to a node from the set 'debian-8-docker'
rake beaker:ssh:debian-8-vagrant[node]       # Use vagrant to login to a node from the set 'debian-8-vagrant'
rake beaker:ssh:debian-9-docker[node]        # Use vagrant to login to a node from the set 'debian-9-docker'
rake beaker:ssh:default[node]                # Use vagrant to login to a node from the set 'default'
rake beaker:ssh:default-docker[node]         # Use vagrant to login to a node from the set 'default-docker'
rake beaker:ssh:default-vagrant[node]        # Use vagrant to login to a node from the set 'default-vagrant'
rake beaker:ssh:ubuntu-14.04-docker[node]    # Use vagrant to login to a node from the set 'ubuntu-14.04-docker'
rake beaker:ssh:ubuntu-14.04-vagrant[node]   # Use vagrant to login to a node from the set 'ubuntu-14.04-vagrant'
rake beaker:ssh:ubuntu-16.04-docker[node]    # Use vagrant to login to a node from the set 'ubuntu-16.04-docker'
rake beaker:ssh:ubuntu-16.04-vagrant[node]   # Use vagrant to login to a node from the set 'ubuntu-16.04-vagrant'
rake beaker:ubuntu-14.04-docker              # Run the Beaker acceptance tests for the node set 'ubuntu-14.04-docker'
rake beaker:ubuntu-14.04-vagrant             # Run the Beaker acceptance tests for the node set 'ubuntu-14.04-vagrant'
rake beaker:ubuntu-16.04-docker              # Run the Beaker acceptance tests for the node set 'ubuntu-16.04-docker'
rake beaker:ubuntu-16.04-vagrant             # Run the Beaker acceptance tests for the node set 'ubuntu-16.04-vagrant'
rake build                                   # Build puppet module package
rake check:dot_underscore                    # Fails if any ._ files are present in directory
rake check:git_ignore                        # Fails if directories contain the files specified in .gitignore
rake check:symlinks                          # Fails if symlinks are present in directory
rake check:test_file                         # Fails if .pp files present in tests folder
rake clean                                   # Clean a built module package
rake compute_dev_version                     # Print development version of module
rake help                                    # Display the list of available rake tasks
rake lint                                    # Run puppet-lint
rake metadata_lint                           # Run metadata-json-lint
rake module:bump                             # Bump module version to the next patch
rake module:bump:full                        # Bump module version to the next FULL version
rake module:bump:major                       # Bump module version to the next MAJOR version
rake module:bump:minor                       # Bump module version to the next MINOR version
rake module:bump:patch                       # Bump module version to the next PATCH version
rake module:bump_commit                      # Bump version and git commit
rake module:bump_commit:full                 # Bump module version to the next FULL version and git commit
rake module:bump_commit:major                # Bump module version to the next MAJOR version and git commit
rake module:bump_commit:minor                # Bump module version to the next MINOR version and git commit
rake module:bump_commit:patch                # Bump module version to the next PATCH version and git commit
rake module:clean                            # Runs clean again
rake module:dependency[module_name,version]  # Set specific module dependency version
rake module:push                             # Push module to the Puppet Forge
rake module:release                          # Release the Puppet module, doing a clean, build, tag, push, bump_commit and git push
rake module:tag                              # Git tag with the current module version
rake module:version                          # Get current module version
rake module:version:next                     # Get next module version
rake module:version:next:major               # Get the next MAJOR version
rake module:version:next:minor               # Get the next MINOR version
rake module:version:next:patch               # Get the next PATCH version
rake parallel_spec                           # Parallel spec tests
rake release_checks                          # Runs all necessary checks on a module in preparation for a release
rake rubocop                                 # Run RuboCop
rake rubocop:auto_correct                    # Auto-correct RuboCop offenses
rake spec                                    # Run spec tests and clean the fixtures directory if successful
rake spec_clean                              # Clean up the fixtures directory
rake spec_list_json                          # List spec tests in a JSON document
rake spec_prep                               # Create the fixtures directory
rake spec_standalone                         # Run RSpec code examples
rake syntax                                  # Syntax check Puppet manifests and templates
rake syntax:hiera                            # Syntax check Hiera config files
rake syntax:manifests                        # Syntax check Puppet manifests
rake syntax:templates                        # Syntax check Puppet templates
rake validate                                # Check syntax of Ruby files and call :syntax and :metadata_lint

Purely for demonstration purposes beaker tests have been added using both vagrant and docker, whereas in normal circumstances you would most likely select one of these for your testing.

Managing your module going forward will not be covered in this demo, how you manage your code, and how you test/release the module is beyond the scope of this project, this is a simple demo of a puppet 5 module with minimal testing (unit / integration) to use a reference or starting point for writing your own modules.