├── moduleroot_init ├── data │ └── common.yaml ├── .fixtures.yml.erb ├── CHANGELOG.md.erb ├── hiera.yaml.erb └── README.md.erb ├── moduleroot ├── .rspec_parallel.erb ├── .rspec.erb ├── .gitignore.erb ├── .pdkignore.erb ├── .vscode │ └── extensions.json ├── .gitattributes.erb ├── .yardopts.erb ├── .editorconfig.erb ├── spec │ ├── default_facts.yml.erb │ └── spec_helper.rb.erb ├── Dockerfile.erb ├── .github │ ├── PULL_REQUEST_TEMPLATE.md.erb │ ├── ISSUE_TEMPLATE.md.erb │ └── CONTRIBUTING.md.erb ├── .puppet-lint.rc.erb ├── .overcommit.yml.erb ├── voxpupuli_rake_tasks.rb.erb ├── .rubocop.yml.erb ├── appveyor.yml.erb ├── Gemfile.erb ├── .gitlab-ci.yml.erb ├── Rakefile.erb └── .travis.yml.erb ├── CODEOWNERS ├── Gemfile ├── .travis ├── fixtures │ └── new_provider_sync.yml ├── install_pdk.sh └── test_script.sh ├── object_templates ├── defined_type.erb ├── provider_type_spec.erb ├── class_spec.erb ├── transport_type_spec.erb ├── defined_type_spec.erb ├── plan.erb ├── class.erb ├── transport_device.erb ├── transport_type.erb ├── provider.erb ├── provider_type.erb ├── task.erb ├── provider_spec.erb ├── transport.erb └── transport_spec.erb ├── rubocop ├── README.md ├── profile_builder.rb ├── cleanup_cops.yml └── defaults-0.49.1.yml ├── .gitignore ├── NOTICE ├── .travis.yml ├── VP_README.md ├── LICENSE ├── config_defaults.yml └── README.md /moduleroot_init/data/common.yaml: -------------------------------------------------------------------------------- 1 | --- {} 2 | -------------------------------------------------------------------------------- /moduleroot/.rspec_parallel.erb: -------------------------------------------------------------------------------- 1 | --format progress 2 | -------------------------------------------------------------------------------- /moduleroot/.rspec.erb: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Default owners. 2 | * @puppetlabs/pdk @puppetlabs/modules 3 | -------------------------------------------------------------------------------- /moduleroot/.gitignore.erb: -------------------------------------------------------------------------------- 1 | <% (@configs['required'] + (@configs['paths'] || [])).uniq.each do |path| -%> 2 | <%= path %> 3 | <% end -%> 4 | -------------------------------------------------------------------------------- /moduleroot/.pdkignore.erb: -------------------------------------------------------------------------------- 1 | <% (@configs['required'] + (@configs['paths'] || [])).uniq.each do |path| -%> 2 | <%= path %> 3 | <% end -%> 4 | -------------------------------------------------------------------------------- /moduleroot/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "puppet.puppet-vscode", 4 | "rebornix.Ruby" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'rubocop', '= 0.49.1' 4 | gem 'rubocop-rspec', '= 1.15.1' 5 | gem 'rubocop-i18n', '= 1.2.0' 6 | -------------------------------------------------------------------------------- /.travis/fixtures/new_provider_sync.yml: -------------------------------------------------------------------------------- 1 | --- 2 | Gemfile: 3 | optional: 4 | ':development': 5 | - gem: 'puppet-resource_api' 6 | spec/spec_helper.rb: 7 | mock_with: ':rspec' 8 | -------------------------------------------------------------------------------- /moduleroot/.gitattributes.erb: -------------------------------------------------------------------------------- 1 | <% 2 | excludelist = @configs['exclude'] || [] 3 | includelist = @configs['include'] || {} 4 | -%> 5 | <% (includelist.keys - excludelist).each do |key| -%> 6 | <%= key -%> <%= includelist[key] %> 7 | <% end -%> 8 | -------------------------------------------------------------------------------- /object_templates/defined_type.erb: -------------------------------------------------------------------------------- 1 | # @summary A short summary of the purpose of this defined type. 2 | # 3 | # A description of what this defined type does 4 | # 5 | # @example 6 | # <%= name %> { 'namevar': } 7 | define <%= name %> ( 8 | ) { 9 | } 10 | -------------------------------------------------------------------------------- /moduleroot_init/.fixtures.yml.erb: -------------------------------------------------------------------------------- 1 | # This file can be used to install module dependencies for unit testing 2 | # See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details 3 | --- 4 | fixtures: 5 | forge_modules: 6 | # stdlib: "puppetlabs/stdlib" 7 | -------------------------------------------------------------------------------- /moduleroot/.yardopts.erb: -------------------------------------------------------------------------------- 1 | <% if !@configs.nil? && @configs.has_key?('markup') -%> 2 | <%= "--markup #{@configs['markup']}" %> 3 | <% end -%> 4 | <% if !@configs.nil? && @configs.has_key?('optional') -%> 5 | <% @configs['optional'].each do |arg| -%> 6 | <%= arg %> 7 | <% end -%> 8 | <% end -%> 9 | -------------------------------------------------------------------------------- /moduleroot_init/CHANGELOG.md.erb: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## Release <%= @configs['module_metadata']['version'] rescue '[moduleversion]' %> 6 | 7 | **Features** 8 | 9 | **Bugfixes** 10 | 11 | **Known Issues** 12 | -------------------------------------------------------------------------------- /object_templates/provider_type_spec.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | require 'puppet/type/<%= name %>' 5 | 6 | RSpec.describe 'the <%= name %> type' do 7 | it 'loads' do 8 | expect(Puppet::Type.type(:<%= name %>)).not_to be_nil 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /moduleroot/.editorconfig.erb: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | # MANAGED BY MODULESYNC 4 | 5 | root = true 6 | 7 | [*] 8 | charset = utf-8 9 | end_of_line = lf 10 | indent_size = 2 11 | tab_width = 2 12 | indent_style = space 13 | insert_final_newline = true 14 | trim_trailing_whitespace = true 15 | -------------------------------------------------------------------------------- /rubocop/README.md: -------------------------------------------------------------------------------- 1 | # Building Rubocop default profile 2 | 3 | To build the default profile for your version of rubocop, run: 4 | 5 | ``` 6 | bundle exec profile_builder.rb 7 | ``` 8 | 9 | This will build the enabled cops for this version of rubocop. 10 | 11 | Do NOT manually update default profile! 12 | -------------------------------------------------------------------------------- /object_templates/class_spec.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe '<%= name %>' do 6 | on_supported_os.each do |os, os_facts| 7 | context "on #{os}" do 8 | let(:facts) { os_facts } 9 | 10 | it { is_expected.to compile } 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /object_templates/transport_type_spec.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | require 'puppet/transport/schema/<%= name %>' 5 | 6 | RSpec.describe 'the <%= name %> transport' do 7 | it 'loads' do 8 | expect(Puppet::ResourceApi::Transport.list['<%= name %>']).not_to be_nil 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /object_templates/defined_type_spec.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe '<%= name %>' do 6 | let(:title) { 'namevar' } 7 | let(:params) do 8 | {} 9 | end 10 | 11 | on_supported_os.each do |os, os_facts| 12 | context "on #{os}" do 13 | let(:facts) { os_facts } 14 | 15 | it { is_expected.to compile } 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.sw[op] 2 | *~ 3 | .metadata 4 | .yardoc 5 | .yardwarns 6 | *.iml 7 | /.bundle/ 8 | /.idea/ 9 | /.vagrant/ 10 | /coverage/ 11 | /bin/ 12 | /doc/ 13 | /Gemfile.local 14 | /Gemfile.lock 15 | /junit/ 16 | /log/ 17 | /log/ 18 | /pkg/ 19 | /spec/fixtures/manifests/ 20 | /spec/fixtures/modules/ 21 | /tmp/ 22 | /vendor/ 23 | /convert_report.txt 24 | # Rubocop profile builder temporary files 25 | /rubocop/.rubocop.yml 26 | /rubocop/.rubocop_todo.yml 27 | -------------------------------------------------------------------------------- /object_templates/plan.erb: -------------------------------------------------------------------------------- 1 | # 2 | # Puppet Plan Name: <%= name %> 3 | # 4 | # This is where you put the puppet code for your plan. 5 | # 6 | # You can write Puppet Plans in puppet code 7 | # 8 | # Learn more at: https://puppet.com/docs/bolt/1.x/writing_plans.html 9 | 10 | plan <%= name %> ( 11 | String[1] $parameter1, 12 | TargetSpec $parameter2, 13 | ) { 14 | 15 | run_task('modulename::task_name', $parameter1, some_parameter_name => $parameter2) 16 | } 17 | -------------------------------------------------------------------------------- /moduleroot/spec/default_facts.yml.erb: -------------------------------------------------------------------------------- 1 | # Use default_module_facts.yml for module specific facts. 2 | # 3 | # Facts specified here will override the values provided by rspec-puppet-facts. 4 | --- 5 | ipaddress: "<%= @configs['ipaddress'] %>" 6 | ipaddress6: "<%= @configs['ipaddress6'] %>" 7 | is_pe: <%= @configs['is_pe'] %> 8 | macaddress: "<%= @configs['macaddress'] %>" 9 | <% if !@configs['extra_facts'].nil? -%> 10 | <% require 'yaml' -%> 11 | <%= @configs['extra_facts'].to_yaml[4..-1] %> 12 | <% end -%> 13 | -------------------------------------------------------------------------------- /object_templates/class.erb: -------------------------------------------------------------------------------- 1 | # @summary A short summary of the purpose of this class 2 | # 3 | # A description of what this class does 4 | # 5 | # @example 6 | # include <%= name %> 7 | <%- if params -%> 8 | # 9 | <%- params.each do |param| -%> 10 | # @param <%= param[:name] %> A description of this parameter. 11 | <%- end -%> 12 | class <%= name %> ( 13 | <%- params.each do |param| -%> 14 | <%= param[:type].ljust(max_type_length) %> $<%= param[:name] %>, 15 | <%- end -%> 16 | ) { 17 | <%- else -%> 18 | class <%= name %> { 19 | <%- end -%> 20 | } 21 | -------------------------------------------------------------------------------- /moduleroot/Dockerfile.erb: -------------------------------------------------------------------------------- 1 | FROM ruby:2.5.3 2 | 3 | WORKDIR /opt/puppet 4 | 5 | # https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 6 | RUN mkdir -p /etc/sv 7 | 8 | ARG PUPPET_VERSION="~> 6.0" 9 | ARG PARALLEL_TEST_PROCESSORS=4 10 | 11 | # Cache gems 12 | COPY Gemfile . 13 | RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle} 14 | 15 | COPY . . 16 | 17 | RUN bundle install 18 | RUN bundle exec rake release_checks 19 | 20 | # Container should not saved 21 | RUN exit 1 22 | -------------------------------------------------------------------------------- /moduleroot/.github/PULL_REQUEST_TEMPLATE.md.erb: -------------------------------------------------------------------------------- 1 | 9 | #### Pull Request (PR) description 10 | 13 | 14 | #### This Pull Request (PR) fixes the following issues 15 | 21 | -------------------------------------------------------------------------------- /moduleroot/.github/ISSUE_TEMPLATE.md.erb: -------------------------------------------------------------------------------- 1 | 10 | 11 | ## Affected Puppet, Ruby, OS and module versions/distributions 12 | 13 | - Puppet: 14 | - Ruby: 15 | - Distribution: 16 | - Module version: 17 | 18 | ## How to reproduce (e.g Puppet code you use) 19 | 20 | ## What are you seeing 21 | 22 | ## What behaviour did you expect instead 23 | 24 | ## Output log 25 | 26 | ## Any additional information you'd like to impart 27 | -------------------------------------------------------------------------------- /moduleroot_init/hiera.yaml.erb: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | 4 | defaults: # Used for any hierarchy level that omits these keys. 5 | datadir: data # This path is relative to hiera.yaml's directory. 6 | data_hash: yaml_data # Use the built-in YAML backend. 7 | 8 | hierarchy: 9 | - name: "osfamily/major release" 10 | paths: 11 | # Used to distinguish between Debian and Ubuntu 12 | - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" 13 | - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" 14 | # Used for Solaris 15 | - "os/%{facts.os.family}/%{facts.kernelrelease}.yaml" 16 | - name: "osfamily" 17 | paths: 18 | - "os/%{facts.os.name}.yaml" 19 | - "os/%{facts.os.family}.yaml" 20 | - name: 'common' 21 | path: 'common.yaml' 22 | -------------------------------------------------------------------------------- /object_templates/transport_device.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/resource_api/transport/wrapper' 4 | 5 | # Initialize the NetworkDevice class if necessary 6 | class Puppet::Util::NetworkDevice; end 7 | 8 | # The <%= name.capitalize %> module only contains the Device class to bridge from puppet's internals to the Transport. 9 | # All the heavy lifting is done bye the Puppet::ResourceApi::Transport::Wrapper 10 | module Puppet::Util::NetworkDevice::<%= name.capitalize %> # rubocop:disable Style/ClassAndModuleCamelCase 11 | # Bridging from puppet to the <%= name %> transport 12 | class Device < Puppet::ResourceApi::Transport::Wrapper 13 | def initialize(url_or_config, _options = {}) 14 | super('<%= name %>', url_or_config) 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /moduleroot/.puppet-lint.rc.erb: -------------------------------------------------------------------------------- 1 | <%- 2 | if respond_to?(:config_for) 3 | rakefile_config = config_for('Rakefile') 4 | disabled_checks = [ 5 | rakefile_config['default_disabled_lint_checks'].to_a, 6 | rakefile_config['extra_disabled_lint_checks'].to_a, 7 | ].flatten.uniq 8 | options = rakefile_config['linter_options'].to_a 9 | fail_on_warnings = rakefile_config['linter_fail_on_warnings'] 10 | else 11 | disabled_checks = [] 12 | options = [] 13 | fail_on_warnings = false 14 | end 15 | -%> 16 | <% if fail_on_warnings -%> 17 | --fail-on-warnings 18 | <% end -%> 19 | <% disabled_checks.each do |check_name| -%> 20 | <%- if check_name == 'relative' -%> 21 | --relative 22 | <%- else -%> 23 | --no-<%= check_name %>-check 24 | <%- end -%> 25 | <% end -%> 26 | <% options.each do |option| -%> 27 | --<%= option %> 28 | <% end -%> 29 | -------------------------------------------------------------------------------- /object_templates/transport_type.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/resource_api' 4 | 5 | Puppet::ResourceApi.register_transport( 6 | name: '<%= name %>', 7 | desc: <<-EOS, 8 | This transport provides Puppet with the capability to connect to <%= name %> targets. 9 | EOS 10 | features: [], 11 | connection_info: { 12 | host: { 13 | type: 'String', 14 | desc: 'The hostname or IP address to connect to for this target.', 15 | }, 16 | port: { 17 | type: 'Optional[Integer]', 18 | desc: 'The port to connect to. Defaults to ...', 19 | }, 20 | user: { 21 | type: 'String', 22 | desc: 'The name of the user to authenticate as.', 23 | }, 24 | password: { 25 | type: 'String', 26 | desc: 'The password for the user.', 27 | sensitive: true, 28 | }, 29 | }, 30 | ) 31 | -------------------------------------------------------------------------------- /.travis/install_pdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | 3 | DIST_NAME=$(lsb_release -cs) 4 | RELEASE_DEB="https://apt.puppetlabs.com/puppet-tools-release-${DIST_NAME}.deb" 5 | NIGHTLY_DEB="https://nightlies.puppetlabs.com/apt/puppet-nightly-release-${DIST_NAME}.deb" 6 | 7 | setup_apt() { 8 | local deb_url="${1}" 9 | local deb_file=$(basename "${deb_url}") 10 | 11 | wget "${deb_url}" 12 | sudo dpkg -i "${deb_file}" 13 | } 14 | 15 | main() { 16 | if [ -z "${PDK}" -o "${PDK}" = "release" ]; then 17 | setup_apt "${RELEASE_DEB}" 18 | elif [ "${PDK}" = "nightly" ]; then 19 | setup_apt "${NIGHTLY_DEB}" 20 | else 21 | echo "Unknown \$PDK value '${PDK}'. Supported values are 'release' and 'nightly'." >&2 22 | exit 1 23 | fi 24 | 25 | sudo apt-get update -qq 26 | sudo apt-get install -y pdk 27 | 28 | /usr/local/bin/pdk --version 29 | } 30 | 31 | main "$@" 32 | -------------------------------------------------------------------------------- /object_templates/provider.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/resource_api/simple_provider' 4 | 5 | # Implementation for the <%= name %> type using the Resource API. 6 | class Puppet::Provider::<%= provider_class %>::<%= provider_class %> < Puppet::ResourceApi::SimpleProvider 7 | def get(context) 8 | context.debug('Returning pre-canned example data') 9 | [ 10 | { 11 | name: 'foo', 12 | ensure: 'present', 13 | }, 14 | { 15 | name: 'bar', 16 | ensure: 'present', 17 | }, 18 | ] 19 | end 20 | 21 | def create(context, name, should) 22 | context.notice("Creating '#{name}' with #{should.inspect}") 23 | end 24 | 25 | def update(context, name, should) 26 | context.notice("Updating '#{name}' with #{should.inspect}") 27 | end 28 | 29 | def delete(context, name) 30 | context.notice("Deleting '#{name}'") 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Puppet Development Kit Module Template 2 | 3 | Copyright (C) 2017 Puppet, Inc. 4 | 5 | Puppet Labs can be contacted at: info@puppetlabs.com 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | By applying the templates through the PDK (through `pdk new module`, 20 | `pdk convert`, `pdk update`, or `pdk new ...`) the modifications 21 | required by section 4 (Redistribution) of the LICENSE are fulfilled. 22 | -------------------------------------------------------------------------------- /object_templates/provider_type.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/resource_api' 4 | 5 | Puppet::ResourceApi.register_type( 6 | name: '<%= name %>', 7 | docs: <<-EOS, 8 | @summary a <%= name %> type 9 | @example 10 | <%= name %> { 'foo': 11 | ensure => 'present', 12 | } 13 | 14 | This type provides Puppet with the capabilities to manage ... 15 | 16 | If your type uses autorequires, please document as shown below, else delete 17 | these lines. 18 | **Autorequires**: 19 | * `Package[foo]` 20 | EOS 21 | features: [], 22 | attributes: { 23 | ensure: { 24 | type: 'Enum[present, absent]', 25 | desc: 'Whether this resource should be present or absent on the target system.', 26 | default: 'present', 27 | }, 28 | name: { 29 | type: 'String', 30 | desc: 'The name of the resource you want to manage.', 31 | behaviour: :namevar, 32 | }, 33 | }, 34 | ) 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: linux 3 | dist: xenial 4 | language: generic 5 | env: 6 | - PDK=release PDK_FRONTEND=noninteractive 7 | - PDK=nightly PDK_FRONTEND=noninteractive 8 | before_install: 9 | - ".travis/install_pdk.sh" 10 | script: 11 | - ".travis/test_script.sh" 12 | branches: 13 | only: 14 | - master 15 | notifications: 16 | email: false 17 | slack: 18 | secure: RuLR/yl5FTfo7jDywF/7p6ba2zsP5SEB2jiPLQPwN7VFi8i3kJDsElHVMVQIVD1Ubuuo+LAdCKhugDpgeO/TRBjEfFDAV9IAKb1l61GR4YZv51AUMT4L6PDUeCStDbbuqI1goDIIeZmHo1o2rPmOMLuOkQLB1r84Lre3bNTb9CAQXIqFqQmlVG8FbkaUhArWKHaWE6MWol6WX5Sq3We1nXo12javfDEdATJGzbLSzuwLMt7/oCT40w2WeJBN2+VjFPuLr6lA6UCXuLKCcgUCHl6ibM658calCDP6I14C/NwGFjUMV13PbML6iHgpK2xLUtOEvDSVuBmrmCn/0WVbm332feEOucg+SmI2LF1c+kn/52lnQAwQ17+B0Nl0CXW4de5oR47rvhvhWDJ+9AYHkOokO9Misd7arCLTJ2Z0pvqAysDxVaVQPcIZAsTHeWQPDVe2SHOMVP5LX8nvD3GNQBv7447uO32cDo9QWalLLUFF77uAVNSRgwDSMhHN2NnPV02oCOti0XUIn3Bz2gaqAsoXK2VszwrVk6GR+9rqXmvn+wTg1RizIcq3HuuvXIeDaGt7HYvdYPSC/EWsI+1UKuBhGCN1aiVOgfxyGHSC2WfIefbV4HNDPCbBdZluKWlHFuvUfQzCip3cfj2uyMCpfqPfw0LzrgPELPHwymCGzHY= 19 | -------------------------------------------------------------------------------- /object_templates/task.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Puppet Task Name: <%= name %> 4 | # 5 | # This is where you put the shell code for your task. 6 | # 7 | # You can write Puppet tasks in any language you want and it's easy to 8 | # adapt an existing Python, PowerShell, Ruby, etc. script. Learn more at: 9 | # https://puppet.com/docs/bolt/0.x/writing_tasks.html 10 | # 11 | # Puppet tasks make it easy for you to enable others to use your script. Tasks 12 | # describe what it does, explains parameters and which are required or optional, 13 | # as well as validates parameter type. For examples, if parameter "instances" 14 | # must be an integer and the optional "datacenter" parameter must be one of 15 | # portland, sydney, belfast or singapore then the <% task_name %>.json file 16 | # would include: 17 | # "parameters": { 18 | # "instances": { 19 | # "description": "Number of instances to create", 20 | # "type": "Integer" 21 | # }, 22 | # "datacenter": { 23 | # "description": "Datacenter where instances will be created", 24 | # "type": "Enum[portland, sydney, belfast, singapore]" 25 | # } 26 | # } 27 | # Learn more at: https://puppet.com/docs/bolt/0.x/writing_tasks.html#ariaid-title11 28 | # 29 | -------------------------------------------------------------------------------- /moduleroot/.overcommit.yml.erb: -------------------------------------------------------------------------------- 1 | # Managed by https://github.com/voxpupuli/modulesync_configs 2 | # 3 | # Hooks are only enabled if you take action. 4 | # 5 | # To enable the hooks run: 6 | # 7 | # ``` 8 | # bundle exec overcommit --install 9 | # # ensure .overcommit.yml does not harm to you and then 10 | # bundle exec overcommit --sign 11 | # ``` 12 | # 13 | # (it will manage the .git/hooks directory): 14 | # 15 | # Examples howto skip a test for a commit or push: 16 | # 17 | # ``` 18 | # SKIP=RuboCop git commit 19 | # SKIP=PuppetLint git commit 20 | # SKIP=RakeTask git push 21 | # ``` 22 | # 23 | # Don't invoke overcommit at all: 24 | # 25 | # ``` 26 | # OVERCOMMIT_DISABLE=1 git commit 27 | # ``` 28 | # 29 | # Read more about overcommit: https://github.com/brigade/overcommit 30 | # 31 | # To manage this config yourself in your module add 32 | # 33 | # ``` 34 | # .overcommit.yml: 35 | # unmanaged: true 36 | # ``` 37 | # 38 | # to your modules .sync.yml config 39 | --- 40 | PreCommit: 41 | RuboCop: 42 | enabled: true 43 | description: 'Runs rubocop on modified files only' 44 | command: ['bundle', 'exec', 'rubocop'] 45 | PuppetLint: 46 | enabled: true 47 | description: 'Runs puppet-lint on modified files only' 48 | command: ['bundle', 'exec', 'puppet-lint'] 49 | YamlSyntax: 50 | enabled: true 51 | JsonSyntax: 52 | enabled: true 53 | TrailingWhitespace: 54 | enabled: true 55 | 56 | PrePush: 57 | RakeTarget: 58 | enabled: true 59 | description: 'Run rake targets' 60 | targets: 61 | - 'validate' 62 | - 'test' 63 | - 'rubocop' 64 | command: [ 'bundle', 'exec', 'rake' ] 65 | -------------------------------------------------------------------------------- /object_templates/provider_spec.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | ensure_module_defined('Puppet::Provider::<%= provider_class %>') 6 | require 'puppet/provider/<%= name %>/<%= name %>' 7 | 8 | RSpec.describe Puppet::Provider::<%= provider_class %>::<%= provider_class %> do 9 | subject(:provider) { described_class.new } 10 | 11 | let(:context) { instance_double('Puppet::ResourceApi::BaseContext', 'context') } 12 | 13 | describe '#get' do 14 | it 'processes resources' do 15 | expect(context).to receive(:debug).with('Returning pre-canned example data') 16 | expect(provider.get(context)).to eq [ 17 | { 18 | name: 'foo', 19 | ensure: 'present', 20 | }, 21 | { 22 | name: 'bar', 23 | ensure: 'present', 24 | }, 25 | ] 26 | end 27 | end 28 | 29 | describe 'create(context, name, should)' do 30 | it 'creates the resource' do 31 | expect(context).to receive(:notice).with(%r{\ACreating 'a'}) 32 | 33 | provider.create(context, 'a', name: 'a', ensure: 'present') 34 | end 35 | end 36 | 37 | describe 'update(context, name, should)' do 38 | it 'updates the resource' do 39 | expect(context).to receive(:notice).with(%r{\AUpdating 'foo'}) 40 | 41 | provider.update(context, 'foo', name: 'foo', ensure: 'present') 42 | end 43 | end 44 | 45 | describe 'delete(context, name)' do 46 | it 'deletes the resource' do 47 | expect(context).to receive(:notice).with(%r{\ADeleting 'foo'}) 48 | 49 | provider.delete(context, 'foo') 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /object_templates/transport.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Puppet::Transport 4 | # The main connection class to a <%= transport_class %> endpoint 5 | class <%= transport_class %> 6 | # Initialise this transport with a set of credentials 7 | def initialize(context, connection_info) 8 | # because `password` is marked sensitive, we can log it here and it will be masked 9 | context.debug("Connecting to #{connection_info[:user]}:#{connection_info[:password]}@#{connection_info[:host]}:#{connection_info[:port]}") 10 | # store the credentials for later use 11 | # alternatively, connect right here 12 | @connection_info = connection_info 13 | end 14 | 15 | # Verifies that the stored credentials are valid, and that we can talk to the target 16 | def verify(context) 17 | context.debug("Checking connection to #{@connection_info[:host]}:#{@connection_info[:port]}") 18 | # in a real world implementation, the password would be checked by connecting 19 | # to the target device or checking that an existing connection is still alive 20 | raise 'authentication error' if @connection_info[:password].unwrap == 'invalid' 21 | end 22 | 23 | # Retrieve facts from the target and return in a hash 24 | def facts(context) 25 | context.debug('Retrieving facts') 26 | { 27 | operatingsystem: 'example', 28 | operatingsystemrelease: '1.2.3.4', 29 | } 30 | end 31 | 32 | # Close the connection and release all resources 33 | def close(context) 34 | context.debug('Closing connection') 35 | @connection_info = nil 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /.travis/test_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x # echo commands with vars expanded 3 | set -e # exit immediately on error 4 | 5 | TEMPLATE_PR_DIR=$PWD 6 | 7 | # Make a branch from checked out HEAD so that we can target 8 | # it specifically with --template-ref 9 | git checkout -b travis_commit 10 | 11 | # Test if new module from PR commit is still functional. 12 | pdk new module new_module --template-url="file://$TEMPLATE_PR_DIR" --template-ref=travis_commit --skip-interview 13 | pushd new_module 14 | grep template < metadata.json 15 | cp "$TEMPLATE_PR_DIR/.travis/fixtures/new_provider_sync.yml" ./.sync.yml 16 | pdk update --force 17 | pdk new class new_module 18 | pdk new defined_type testtype 19 | pdk new provider testprovider 20 | pdk new task testtask 21 | pdk validate 22 | pdk test unit 23 | popd 24 | 25 | rm -f ~/.pdk/cache/answers.json 26 | 27 | # Create new module from default template-url and release tag 28 | pdk new module convert_from_release_tag --skip-interview 29 | pushd convert_from_release_tag 30 | grep template < metadata.json 31 | # Attempt to convert to PR commit from release tag 32 | pdk convert --template-url="file://$TEMPLATE_PR_DIR" --template-ref=travis_commit --skip-interview --force 33 | cat convert_report.txt 34 | popd 35 | 36 | rm -f ~/.pdk/cache/answers.json 37 | 38 | # Create new module from master branch of official templates repo 39 | pdk new module convert_from_master --template-url="https://github.com/puppetlabs/pdk-templates.git" --template-ref=master --skip-interview 40 | pushd convert_from_master 41 | grep template < metadata.json 42 | # Attempt to convert to PR commit from official/master 43 | pdk convert --template-url="file://$TEMPLATE_PR_DIR" --template-ref=travis_commit --skip-interview --force 44 | cat convert_report.txt 45 | popd 46 | -------------------------------------------------------------------------------- /object_templates/transport_spec.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | require 'puppet/transport/<%= name %>' 6 | 7 | RSpec.describe Puppet::Transport::<%= transport_class %> do 8 | subject(:transport) { described_class.new(context, connection_info) } 9 | 10 | let(:context) { instance_double('Puppet::ResourceApi::BaseContext', 'context') } 11 | let(:password) { 'aih6cu6ohvohpahN' } 12 | let(:connection_info) do 13 | { 14 | host: 'api.example.com', 15 | user: 'admin', 16 | password: Puppet::Pops::Types::PSensitiveType::Sensitive.new(password), 17 | } 18 | end 19 | 20 | before(:each) do 21 | allow(context).to receive(:debug) 22 | end 23 | 24 | describe 'initialize(context, connection_info)' do 25 | it { expect { transport }.not_to raise_error } 26 | end 27 | 28 | describe 'verify(context)' do 29 | context 'with valid credentials' do 30 | it 'returns' do 31 | expect { transport.verify(context) }.not_to raise_error 32 | end 33 | end 34 | 35 | context 'with invalid credentials' do 36 | let(:password) { 'invalid' } 37 | 38 | it 'raises an error' do 39 | expect { transport.verify(context) }.to raise_error RuntimeError, %r{authentication error} 40 | end 41 | end 42 | end 43 | 44 | describe 'facts(context)' do 45 | let(:facts) { transport.facts(context) } 46 | 47 | it 'returns basic facts' do 48 | expect(facts).to include(:operatingsystem, :operatingsystemrelease) 49 | end 50 | end 51 | 52 | describe 'close(context)' do 53 | it 'releases resources' do 54 | transport.close(context) 55 | 56 | expect(transport.instance_variable_get(:@connection_info)).to be_nil 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /moduleroot/voxpupuli_rake_tasks.rb.erb: -------------------------------------------------------------------------------- 1 | desc 'Run acceptance tests' 2 | RSpec::Core::RakeTask.new(:acceptance) do |t| 3 | t.pattern = 'spec/acceptance' 4 | end 5 | 6 | desc 'Run tests release_checks' 7 | task test: [ 8 | :release_checks, 9 | ] 10 | 11 | namespace :check do 12 | desc 'Check for trailing whitespace' 13 | task :trailing_whitespace do 14 | Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename| 15 | next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)} 16 | File.foreach(filename).each_with_index do |line, index| 17 | if line =~ %r{\s\n$} 18 | puts "#{filename} has trailing whitespace on line #{index + 1}" 19 | exit 1 20 | end 21 | end 22 | end 23 | end 24 | end 25 | Rake::Task[:release_checks].enhance ['check:trailing_whitespace'] 26 | 27 | desc "Run main 'test' task and report merged results to coveralls" 28 | task test_with_coveralls: [:test] do 29 | if Dir.exist?(File.expand_path('../lib', __FILE__)) 30 | require 'coveralls/rake/task' 31 | Coveralls::RakeTask.new 32 | Rake::Task['coveralls:push'].invoke 33 | else 34 | puts 'Skipping reporting to coveralls. Module has no lib dir' 35 | end 36 | end 37 | 38 | desc 'Print supported beaker sets' 39 | task 'beaker_sets', [:directory] do |_t, args| 40 | directory = args[:directory] 41 | 42 | metadata = JSON.parse(File.read('metadata.json')) 43 | 44 | (metadata['operatingsystem_support'] || []).each do |os| 45 | (os['operatingsystemrelease'] || []).each do |release| 46 | beaker_set = if directory 47 | "#{directory}/#{os['operatingsystem'].downcase}-#{release}" 48 | else 49 | "#{os['operatingsystem'].downcase}-#{release}-x64" 50 | end 51 | 52 | filename = "spec/acceptance/nodesets/#{beaker_set}.yml" 53 | 54 | puts beaker_set if File.exist? filename 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /rubocop/profile_builder.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | this_dir = __dir__ 5 | raise "This script must be run from the #{this_dir} directory" if this_dir != Dir.pwd 6 | 7 | require 'yaml' 8 | require 'rubocop/version' 9 | 10 | File.delete('.rubocop.yml') if File.exist?('.rubocop.yml') 11 | 12 | default_configs = YAML.load(`rubocop --show-cops --require rubocop-rspec --require rubocop-i18n`) 13 | all_cops = default_configs.keys - [ 'AllCops', 'require' ] 14 | default_enabled_cops = all_cops.find_all { |c| default_configs[c]['Enabled'] } 15 | default_disabled_cops = all_cops - default_enabled_cops 16 | 17 | $stderr.puts "Found #{default_enabled_cops.length} enabled, and #{default_disabled_cops.length} disabled cops in the default config." 18 | 19 | # fetch config from current PDK. Assume it's in the same directory as this repo. 20 | FileUtils.cp(File.join('..', '..', 'pdk', '.rubocop.yml'), '.') 21 | # stub out the included config to avoid rubocop complaints 22 | File.open('.rubocop_todo.yml', 'w') do |f| 23 | # nothing 24 | end 25 | config = YAML.load(File.read('.rubocop.yml')) 26 | 27 | configured_cops = YAML.load(`rubocop --show-cops`) 28 | config_enabled_cops = all_cops.find_all { |c| configured_cops[c] && configured_cops[c]['Enabled'] } 29 | config_disabled_cops = all_cops - config_enabled_cops 30 | 31 | $stderr.puts "Found #{config_enabled_cops.length} enabled, and #{config_disabled_cops.length} disabled cops in the recommended config." 32 | 33 | # The cleanups_only profile only has the uncontroversial cops enabled, and configred, everything else is disabled 34 | 35 | cleanup_cops = YAML.load(File.read('cleanup_cops.yml')) 36 | 37 | cleanup_enabled_cops = cleanup_cops - config_disabled_cops 38 | cleanup_disabled_cops = all_cops - cleanup_enabled_cops 39 | 40 | $stderr.puts "Found #{cleanup_enabled_cops.length} enabled, and #{cleanup_disabled_cops.length} disabled cops in the cleanup config." 41 | 42 | force_disabled_cops = config_disabled_cops - default_disabled_cops 43 | 44 | # all_cops.each do |c| 45 | # if default_enabled 46 | # if disabled 47 | # # render 48 | # end 49 | # else 50 | # if enabled 51 | # # render 52 | # end 53 | # end 54 | # end 55 | File.open("defaults-#{RuboCop::Version.version}.yml", 'wb') do |f| 56 | f.puts YAML.dump(default_enabled_cops: default_enabled_cops) 57 | end 58 | 59 | puts YAML.dump(config_enabled_cops - cleanup_enabled_cops) 60 | -------------------------------------------------------------------------------- /moduleroot/.rubocop.yml.erb: -------------------------------------------------------------------------------- 1 | <%- 2 | # note that these hashes need to use rockets, not colons, because rubocop config requires strings as keys 3 | defaults = { 4 | 'require' => [ 5 | 'rubocop-rspec', 6 | 'rubocop-i18n', 7 | ], 8 | 'AllCops' => { 9 | 'DisplayCopNames' => true, 10 | 'TargetRubyVersion' => '2.1', 11 | 'Include' => [ 12 | './**/*.rb', 13 | ], 14 | 'Exclude'=> [ 15 | 'bin/*', 16 | '.vendor/**/*', 17 | '**/Gemfile', 18 | '**/Rakefile', 19 | 'pkg/**/*', 20 | 'spec/fixtures/**/*', 21 | 'vendor/**/*', 22 | '**/Puppetfile', 23 | '**/Vagrantfile', 24 | '**/Guardfile', 25 | ], 26 | }, 27 | } 28 | 29 | if @configs['include_todos'] 30 | defaults['inherit_from'] = '.rubocop_todo.yml' 31 | end 32 | 33 | require 'deep_merge/core' 34 | profile = @configs['profiles'][@configs['selected_profile']] 35 | configs = defaults.dup 36 | DeepMerge::deep_merge!(profile['configs'], configs, knockout_prefix: "--", preserve_unmergeables: false) 37 | 38 | default_version = '0.49.1' 39 | 40 | # rubocop's dependencies have native extensions and are not available on windows currently 41 | # to preserve the dynamic behaviour, and still work in its current state, this workaround 42 | # will keep the lights on 43 | version = begin 44 | require 'rubocop/version' 45 | RuboCop::Version.version 46 | rescue LoadError 47 | default_version 48 | end 49 | 50 | # If people have a different rubocop installed, and supported in their template 51 | # this allows them to use that configuration. 52 | # If the rubocop version is not installed, fall back to the default 53 | base_path = File.join(__FILE__, '..', '..', 'rubocop') 54 | dynamic_path = File.absolute_path(File.join(base_path, "defaults-#{version}.yml")) 55 | default_path = File.absolute_path(File.join(base_path, "defaults-#{default_version}.yml")) 56 | path = File.exist?(dynamic_path) ? dynamic_path : default_path 57 | 58 | require 'yaml' 59 | default_enabled_cops = YAML.load(File.read(path))[:default_enabled_cops] 60 | 61 | cop_configs = (profile['enabled_cops'] || {}) 62 | 63 | enabled_cops = cop_configs.keys 64 | enabled_cops = default_enabled_cops if enabled_cops == 'all' 65 | 66 | (enabled_cops & default_enabled_cops).sort.each { |c| configs[c] ||= cop_configs[c] if cop_configs[c] } 67 | (enabled_cops - default_enabled_cops).sort.each { |c| configs[c] ||= cop_configs[c] || {}; configs[c]['Enabled'] = true } 68 | (default_enabled_cops - enabled_cops).sort.each { |c| configs[c] ||= cop_configs[c] || {}; configs[c]['Enabled'] = false } 69 | -%> 70 | <%= YAML.dump(configs) -%> 71 | -------------------------------------------------------------------------------- /moduleroot/appveyor.yml.erb: -------------------------------------------------------------------------------- 1 | --- 2 | version: 1.1.x.{build} 3 | branches: 4 | <% if ((@configs['branches'] || []) - (@configs['remove_branches'] || [])).any? -%> 5 | only: 6 | <% (@configs['branches'] - (@configs['remove_branches'] || [])).each do |branch| -%> 7 | - <%= branch %> 8 | <% end -%> 9 | <% end -%> 10 | <% if @configs['branches_except'] -%> 11 | except: 12 | <% @configs['branches_except'].each do |branch| -%> 13 | - <%= branch %> 14 | <% end -%> 15 | <% end -%> 16 | skip_commits: 17 | message: /^\(?doc\)?.*/ 18 | clone_depth: 10 19 | init: 20 | - SET 21 | - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' 22 | - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' 23 | - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' 24 | - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' 25 | environment: 26 | <%- (@configs['environment'] || []).each do |key, value| -%> 27 | <%= key %>: <%= value %> 28 | <%- end -%> 29 | <% if @configs['simplecov'] -%> 30 | SIMPLECOV: yes 31 | <% end -%> 32 | matrix: 33 | <%- (@configs['matrix'] + (@configs['matrix_extras'] || [])).each do |matrix| -%> 34 | - 35 | <%- matrix.each do |key, value| -%> 36 | <%- if (@configs['spec_type'] && value =~ %r{spec}) -%> 37 | <%= key %>: <%= @configs['spec_type'] %> 38 | <%- else -%> 39 | <%= key %>: <%= value %> 40 | <%- end -%> 41 | <%- end -%> 42 | <%- end -%> 43 | <% if @configs['use_litmus'] -%> 44 | for: 45 | - 46 | matrix: 47 | only: 48 | - ACCEPTANCE: yes 49 | install: 50 | - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% 51 | - bundle install --jobs 4 --retry 2 52 | - type Gemfile.lock 53 | test_script: 54 | - bundle exec puppet -V 55 | - ruby -v 56 | - gem -v 57 | - bundle -v 58 | - bundle exec rake spec_prep 59 | - bundle exec rake litmus:acceptance:localhost 60 | <% end -%> 61 | matrix: 62 | fast_finish: true 63 | install: 64 | <% if @configs['install_pre'] -%> 65 | <% @configs['install_pre'].each do |ip| -%> 66 | - <%= ip %> 67 | <% end -%> 68 | <% end -%> 69 | - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% 70 | - <%= @configs['appveyor_bundle_install'] %> 71 | - type Gemfile.lock 72 | <% if @configs['install_post'] -%> 73 | <% @configs['install_post'].each do |ip| -%> 74 | - <%= ip %> 75 | <% end -%> 76 | <% end -%> 77 | build: off 78 | test_script: 79 | - bundle exec puppet -V 80 | - ruby -v 81 | - gem -v 82 | - bundle -v 83 | <% @configs['test_script'].each do |script| -%> 84 | - <%= script %> 85 | <% end -%> 86 | notifications: 87 | - provider: Email 88 | to: 89 | - nobody@nowhere.com 90 | on_build_success: false 91 | on_build_failure: false 92 | on_build_status_changed: false 93 | -------------------------------------------------------------------------------- /moduleroot/spec/spec_helper.rb.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | <%- if @configs['mock_with'] -%> 4 | RSpec.configure do |c| 5 | c.mock_with <%= @configs['mock_with'] %> 6 | end 7 | 8 | <%- end -%> 9 | require 'puppetlabs_spec_helper/module_spec_helper' 10 | require 'rspec-puppet-facts' 11 | 12 | require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) 13 | 14 | include RspecPuppetFacts 15 | 16 | default_facts = { 17 | puppetversion: Puppet.version, 18 | facterversion: Facter.version, 19 | } 20 | 21 | default_fact_files = [ 22 | File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), 23 | File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), 24 | ] 25 | 26 | default_fact_files.each do |f| 27 | next unless File.exist?(f) && File.readable?(f) && File.size?(f) 28 | 29 | begin 30 | default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) 31 | rescue => e 32 | RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" 33 | end 34 | end 35 | 36 | # read default_facts and merge them over what is provided by facterdb 37 | default_facts.each do |fact, value| 38 | add_custom_fact fact, value 39 | end 40 | 41 | RSpec.configure do |c| 42 | c.default_facts = default_facts 43 | <%- if @configs['default_facter_version'] -%> 44 | c.default_facter_version = '<%= @configs['default_facter_version'] %>' 45 | <%- end -%> 46 | <%- if @configs['hiera_config'] -%> 47 | c.hiera_config = '<%= @configs['hiera_config'] %>' 48 | <%- elsif @configs['hiera_config_ruby'] -%> 49 | c.hiera_config = <%= @configs['hiera_config_ruby'] %> 50 | <%- end -%> 51 | c.before :each do 52 | <%- if @configs['strict_level'] -%> 53 | # set to strictest setting for testing 54 | # by default Puppet runs at warning level 55 | Puppet.settings[:strict] = <%= @configs['strict_level'] %> 56 | <%- end -%> 57 | <%- if @configs['strict_variables'] -%> 58 | Puppet.settings[:strict_variables] = <%= @configs['strict_variables'] %> 59 | <%- end -%> 60 | end 61 | c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] 62 | c.after(:suite) do 63 | <%- if @configs['coverage_report'] -%> 64 | RSpec::Puppet::Coverage.report!(<%= @configs['minimum_code_coverage_percentage'] %>) 65 | <%- end -%> 66 | end 67 | end 68 | 69 | # Ensures that a module is defined 70 | # @param module_name Name of the module 71 | def ensure_module_defined(module_name) 72 | module_name.split('::').reduce(Object) do |last_module, next_module| 73 | last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) 74 | last_module.const_get(next_module, false) 75 | end 76 | end 77 | 78 | # 'spec_overrides' from sync.yml will appear below this line 79 | <%- [@configs['spec_overrides']].flatten.compact.each do |line| -%> 80 | <%= line %> 81 | <%- end -%> 82 | -------------------------------------------------------------------------------- /VP_README.md: -------------------------------------------------------------------------------- 1 | # Vox Pupuli PDK Templates 2 | This is a fork of the pdk-templates from Puppet intended for Vox Pupuli Organization. Since Vox Pupuli has different workflows and automations we require slightly different templates than the upstream. We will strive to keep the changes to a minimum but over time these changes may drift. 3 | 4 | ## Testing Template changes 5 | You can test pdk-template changes locally by running `pdk convert` in a module that uses pdk. 6 | 7 | This will tell pdk to use the local templates and consequently update the metadata.json file as well. 8 | 9 | Example: 10 | 11 | ```shell 12 | git clone https://github.com/voxpupuli/pdk-templates /voxpupuli/pdk-templates 13 | git clone https://github.com/voxpupuli/puppet-format.git 14 | cd puppet-format 15 | pdk convert --template-url=/voxpupuli/pdk-templates --template-ref=vp-1.18.0 16 | ----------Files to be modified---------- 17 | /voxpupuli/modules/puppet-format/metadata.json 18 | 19 | ---------------------------------------- 20 | 21 | You can find a report of differences in update_report.txt. 22 | 23 | Do you want to continue and make these changes to your module? Yes 24 | 25 | ------------Update completed------------ 26 | 27 | 1 files modified. 28 | 29 | View the changes and validate within the puppet module that those changes work. 30 | 31 | pdk validate 32 | pdk test 33 | ``` 34 | 35 | When finished testing you will need to convert back to the github hosted pdk-templates. 36 | 37 | `pdk convert --template-url=https://github.com/voxpupuli/pdk-templates --template-ref=vp-1.18.0` 38 | 39 | ## Updating templates 40 | When updating templates we try and keep as close to the upstream source as possible. To do this you must perform the 41 | following steps. 42 | 43 | 1. git clone https://github.com/voxpupuli/pdk-templates /voxpupuli/pdk-templates 44 | 2. cd /voxpupuli/pdk-templates 45 | 3. git remote add upstream https://github.com/puppetlabs/pdk-templates 46 | 4. git fetch upstream 47 | 5. git checkout vp-1.x.x (latest version) ie. `git checkout vp-1.17.0` 48 | 6. git rebase 1.18.0 (latest tag from upstream ) 49 | 7. Resolve any conflicts during rebase 50 | 8. Test changes locally before pushing branch (see steps about testing locally) 51 | 9. Once you have verified updates have worked, you can push the new branch ie. git push origin vp-1.18.0 52 | 53 | Note: Since we have modified the original pdk templates we prepend a `vp-` in front of the tag to designate these our Voxpupuli changes. 54 | 55 | I don't know how sustainable this workflow is so comments or suggestions are welcomed. 56 | 57 | ## Converting a module 58 | Converting your module to use Vox Pupuli's version of pdk-templates is easy as: 59 | 60 | `pdk convert --template-url=https://github.com/voxpupuli/pdk-templates --template-ref=vp-1.18.0` 61 | 62 | While the version may change over time the procedure is the same. 63 | 64 | Please be aware that if you have something custom in any of the files that pdk manages you will need to create a .sync.yml file and keep the changes there. Please see https://github.com/voxpupuli/pdk-templates#basic-usage for more info. 65 | 66 | -------------------------------------------------------------------------------- /moduleroot_init/README.md.erb: -------------------------------------------------------------------------------- 1 | <%- name = @configs['module_metadata']['name'].split('-').last rescue '[modulename]' -%> 2 | # <%= name %> 3 | 4 | Welcome to your new module. A short overview of the generated parts can be found in the PDK documentation at https://puppet.com/docs/pdk/latest/pdk_generating_modules.html . 5 | 6 | The README template below provides a starting point with details about what information to include in your README. 7 | 8 | #### Table of Contents 9 | 10 | 1. [Description](#description) 11 | 2. [Setup - The basics of getting started with <%= name %>](#setup) 12 | * [What <%= name %> affects](#what-<%= name %>-affects) 13 | * [Setup requirements](#setup-requirements) 14 | * [Beginning with <%= name %>](#beginning-with-<%= name %>) 15 | 3. [Usage - Configuration options and additional functionality](#usage) 16 | 4. [Limitations - OS compatibility, etc.](#limitations) 17 | 5. [Development - Guide for contributing to the module](#development) 18 | 19 | ## Description 20 | 21 | Briefly tell users why they might want to use your module. Explain what your module does and what kind of problems users can solve with it. 22 | 23 | This should be a fairly short description helps the user decide if your module is what they want. 24 | 25 | ## Setup 26 | 27 | ### What <%= name %> affects **OPTIONAL** 28 | 29 | If it's obvious what your module touches, you can skip this section. For example, folks can probably figure out that your mysql_instance module affects their MySQL instances. 30 | 31 | If there's more that they should know about, though, this is the place to mention: 32 | 33 | * Files, packages, services, or operations that the module will alter, impact, or execute. 34 | * Dependencies that your module automatically installs. 35 | * Warnings or other important notices. 36 | 37 | ### Setup Requirements **OPTIONAL** 38 | 39 | If your module requires anything extra before setting up (pluginsync enabled, another module, etc.), mention it here. 40 | 41 | If your most recent release breaks compatibility or requires particular steps for upgrading, you might want to include an additional "Upgrading" section here. 42 | 43 | ### Beginning with <%= name %> 44 | 45 | The very basic steps needed for a user to get the module up and running. This can include setup steps, if necessary, or it can be an example of the most basic use of the module. 46 | 47 | ## Usage 48 | 49 | Include usage examples for common use cases in the **Usage** section. Show your users how to use your module to solve problems, and be sure to include code examples. Include three to five examples of the most important or common tasks a user can accomplish with your module. Show users how to accomplish more complex tasks that involve different types, classes, and functions working in tandem. 50 | 51 | ## Reference 52 | 53 | This section is deprecated. Instead, add reference information to your code as Puppet Strings comments, and then use Strings to generate a REFERENCE.md in your module. For details on how to add code comments and generate documentation with Strings, see the Puppet Strings [documentation](https://puppet.com/docs/puppet/latest/puppet_strings.html) and [style guide](https://puppet.com/docs/puppet/latest/puppet_strings_style.html) 54 | 55 | If you aren't ready to use Strings yet, manually create a REFERENCE.md in the root of your module directory and list out each of your module's classes, defined types, facts, functions, Puppet tasks, task plans, and resource types and providers, along with the parameters for each. 56 | 57 | For each element (class, defined type, function, and so on), list: 58 | 59 | * The data type, if applicable. 60 | * A description of what the element does. 61 | * Valid values, if the data type doesn't make it obvious. 62 | * Default value, if any. 63 | 64 | For example: 65 | 66 | ``` 67 | ### `pet::cat` 68 | 69 | #### Parameters 70 | 71 | ##### `meow` 72 | 73 | Enables vocalization in your cat. Valid options: 'string'. 74 | 75 | Default: 'medium-loud'. 76 | ``` 77 | 78 | ## Limitations 79 | 80 | In the Limitations section, list any incompatibilities, known issues, or other warnings. 81 | 82 | ## Development 83 | 84 | In the Development section, tell other users the ground rules for contributing to your project and how they should submit their work. 85 | 86 | ## Release Notes/Contributors/Etc. **Optional** 87 | 88 | If you aren't using changelog, put your release notes here (though you should consider using changelog). You can also add any additional sections you feel are necessary or important to include here. Please use the `## ` header. 89 | -------------------------------------------------------------------------------- /moduleroot/Gemfile.erb: -------------------------------------------------------------------------------- 1 | <% 2 | def gem_length(gem) 3 | if gem['from_env'] 4 | version_len = " *location_for(ENV['#{gem['from_env']}'])".length + ((" || '#{gem['version']}'".length if gem['version']) || 0) 5 | else 6 | version_len = (", '#{gem['version']}'".length if gem['version']) || 0 7 | end 8 | 9 | gem['gem'].length + version_len 10 | end 11 | 12 | def gem_spec(gem, max_len) 13 | output = "\"#{gem['gem']}\"" 14 | 15 | if gem['version'] 16 | if gem['from_env'] 17 | output += ", *location_for(ENV['#{gem['from_env']}'] || '#{gem['version']}')" 18 | else 19 | output += ", '#{gem['version']}'" 20 | end 21 | end 22 | 23 | options = [] 24 | options << "require: false" if gem['from_env'].nil? 25 | options << "git: '#{gem['git']}'" unless gem['git'].nil? 26 | options << "branch: '#{gem['branch']}'" unless gem['branch'].nil? 27 | options << "ref: '#{gem['ref']}'" unless gem['ref'].nil? 28 | options << "platforms: #{gem['platforms'].inspect}" unless gem['platforms'].nil? 29 | options << "source: #{gem['source'].inspect}" unless gem['source'].nil? 30 | 31 | unless options.empty? 32 | output += ', ' 33 | output += ' ' * (max_len - gem['length']) 34 | 35 | output += options.join(', ') 36 | end 37 | 38 | output += " if #{gem['condition']}" unless gem['condition'].nil? 39 | 40 | output 41 | end 42 | -%> 43 | source ENV['GEM_SOURCE'] || 'https://rubygems.org' 44 | 45 | def location_for(place_or_version, fake_version = nil) 46 | git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} 47 | file_url_regex = %r{\Afile:\/\/(?.*)} 48 | 49 | if place_or_version && (git_url = place_or_version.match(git_url_regex)) 50 | [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact 51 | elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) 52 | ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] 53 | else 54 | [place_or_version, { require: false }] 55 | end 56 | end 57 | 58 | ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments 59 | minor_version = ruby_version_segments[0..1].join('.') 60 | 61 | <% 62 | groups = {} 63 | (@configs['required'].keys + ((@configs['optional'] || {}).keys)).uniq.each do |key| 64 | groups[key] = (@configs['required'][key] || []) + ((@configs['optional'] || {})[key] || []) 65 | end 66 | 67 | if respond_to?(:config_for) 68 | common_config = config_for('common') 69 | 70 | if common_config['disable_legacy_facts'] 71 | groups[':development'] << { 72 | 'gem' => 'puppet-lint-legacy_facts-check', 73 | } 74 | end 75 | end 76 | -%> 77 | <% groups.each do |group, gems| -%> 78 | group <%= group %> do 79 | <% 80 | gems.map! do |gem| 81 | { 82 | 'gem' => gem['gem'], 83 | 'version' => gem['version'], 84 | 'platforms' => gem['platforms'].nil? ? nil : Array[*gem['platforms']].map(&:to_sym), 85 | 'git' => gem['git'], 86 | 'branch' => gem['branch'], 87 | 'ref' => gem['ref'], 88 | 'length' => gem_length(gem), 89 | 'from_env' => gem['from_env'], 90 | 'condition' => gem['condition'], 91 | 'source' => gem['source'], 92 | } 93 | end 94 | 95 | maxlen = gems.map { |r| r['length'] }.max 96 | -%> 97 | <% gems.each do |gem| -%> 98 | gem <%= gem_spec(gem, maxlen) %> 99 | <% end -%> 100 | end 101 | <% end -%> 102 | 103 | puppet_version = ENV['PUPPET_GEM_VERSION'] 104 | facter_version = ENV['FACTER_GEM_VERSION'] 105 | hiera_version = ENV['HIERA_GEM_VERSION'] 106 | 107 | gems = {} 108 | 109 | gems['puppet'] = location_for(puppet_version) 110 | 111 | # If facter or hiera versions have been specified via the environment 112 | # variables 113 | 114 | gems['facter'] = location_for(facter_version) if facter_version 115 | gems['hiera'] = location_for(hiera_version) if hiera_version 116 | 117 | if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} 118 | # If we're using a Puppet gem on Windows which handles its own win32-xxx gem 119 | # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). 120 | gems['win32-dir'] = ['<= 0.4.9', require: false] 121 | gems['win32-eventlog'] = ['<= 0.6.5', require: false] 122 | gems['win32-process'] = ['<= 0.7.5', require: false] 123 | gems['win32-security'] = ['<= 0.2.5', require: false] 124 | gems['win32-service'] = ['0.8.8', require: false] 125 | end 126 | 127 | gems.each do |gem_name, gem_params| 128 | gem gem_name, *gem_params 129 | end 130 | 131 | # Evaluate Gemfile.local and ~/.gemfile if they exist 132 | extra_gemfiles = [ 133 | "#{__FILE__}.local", 134 | File.join(Dir.home, '.gemfile'), 135 | ] 136 | 137 | extra_gemfiles.each do |gemfile| 138 | if File.file?(gemfile) && File.readable?(gemfile) 139 | eval(File.read(gemfile), binding) 140 | end 141 | end 142 | # vim: syntax=ruby 143 | -------------------------------------------------------------------------------- /moduleroot/.gitlab-ci.yml.erb: -------------------------------------------------------------------------------- 1 | --- 2 | <% if @configs['override'] && @configs.has_key?('custom') -%> 3 | <% configs = @configs['custom'].dup -%> 4 | <% elsif @configs['defaults'] && !@configs.has_key?('custom') -%> 5 | <% configs = @configs['defaults'].dup -%> 6 | <% else -%> 7 | <% require 'deep_merge/core' -%> 8 | <% configs = {} -%> 9 | <% configs.deep_merge!(@configs['defaults']) -%> 10 | <% configs.deep_merge!(@configs['custom']) -%> 11 | <% end -%> 12 | stages: 13 | <% unless @configs['override'] -%> 14 | - syntax 15 | - unit 16 | <% end -%> 17 | <% if configs['beaker'] -%> 18 | - beaker 19 | <% end -%> 20 | <% if configs['custom_stages'] -%> 21 | <% configs['custom_stages'].each do |stage| -%> 22 | - <%= stage %> 23 | <% end -%> 24 | <% end -%> 25 | <% if configs.has_key?('global_variables') -%> 26 | variables: 27 | <% configs['global_variables'].each do |key, value| -%> 28 | <%= key %>: '<%= value %>' 29 | <% end -%> 30 | <% end -%> 31 | 32 | <% if configs['image'] -%> 33 | image: <%= configs['image'] %> 34 | 35 | <% end -%> 36 | <% if configs['cache'] -%> 37 | cache: 38 | paths: 39 | <% configs['cache']['paths'].each do |path| -%> 40 | - <%= path %> 41 | <% end -%> 42 | <% end -%> 43 | 44 | <% if !configs.has_key?('default_before_script') || configs['default_before_script'] -%> 45 | before_script: 46 | <% if configs['custom_before_steps'] -%> 47 | <% configs['custom_before_steps'].each do |step| -%> 48 | - <%= step %> 49 | <% end -%> 50 | <% end -%> 51 | - bundle -v 52 | - rm Gemfile.lock || true 53 | <% if configs['rubygems_mirror'] -%> 54 | - gem sources -a <%= configs['rubygems_mirror'] %> --remove https://rubygems.org/ 55 | - bundle config mirror.http://rubygems.org/ <%= configs['rubygems_mirror'] %> 56 | - bundle config mirror.https://rubygems.org/ <%= configs['rubygems_mirror'] %> 57 | <% end -%> 58 | - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" 59 | - "# Set `rubygems_version` in the .sync.yml to set a value" 60 | - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" 61 | - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' 62 | - gem --version 63 | - bundle -v 64 | - bundle install <%= configs['bundler_args'] %> 65 | <% end -%> 66 | 67 | <% if configs['ruby_versions'] -%> 68 | <% configs['ruby_versions'].each do |ruby_version, options| -%> 69 | <% if options['image'] -%> 70 | <% image = options['image'] -%> 71 | <% else -%> 72 | <% image = 'ruby' -%> 73 | <% end -%> 74 | <% options['checks'].each do |check| -%> 75 | <%= check %>-Ruby <%= ruby_version %>-Puppet <%= options['puppet_version'] %>: 76 | <% if check =~ /spec/ -%> 77 | stage: unit 78 | <% else -%> 79 | stage: syntax 80 | <% end -%> 81 | image: <%= image %>:<%= ruby_version %> 82 | script: 83 | - bundle exec rake <%= check %> 84 | variables: 85 | PUPPET_GEM_VERSION: '<%= options['puppet_version'] %>' 86 | <% if options['rubygems_version'] -%> 87 | RUBYGEMS_VERSION: '<%= options['rubygems_version'] -%>' 88 | <% end -%> 89 | <% if options['allow_failure'] -%> 90 | <% if options['allow_failure'].include?(check) -%> 91 | allow_failure: true 92 | <% end -%> 93 | <% end -%> 94 | <% unless options['except'].nil? || options['except'][check].nil? -%> 95 | except: 96 | <% if ['variables', 'refs', 'changes', 'kubernetes'].any? { |i| options['except'][check].include?(i) } -%> 97 | <% options['except'][check].each do |key, ref| -%> 98 | <%= key %>: 99 | <% ref.each do |r| -%> 100 | - <%= r %> 101 | <% end -%> 102 | <% end -%> 103 | <% else -%> 104 | <% options['except'][check].each do |ref| -%> 105 | - <%= ref %> 106 | <% end -%> 107 | <% end -%> 108 | <% end -%> 109 | <% unless options['only'].nil? || options['only'][check].nil? -%> 110 | only: 111 | <% if ['variables', 'refs', 'changes', 'kubernetes'].any? { |i| options['only'][check].include?(i) } -%> 112 | <% options['only'][check].each do |key, ref| -%> 113 | <%= key %>: 114 | <% ref.each do |r| -%> 115 | - <%= r %> 116 | <% end -%> 117 | <% end -%> 118 | <% else -%> 119 | <% options['only'][check].each do |ref| -%> 120 | - <%= ref %> 121 | <% end -%> 122 | <% end -%> 123 | <% end -%> 124 | <% if options['tags'] -%> 125 | tags: 126 | <% options['tags'].each do |tag| -%> 127 | - <%= tag %> 128 | <% end -%> 129 | <% end %> 130 | <% end -%> 131 | <% end -%> 132 | <% end -%> 133 | <% if configs['beaker'] -%> 134 | beaker: 135 | stage: beaker 136 | variables: 137 | DOCKER_DRIVER: 'overlay2' 138 | <% configs['beaker']['variables'].each do |key, value| -%> 139 | <%= key %>: '<%= value %>' 140 | <% end -%> 141 | services: 142 | - docker:dind 143 | script: 144 | - bundle install --with-system_tests 145 | - bundle exec rake acceptance 146 | <% if configs['beaker']['tags'] -%> 147 | tags: 148 | <% configs['beaker']['tags'].each do |tag| -%> 149 | - <%= tag %> 150 | <% end -%> 151 | <% end -%> 152 | <% end -%> 153 | <% if configs['custom_jobs'] -%> 154 | <%= YAML.dump(configs['custom_jobs']).sub(%r{\A---\r?\n}m, '') %> 155 | <% end -%> 156 | -------------------------------------------------------------------------------- /moduleroot/Rakefile.erb: -------------------------------------------------------------------------------- 1 | <% 2 | def requires(item) 3 | if item.is_a? String 4 | line = "require '#{item}'" 5 | elsif item.is_a? Hash 6 | line = "require '#{item['require']}'" unless item['require'].nil? 7 | line = "#{line} if #{item['conditional']}" unless item['require'].nil? and item['conditional'].nil? 8 | end 9 | line 10 | end 11 | -%> 12 | # frozen_string_literal: true 13 | 14 | require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? 15 | require 'puppetlabs_spec_helper/rake_tasks' 16 | require 'puppet-syntax/tasks/puppet-syntax' 17 | require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? 18 | require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? 19 | require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? 20 | <% if ! @configs['requires'].nil? -%> 21 | <% @configs['requires'].each do |item| -%> 22 | <%= requires(item) %> 23 | <% end -%> 24 | <% end -%> 25 | <% if ! @configs['imports'].nil? %> 26 | <% @configs['imports'].each do |item| -%> 27 | import '<%= item %>' 28 | <% end -%> 29 | <% end -%> 30 | 31 | def changelog_user 32 | return unless Rake.application.top_level_tasks.include? "changelog" 33 | returnVal = <%= @configs['changelog_user'].inspect -%> || JSON.load(File.read('metadata.json'))['author'] 34 | raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? 35 | puts "GitHubChangelogGenerator user:#{returnVal}" 36 | returnVal 37 | end 38 | 39 | def changelog_project 40 | return unless Rake.application.top_level_tasks.include? "changelog" 41 | 42 | returnVal = <%= @configs['changelog_project'].inspect -%> 43 | 44 | returnVal ||= begin 45 | metadata_source = JSON.load(File.read('metadata.json'))['source'] 46 | metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) 47 | 48 | metadata_source_match && metadata_source_match[1] 49 | end 50 | 51 | raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? 52 | 53 | puts "GitHubChangelogGenerator project:#{returnVal}" 54 | returnVal 55 | end 56 | 57 | def changelog_future_release 58 | return unless Rake.application.top_level_tasks.include? "changelog" 59 | returnVal = <%= @configs['changelog_version_tag_pattern'].inspect -%> % JSON.load(File.read('metadata.json'))['version'] 60 | raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? 61 | puts "GitHubChangelogGenerator future_release:#{returnVal}" 62 | returnVal 63 | end 64 | 65 | <% checks = @configs['default_disabled_lint_checks'] + ( @configs['extra_disabled_lint_checks'] || [] ) -%> 66 | <% checks.each do |check| -%> 67 | PuppetLint.configuration.send('disable_<%= check %>') 68 | <% end -%> 69 | exclude_paths = %w( 70 | pkg/**/* 71 | vendor/**/* 72 | .vendor/**/* 73 | spec/**/* 74 | ) 75 | PuppetLint.configuration.ignore_paths = exclude_paths 76 | PuppetSyntax.exclude_paths = exclude_paths 77 | <% if @configs['linter_fail_on_warnings'] -%> 78 | PuppetLint.configuration.fail_on_warnings = true 79 | <% end -%> 80 | <% linter_options = @configs['linter_options'] || [] -%> 81 | <% linter_options.each do |option| -%> 82 | PuppetLint.configuration.send('<%= option %>') 83 | <% end -%> 84 | <% if @configs['log_format'] -%> 85 | PuppetLint.configuration.log_format = <%= @configs['log_format'] %> 86 | <% end -%> 87 | if Bundler.rubygems.find_name('github_changelog_generator').any? 88 | GitHubChangelogGenerator::RakeTask.new :changelog do |config| 89 | raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? 90 | <% if @configs['github_site'] -%> 91 | config.github_site = <%= @configs['github_site'].inspect %> 92 | <% end -%> 93 | <% if @configs['github_endpoint'] -%> 94 | config.github_endpoint = <%= @configs['github_endpoint'].inspect %> 95 | <% end -%> 96 | <% if @configs['gitlab'] -%> 97 | config.gitlab = <%= @configs['gitlab'].inspect %> 98 | <% end -%> 99 | config.user = "#{changelog_user}" 100 | config.project = "#{changelog_project}" 101 | <% if @configs['changelog_since_tag'] -%> 102 | config.since_tag = <%= @configs['changelog_since_tag'].inspect %> 103 | <% end -%> 104 | config.future_release = "#{changelog_future_release}" 105 | config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} 106 | config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." 107 | config.add_pr_wo_labels = true 108 | config.issues = false 109 | config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" 110 | config.configure_sections = { 111 | "Changed" => { 112 | "prefix" => "### Changed", 113 | "labels" => ["backwards-incompatible"], 114 | }, 115 | "Added" => { 116 | "prefix" => "### Added", 117 | "labels" => ["feature", "enhancement"], 118 | }, 119 | "Fixed" => { 120 | "prefix" => "### Fixed", 121 | "labels" => ["bugfix"], 122 | }, 123 | } 124 | end 125 | else 126 | desc 'Generate a Changelog from GitHub' 127 | task :changelog do 128 | raise <= Gem::Version.new('2.2.2')" 139 | EOM 140 | end 141 | end 142 | 143 | <%- [@configs['extras']].flatten.compact.each do |line| -%> 144 | <%= line %> 145 | <%- end -%> 146 | # vim: syntax=ruby 147 | -------------------------------------------------------------------------------- /rubocop/cleanup_cops.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - Bundler/OrderedGems 3 | - Layout/AccessModifierIndentation 4 | - Layout/AlignArray 5 | - Layout/AlignHash 6 | - Layout/AlignParameters 7 | - Layout/BlockEndNewline 8 | - Layout/CaseIndentation 9 | - Layout/ClosingParenthesisIndentation 10 | - Layout/CommentIndentation 11 | - Layout/DotPosition 12 | - Layout/ElseAlignment 13 | - Layout/EmptyLineAfterMagicComment 14 | - Layout/EmptyLineBetweenDefs 15 | - Layout/EmptyLines 16 | - Layout/EmptyLinesAroundAccessModifier 17 | - Layout/EmptyLinesAroundBlockBody 18 | - Layout/EmptyLinesAroundClassBody 19 | - Layout/EmptyLinesAroundExceptionHandlingKeywords 20 | - Layout/EmptyLinesAroundMethodBody 21 | - Layout/EmptyLinesAroundModuleBody 22 | - Layout/ExtraSpacing 23 | - Layout/FirstParameterIndentation 24 | - Layout/IndentArray 25 | - Layout/IndentAssignment 26 | - Layout/IndentHash 27 | - Layout/IndentationConsistency 28 | - Layout/IndentationWidth 29 | - Layout/InitialIndentation 30 | - Layout/LeadingCommentSpace 31 | - Layout/MultilineArrayBraceLayout 32 | - Layout/MultilineBlockLayout 33 | - Layout/MultilineHashBraceLayout 34 | - Layout/MultilineMethodCallBraceLayout 35 | - Layout/MultilineMethodCallIndentation 36 | - Layout/MultilineMethodDefinitionBraceLayout 37 | - Layout/MultilineOperationIndentation 38 | - Layout/RescueEnsureAlignment 39 | - Layout/SpaceAfterColon 40 | - Layout/SpaceAfterComma 41 | - Layout/SpaceAfterMethodName 42 | - Layout/SpaceAfterNot 43 | - Layout/SpaceAfterSemicolon 44 | - Layout/SpaceAroundBlockParameters 45 | - Layout/SpaceAroundEqualsInParameterDefault 46 | - Layout/SpaceAroundKeyword 47 | - Layout/SpaceAroundOperators 48 | - Layout/SpaceBeforeBlockBraces 49 | - Layout/SpaceBeforeComma 50 | - Layout/SpaceBeforeComment 51 | - Layout/SpaceBeforeFirstArg 52 | - Layout/SpaceBeforeSemicolon 53 | - Layout/SpaceInLambdaLiteral 54 | - Layout/SpaceInsideArrayPercentLiteral 55 | - Layout/SpaceInsideBlockBraces 56 | - Layout/SpaceInsideBrackets 57 | - Layout/SpaceInsideHashLiteralBraces 58 | - Layout/SpaceInsideParens 59 | - Layout/SpaceInsidePercentLiteralDelimiters 60 | - Layout/SpaceInsideRangeLiteral 61 | - Layout/SpaceInsideStringInterpolation 62 | - Layout/Tab 63 | - Layout/TrailingBlankLines 64 | - Layout/TrailingWhitespace 65 | - Lint/BlockAlignment 66 | - Lint/DefEndAlignment 67 | - Lint/DeprecatedClassMethods 68 | - Lint/EmptyInterpolation 69 | - Lint/LiteralInInterpolation 70 | - Lint/MultipleCompare 71 | - Lint/PercentStringArray 72 | - Lint/PercentSymbolArray 73 | - Lint/RescueType 74 | - Lint/SafeNavigationChain 75 | - Lint/StringConversionInInterpolation 76 | - Lint/UnifiedInteger 77 | - Lint/UnneededSplatExpansion 78 | - Lint/UnusedBlockArgument 79 | - Lint/UnusedMethodArgument 80 | - Performance/CaseWhenSplat 81 | - Performance/Casecmp 82 | - Performance/CompareWithBlock 83 | - Performance/Count 84 | - Performance/Detect 85 | - Performance/DoubleStartEndWith 86 | - Performance/FlatMap 87 | - Performance/LstripRstrip 88 | - Performance/RangeInclude 89 | - Performance/RedundantBlockCall 90 | - Performance/RedundantMatch 91 | - Performance/RedundantMerge 92 | - Performance/RedundantSortBy 93 | - Performance/RegexpMatch 94 | - Performance/ReverseEach 95 | - Performance/Sample 96 | - Performance/Size 97 | - Performance/StartWith 98 | - Performance/StringReplacement 99 | - Performance/TimesMap 100 | - RSpec/BeEql 101 | - RSpec/DescribedClass 102 | - RSpec/EmptyLineAfterFinalLet 103 | - RSpec/EmptyLineAfterSubject 104 | - RSpec/ExampleWording 105 | - RSpec/HookArgument 106 | - RSpec/ImplicitExpect 107 | - RSpec/InstanceSpy 108 | - RSpec/ItBehavesLike 109 | - RSpec/LeadingSubject 110 | - RSpec/NotToNot 111 | - RSpec/SharedContext 112 | - RSpec/SingleArgumentMessageChain 113 | - Security/JSONLoad 114 | - Security/YAMLLoad 115 | - Style/Alias 116 | - Style/AndOr 117 | - Style/ArrayJoin 118 | - Style/Attr 119 | - Style/BarePercentLiterals 120 | - Style/BlockComments 121 | - Style/BlockDelimiters 122 | - Style/BracesAroundHashParameters 123 | - Style/CharacterLiteral 124 | - Style/ClassCheck 125 | - Style/ClassMethods 126 | - Style/CollectionMethods 127 | - Style/ColonMethodCall 128 | - Style/CommandLiteral 129 | - Style/CommentAnnotation 130 | - Style/ConditionalAssignment 131 | - Style/DefWithParentheses 132 | - Style/EachForSimpleLoop 133 | - Style/EachWithObject 134 | - Style/EmptyCaseCondition 135 | - Style/EmptyElse 136 | - Style/EmptyLiteral 137 | - Style/EmptyMethod 138 | - Style/EvenOdd 139 | - Style/FormatString 140 | - Style/FrozenStringLiteralComment 141 | - Style/HashSyntax 142 | - Style/InfiniteLoop 143 | - Style/InverseMethods 144 | - Style/Lambda 145 | - Style/LambdaCall 146 | - Style/LineEndConcatenation 147 | - Style/MethodCallWithoutArgsParentheses 148 | - Style/MethodDefParentheses 149 | - Style/MixinGrouping 150 | - Style/MultilineIfThen 151 | - Style/MultilineMemoization 152 | - Style/MutableConstant 153 | - Style/NegatedIf 154 | - Style/NegatedWhile 155 | - Style/NestedModifier 156 | - Style/NestedParenthesizedCalls 157 | - Style/Next 158 | - Style/NilComparison 159 | - Style/NonNilCheck 160 | - Style/Not 161 | - Style/NumericLiteralPrefix 162 | - Style/NumericLiterals 163 | - Style/OneLineConditional 164 | - Style/ParallelAssignment 165 | - Style/ParenthesesAroundCondition 166 | - Style/PercentLiteralDelimiters 167 | - Style/PercentQLiterals 168 | - Style/PerlBackrefs 169 | - Style/PreferredHashMethods 170 | - Style/Proc 171 | - Style/RaiseArgs 172 | - Style/RedundantBegin 173 | - Style/RedundantException 174 | - Style/RedundantFreeze 175 | - Style/RedundantParentheses 176 | - Style/RedundantReturn 177 | - Style/RedundantSelf 178 | - Style/RegexpLiteral 179 | - Style/RescueModifier 180 | - Style/SafeNavigation 181 | - Style/Semicolon 182 | - Style/SignalException 183 | - Style/SingleLineMethods 184 | - Style/SpecialGlobalVars 185 | - Style/StabbyLambdaParentheses 186 | - Style/StringLiterals 187 | - Style/StringLiteralsInInterpolation 188 | - Style/StringMethods 189 | - Style/SymbolArray 190 | - Style/SymbolLiteral 191 | - Style/TernaryParentheses 192 | - Style/TrailingCommaInArguments 193 | - Style/TrailingCommaInLiteral 194 | - Style/TrailingUnderscoreVariable 195 | - Style/TrivialAccessors 196 | - Style/UnlessElse 197 | - Style/UnneededCapitalW 198 | - Style/UnneededInterpolation 199 | - Style/UnneededPercentQ 200 | - Style/VariableInterpolation 201 | - Style/WhenThen 202 | - Style/WhileUntilDo 203 | - Style/WhileUntilModifier 204 | - Style/WordArray 205 | - Style/YodaCondition 206 | - Style/ZeroLengthPredicate 207 | -------------------------------------------------------------------------------- /moduleroot/.travis.yml.erb: -------------------------------------------------------------------------------- 1 | <% 2 | if @configs['deploy_to_forge']['enabled'] 3 | # If Deploy To Forge is enabled.. 4 | # - Inject the deployment stage using the tag regex 5 | @configs['stages'] << { 6 | 'name' => 'deploy', 7 | 'if' => "tag =~ #{@configs['deploy_to_forge']['tag_regex']}" 8 | } 9 | # - Inject the deployment task into the includes 10 | @configs['includes'] << { 11 | 'env' => 'DEPLOY_TO_FORGE=yes', 12 | 'stage' => 'deploy' 13 | } 14 | end 15 | -%> 16 | --- 17 | <% if @configs['os'] -%> 18 | os: 19 | <% @configs['os'].each do |os| -%> 20 | - <%= os %> 21 | <% end -%> 22 | <% else -%> 23 | os: linux 24 | <% end -%> 25 | <% if @configs['dist'] -%> 26 | dist: <%= @configs['dist'] %> 27 | <% else -%> 28 | dist: xenial 29 | <% end -%> 30 | language: ruby 31 | cache: bundler 32 | <% if !@configs.nil? && @configs.has_key?('addons') -%> 33 | addons: 34 | <% @configs['addons'].each do |addon, params| -%> 35 | <%= addon %>: 36 | <% params.each do |param_name, param_value| -%> 37 | <%= param_name %>:<%= param_value.is_a?(String) ? " #{param_value}" : "" %> 38 | <% if param_value.is_a?(Array) -%> 39 | <% param_value.each do |r| -%> 40 | - <%= r %> 41 | <% end -%> 42 | <% end -%> 43 | <% end -%> 44 | <% end -%> 45 | <% end -%> 46 | before_install: 47 | <% if @configs['before_install_pre'] -%> 48 | <% @configs['before_install_pre'].each do |bip| -%> 49 | - <%= bip %> 50 | <% end -%> 51 | <% end -%> 52 | - bundle -v 53 | - rm -f Gemfile.lock 54 | - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" 55 | - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" 56 | - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" 57 | - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' 58 | - gem --version 59 | - bundle -v 60 | <% if @configs['before_install_post'] -%> 61 | <% @configs['before_install_post'].each do |bip| -%> 62 | - <%= bip %> 63 | <% end -%> 64 | <% end -%> 65 | script: 66 | <% if @configs['simplecov'] -%> 67 | - 'SIMPLECOV=yes bundle exec rake $CHECK' 68 | <% else -%> 69 | - 'bundle exec rake $CHECK' 70 | <% end -%> 71 | bundler_args: <%= @configs['bundler_args'] %> 72 | rvm: 73 | <% @configs['ruby_versions'].each do |ruby_version| -%> 74 | - <%= ruby_version %> 75 | <% end -%> 76 | <% if @configs.has_key?('env') || @configs.has_key?('global_env') -%> 77 | env: 78 | <% if @configs.has_key?('global_env') -%> 79 | global: 80 | <% @configs['global_env'].each do |env| -%> 81 | - <%= env %> 82 | <% end -%> 83 | <% end -%> 84 | <% if @configs.has_key?('env') -%> 85 | jobs: 86 | <% @configs['env'].each do |env| -%> 87 | - <%= env %> 88 | <% end -%> 89 | <% end -%> 90 | <% end -%> 91 | <% if @configs.has_key?('stages') -%> 92 | stages: 93 | <% @configs['stages'].each do |stage| -%> 94 | <% if stage.is_a?(String) -%> 95 | - <%= stage %> 96 | <% elsif stage.is_a?(Hash) -%> 97 | - 98 | <% stage.keys.sort.each do |key| -%> 99 | <%= key %>: <%= stage[key] %> 100 | <% end -%> 101 | <% end -%> 102 | <% end -%> 103 | <% end -%> 104 | jobs: 105 | fast_finish: true 106 | include: 107 | <% (@configs['docker_sets'] || []).each do |set| -%> 108 | <% job = @configs['docker_defaults'].merge(set['options'] || {}) -%> 109 | - 110 | <% job.keys.sort.each do |key| -%> 111 | <%= key %>: <%= job[key].gsub(/@@SET@@/, set['set']).gsub(/@@COLLECTION@@/, set.fetch('collection', 'puppet6')).gsub(/@@TESTMODE@@/, set.fetch('testmode', 'apply')) %> 112 | <% end -%> 113 | <% end -%> 114 | <% if @configs['use_litmus'] 115 | @configs['litmus']['puppet_collection'].each do |puppet_version| 116 | @configs['litmus']['provision_list'].each do |platform|-%> 117 | - 118 | before_script: 119 | - "bundle exec rake 'litmus:provision_list[<%=platform%>]'" 120 | <% if @configs['litmus']['install_wget']-%> 121 | - "bundle exec bolt command run 'apt-get install wget -y' --inventoryfile inventory.yaml --nodes='localhost*'" 122 | <% end-%> 123 | - "bundle exec rake 'litmus:install_agent[<%=puppet_version%>]'" 124 | - "bundle exec rake litmus:install_module" 125 | bundler_args: 126 | env: PLATFORMS=<%=platform%>_<%=puppet_version%> 127 | rvm: <%=@configs['litmus']['rvm']%> 128 | script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] 129 | services: docker 130 | stage: acceptance 131 | <% end -%> 132 | <% end -%> 133 | <% end -%> 134 | <% (@configs['includes'] - (@configs['remove_includes'] || []) + (@configs['extras'] || [])).each do |job| -%> 135 | - 136 | <% job.keys.sort.each do |key| -%> 137 | <%= key %>: <%= job[key] %> 138 | <% end -%> 139 | <% end -%> 140 | <% if @configs['allow_failures'] -%> 141 | allow_failures: 142 | <% @configs['allow_failures'].each do |job| -%> 143 | - 144 | <% job.keys.sort.each do |key| -%> 145 | <%= key %>: <%= job[key] %> 146 | <% end -%> 147 | <% end -%> 148 | <% end -%> 149 | branches: 150 | <% if ((@configs['branches'] || []) - (@configs['remove_branches'] || [])).any? -%> 151 | only: 152 | <% (@configs['branches'] - (@configs['remove_branches'] || [])).each do |branch| -%> 153 | - <%= branch %> 154 | <% end -%> 155 | <% end -%> 156 | <% if @configs['branches_except'] -%> 157 | except: 158 | <% @configs['branches_except'].each do |branch| -%> 159 | - <%= branch %> 160 | <% end -%> 161 | <% end -%> 162 | notifications: 163 | <% notifications_arr = (@configs['notifications'].to_a - @configs['remove_notifications'].to_a) -%> 164 | <% unless notifications_arr.empty? -%> 165 | <% notifications = Hash[*notifications_arr.flatten] -%> 166 | <% notifications.keys.sort.each do |key| -%> 167 | <% if notifications[key].is_a?(Array) or notifications[key].is_a?(Hash) -%> 168 | <%= key %>: 169 | <%= notifications[key].to_yaml.sub(/---\R/, '').gsub(/\R/, "\n ").strip %> 170 | <% else -%> 171 | <%= key %>: <%= notifications[key] %> 172 | <% end -%> 173 | <% end -%> 174 | <% end -%> 175 | <% unless @configs['user'].nil? || @configs['secure'].nil? -%> 176 | <% if @configs['before_deploy'] -%> 177 | before_deploy: 178 | <% @configs['before_deploy'].each do |b_deploy| -%> 179 | - <%= b_deploy %> 180 | <% end -%> 181 | <% end -%> 182 | deploy: 183 | provider: puppetforge 184 | username: <%= @configs['user'] %> 185 | password: 186 | secure: "<%= @configs['secure'] %>" 187 | on: 188 | tags: true 189 | all_branches: true 190 | condition: "$DEPLOY_TO_FORGE = yes" 191 | <% end -%> 192 | -------------------------------------------------------------------------------- /rubocop/defaults-0.49.1.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :default_enabled_cops: 3 | - Bundler/DuplicatedGem 4 | - Bundler/OrderedGems 5 | - GetText/DecorateFunctionMessage 6 | - GetText/DecorateString 7 | - GetText/DecorateStringFormattingUsingInterpolation 8 | - GetText/DecorateStringFormattingUsingPercent 9 | - Layout/AccessModifierIndentation 10 | - Layout/AlignArray 11 | - Layout/AlignHash 12 | - Layout/AlignParameters 13 | - Layout/BlockEndNewline 14 | - Layout/CaseIndentation 15 | - Layout/ClosingParenthesisIndentation 16 | - Layout/CommentIndentation 17 | - Layout/DotPosition 18 | - Layout/ElseAlignment 19 | - Layout/EmptyLineAfterMagicComment 20 | - Layout/EmptyLineBetweenDefs 21 | - Layout/EmptyLines 22 | - Layout/EmptyLinesAroundAccessModifier 23 | - Layout/EmptyLinesAroundBeginBody 24 | - Layout/EmptyLinesAroundBlockBody 25 | - Layout/EmptyLinesAroundClassBody 26 | - Layout/EmptyLinesAroundExceptionHandlingKeywords 27 | - Layout/EmptyLinesAroundMethodBody 28 | - Layout/EmptyLinesAroundModuleBody 29 | - Layout/EndOfLine 30 | - Layout/ExtraSpacing 31 | - Layout/FirstParameterIndentation 32 | - Layout/IndentArray 33 | - Layout/IndentAssignment 34 | - Layout/IndentHash 35 | - Layout/IndentHeredoc 36 | - Layout/IndentationConsistency 37 | - Layout/IndentationWidth 38 | - Layout/InitialIndentation 39 | - Layout/LeadingCommentSpace 40 | - Layout/MultilineArrayBraceLayout 41 | - Layout/MultilineBlockLayout 42 | - Layout/MultilineHashBraceLayout 43 | - Layout/MultilineMethodCallBraceLayout 44 | - Layout/MultilineMethodCallIndentation 45 | - Layout/MultilineMethodDefinitionBraceLayout 46 | - Layout/MultilineOperationIndentation 47 | - Layout/RescueEnsureAlignment 48 | - Layout/SpaceAfterColon 49 | - Layout/SpaceAfterComma 50 | - Layout/SpaceAfterMethodName 51 | - Layout/SpaceAfterNot 52 | - Layout/SpaceAfterSemicolon 53 | - Layout/SpaceAroundBlockParameters 54 | - Layout/SpaceAroundEqualsInParameterDefault 55 | - Layout/SpaceAroundKeyword 56 | - Layout/SpaceAroundOperators 57 | - Layout/SpaceBeforeBlockBraces 58 | - Layout/SpaceBeforeComma 59 | - Layout/SpaceBeforeComment 60 | - Layout/SpaceBeforeFirstArg 61 | - Layout/SpaceBeforeSemicolon 62 | - Layout/SpaceInLambdaLiteral 63 | - Layout/SpaceInsideArrayPercentLiteral 64 | - Layout/SpaceInsideBlockBraces 65 | - Layout/SpaceInsideBrackets 66 | - Layout/SpaceInsideHashLiteralBraces 67 | - Layout/SpaceInsideParens 68 | - Layout/SpaceInsidePercentLiteralDelimiters 69 | - Layout/SpaceInsideRangeLiteral 70 | - Layout/SpaceInsideStringInterpolation 71 | - Layout/Tab 72 | - Layout/TrailingBlankLines 73 | - Layout/TrailingWhitespace 74 | - Lint/AmbiguousBlockAssociation 75 | - Lint/AmbiguousOperator 76 | - Lint/AmbiguousRegexpLiteral 77 | - Lint/AssignmentInCondition 78 | - Lint/BlockAlignment 79 | - Lint/CircularArgumentReference 80 | - Lint/ConditionPosition 81 | - Lint/Debugger 82 | - Lint/DefEndAlignment 83 | - Lint/DeprecatedClassMethods 84 | - Lint/DuplicateCaseCondition 85 | - Lint/DuplicateMethods 86 | - Lint/DuplicatedKey 87 | - Lint/EachWithObjectArgument 88 | - Lint/ElseLayout 89 | - Lint/EmptyEnsure 90 | - Lint/EmptyExpression 91 | - Lint/EmptyInterpolation 92 | - Lint/EmptyWhen 93 | - Lint/EndAlignment 94 | - Lint/EndInMethod 95 | - Lint/EnsureReturn 96 | - Lint/FloatOutOfRange 97 | - Lint/FormatParameterMismatch 98 | - Lint/HandleExceptions 99 | - Lint/ImplicitStringConcatenation 100 | - Lint/IneffectiveAccessModifier 101 | - Lint/InheritException 102 | - Lint/InvalidCharacterLiteral 103 | - Lint/LiteralInCondition 104 | - Lint/LiteralInInterpolation 105 | - Lint/Loop 106 | - Lint/MultipleCompare 107 | - Lint/NestedMethodDefinition 108 | - Lint/NextWithoutAccumulator 109 | - Lint/NonLocalExitFromIterator 110 | - Lint/ParenthesesAsGroupedExpression 111 | - Lint/PercentStringArray 112 | - Lint/PercentSymbolArray 113 | - Lint/RandOne 114 | - Lint/RequireParentheses 115 | - Lint/RescueException 116 | - Lint/RescueType 117 | - Lint/SafeNavigationChain 118 | - Lint/ScriptPermission 119 | - Lint/ShadowedException 120 | - Lint/ShadowingOuterLocalVariable 121 | - Lint/StringConversionInInterpolation 122 | - Lint/UnderscorePrefixedVariableName 123 | - Lint/UnifiedInteger 124 | - Lint/UnneededDisable 125 | - Lint/UnneededSplatExpansion 126 | - Lint/UnreachableCode 127 | - Lint/UnusedBlockArgument 128 | - Lint/UnusedMethodArgument 129 | - Lint/UselessAccessModifier 130 | - Lint/UselessAssignment 131 | - Lint/UselessComparison 132 | - Lint/UselessElseWithoutRescue 133 | - Lint/UselessSetterCall 134 | - Lint/Void 135 | - Metrics/AbcSize 136 | - Metrics/BlockLength 137 | - Metrics/BlockNesting 138 | - Metrics/ClassLength 139 | - Metrics/CyclomaticComplexity 140 | - Metrics/LineLength 141 | - Metrics/MethodLength 142 | - Metrics/ModuleLength 143 | - Metrics/ParameterLists 144 | - Metrics/PerceivedComplexity 145 | - Performance/Caller 146 | - Performance/CaseWhenSplat 147 | - Performance/Casecmp 148 | - Performance/CompareWithBlock 149 | - Performance/Count 150 | - Performance/Detect 151 | - Performance/DoubleStartEndWith 152 | - Performance/EndWith 153 | - Performance/FixedSize 154 | - Performance/FlatMap 155 | - Performance/HashEachMethods 156 | - Performance/LstripRstrip 157 | - Performance/RangeInclude 158 | - Performance/RedundantBlockCall 159 | - Performance/RedundantMatch 160 | - Performance/RedundantMerge 161 | - Performance/RedundantSortBy 162 | - Performance/RegexpMatch 163 | - Performance/ReverseEach 164 | - Performance/Sample 165 | - Performance/Size 166 | - Performance/StartWith 167 | - Performance/StringReplacement 168 | - Performance/TimesMap 169 | - RSpec/AnyInstance 170 | - RSpec/AroundBlock 171 | - RSpec/BeEql 172 | - RSpec/BeforeAfterAll 173 | - RSpec/DescribeClass 174 | - RSpec/DescribeMethod 175 | - RSpec/DescribeSymbol 176 | - RSpec/DescribedClass 177 | - RSpec/EmptyExampleGroup 178 | - RSpec/EmptyLineAfterFinalLet 179 | - RSpec/EmptyLineAfterSubject 180 | - RSpec/ExampleLength 181 | - RSpec/ExampleWording 182 | - RSpec/ExpectActual 183 | - RSpec/ExpectOutput 184 | - RSpec/FilePath 185 | - RSpec/Focus 186 | - RSpec/HookArgument 187 | - RSpec/ImplicitExpect 188 | - RSpec/InstanceSpy 189 | - RSpec/InstanceVariable 190 | - RSpec/ItBehavesLike 191 | - RSpec/IteratedExpectation 192 | - RSpec/LeadingSubject 193 | - RSpec/LetSetup 194 | - RSpec/MessageChain 195 | - RSpec/MessageExpectation 196 | - RSpec/MessageSpies 197 | - RSpec/MultipleDescribes 198 | - RSpec/MultipleExpectations 199 | - RSpec/NamedSubject 200 | - RSpec/NestedGroups 201 | - RSpec/NotToNot 202 | - RSpec/OverwritingSetup 203 | - RSpec/RepeatedDescription 204 | - RSpec/RepeatedExample 205 | - RSpec/ScatteredLet 206 | - RSpec/ScatteredSetup 207 | - RSpec/SharedContext 208 | - RSpec/SingleArgumentMessageChain 209 | - RSpec/SubjectStub 210 | - RSpec/VerifiedDoubles 211 | - Security/Eval 212 | - Security/JSONLoad 213 | - Security/MarshalLoad 214 | - Security/YAMLLoad 215 | - Style/AccessorMethodName 216 | - Style/Alias 217 | - Style/AndOr 218 | - Style/ArrayJoin 219 | - Style/AsciiComments 220 | - Style/AsciiIdentifiers 221 | - Style/Attr 222 | - Style/BarePercentLiterals 223 | - Style/BeginBlock 224 | - Style/BlockComments 225 | - Style/BlockDelimiters 226 | - Style/CaseEquality 227 | - Style/CharacterLiteral 228 | - Style/ClassAndModuleCamelCase 229 | - Style/ClassAndModuleChildren 230 | - Style/ClassCheck 231 | - Style/ClassMethods 232 | - Style/ClassVars 233 | - Style/ColonMethodCall 234 | - Style/CommandLiteral 235 | - Style/CommentAnnotation 236 | - Style/ConditionalAssignment 237 | - Style/ConstantName 238 | - Style/DefWithParentheses 239 | - Style/Documentation 240 | - Style/DoubleNegation 241 | - Style/EachForSimpleLoop 242 | - Style/EachWithObject 243 | - Style/EmptyCaseCondition 244 | - Style/EmptyElse 245 | - Style/EmptyLiteral 246 | - Style/EmptyMethod 247 | - Style/EndBlock 248 | - Style/EvenOdd 249 | - Style/FileName 250 | - Style/FlipFlop 251 | - Style/For 252 | - Style/FormatString 253 | - Style/FormatStringToken 254 | - Style/FrozenStringLiteralComment 255 | - Style/GlobalVars 256 | - Style/GuardClause 257 | - Style/HashSyntax 258 | - Style/IdenticalConditionalBranches 259 | - Style/IfInsideElse 260 | - Style/IfUnlessModifier 261 | - Style/IfUnlessModifierOfIfUnless 262 | - Style/IfWithSemicolon 263 | - Style/InfiniteLoop 264 | - Style/InverseMethods 265 | - Style/Lambda 266 | - Style/LambdaCall 267 | - Style/LineEndConcatenation 268 | - Style/MethodCallWithoutArgsParentheses 269 | - Style/MethodDefParentheses 270 | - Style/MethodMissing 271 | - Style/MethodName 272 | - Style/MixinGrouping 273 | - Style/ModuleFunction 274 | - Style/MultilineBlockChain 275 | - Style/MultilineIfModifier 276 | - Style/MultilineIfThen 277 | - Style/MultilineMemoization 278 | - Style/MultilineTernaryOperator 279 | - Style/MultipleComparison 280 | - Style/MutableConstant 281 | - Style/NegatedIf 282 | - Style/NegatedWhile 283 | - Style/NestedModifier 284 | - Style/NestedParenthesizedCalls 285 | - Style/NestedTernaryOperator 286 | - Style/Next 287 | - Style/NilComparison 288 | - Style/NonNilCheck 289 | - Style/Not 290 | - Style/NumericLiteralPrefix 291 | - Style/NumericLiterals 292 | - Style/NumericPredicate 293 | - Style/OneLineConditional 294 | - Style/OpMethod 295 | - Style/OptionalArguments 296 | - Style/ParallelAssignment 297 | - Style/ParenthesesAroundCondition 298 | - Style/PercentLiteralDelimiters 299 | - Style/PercentQLiterals 300 | - Style/PerlBackrefs 301 | - Style/PredicateName 302 | - Style/PreferredHashMethods 303 | - Style/Proc 304 | - Style/RaiseArgs 305 | - Style/RedundantBegin 306 | - Style/RedundantException 307 | - Style/RedundantFreeze 308 | - Style/RedundantParentheses 309 | - Style/RedundantReturn 310 | - Style/RedundantSelf 311 | - Style/RegexpLiteral 312 | - Style/RescueModifier 313 | - Style/SafeNavigation 314 | - Style/SelfAssignment 315 | - Style/Semicolon 316 | - Style/SignalException 317 | - Style/SingleLineMethods 318 | - Style/SpecialGlobalVars 319 | - Style/StabbyLambdaParentheses 320 | - Style/StringLiterals 321 | - Style/StringLiteralsInInterpolation 322 | - Style/StructInheritance 323 | - Style/SymbolArray 324 | - Style/SymbolLiteral 325 | - Style/SymbolProc 326 | - Style/TernaryParentheses 327 | - Style/TrailingCommaInArguments 328 | - Style/TrailingCommaInLiteral 329 | - Style/TrailingUnderscoreVariable 330 | - Style/TrivialAccessors 331 | - Style/UnlessElse 332 | - Style/UnneededCapitalW 333 | - Style/UnneededInterpolation 334 | - Style/UnneededPercentQ 335 | - Style/VariableInterpolation 336 | - Style/VariableName 337 | - Style/VariableNumber 338 | - Style/WhenThen 339 | - Style/WhileUntilDo 340 | - Style/WhileUntilModifier 341 | - Style/WordArray 342 | - Style/YodaCondition 343 | - Style/ZeroLengthPredicate 344 | -------------------------------------------------------------------------------- /moduleroot/.github/CONTRIBUTING.md.erb: -------------------------------------------------------------------------------- 1 | # Contribution guidelines 2 | 3 | ## Table of contents 4 | 5 | * [Contributing](#contributing) 6 | * [Writing proper commits - short version](#writing-proper-commits-short-version) 7 | * [Writing proper commits - long version](#writing-proper-commits-long-version) 8 | * [Dependencies](#dependencies) 9 | * [Note for OS X users](#note-for-os-x-users) 10 | * [The test matrix](#the-test-matrix) 11 | * [Syntax and style](#syntax-and-style) 12 | * [Running the unit tests](#running-the-unit-tests) 13 | * [Unit tests in docker](#unit-tests-in-docker) 14 | * [Integration tests](#integration-tests) 15 | 16 | This module has grown over time based on a range of contributions from 17 | people using it. If you follow these contributing guidelines your patch 18 | will likely make it into a release a little more quickly. 19 | 20 | ## Contributing 21 | 22 | Please note that this project is released with a Contributor Code of Conduct. 23 | By participating in this project you agree to abide by its terms. 24 | [Contributor Code of Conduct](https://voxpupuli.org/coc/). 25 | 26 | * Fork the repo. 27 | * Create a separate branch for your change. 28 | * We only take pull requests with passing tests, and documentation. [travis-ci](http://travis-ci.org) runs the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). 29 | * Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. 30 | * Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. 31 | * Squash your commits down into logical components. Make sure to rebase against our current master. 32 | * Push the branch to your fork and submit a pull request. 33 | 34 | Please be prepared to repeat some of these steps as our contributors review your code. 35 | 36 | ## Writing proper commits - short version 37 | 38 | * Make commits of logical units. 39 | * Check for unnecessary whitespace with "git diff --check" before committing. 40 | * Commit using Unix line endings (check the settings around "crlf" in git-config(1)). 41 | * Do not check in commented out code or unneeded files. 42 | * The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. 43 | * Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". 44 | * The body should provide a meaningful commit message, which: 45 | *uses the imperative, present tense: `change`, not `changed` or `changes`. 46 | * includes motivation for the change, and contrasts its implementation with the previous behavior. 47 | * Make sure that you have tests for the bug you are fixing, or feature you are adding. 48 | * Make sure the test suites passes after your commit: 49 | * When introducing a new feature, make sure it is properly documented in the README.md 50 | 51 | ## Writing proper commits - long version 52 | 53 | 1. Make separate commits for logically separate changes. 54 | 55 | Please break your commits down into logically consistent units 56 | which include new or changed tests relevant to the rest of the 57 | change. The goal of doing this is to make the diff easier to 58 | read for whoever is reviewing your code. In general, the easier 59 | your diff is to read, the more likely someone will be happy to 60 | review it and get it into the code base. 61 | 62 | If you are going to refactor a piece of code, please do so as a 63 | separate commit from your feature or bug fix changes. 64 | 65 | We also really appreciate changes that include tests to make 66 | sure the bug is not re-introduced, and that the feature is not 67 | accidentally broken. 68 | 69 | Describe the technical detail of the change(s). If your 70 | description starts to get too long, that is a good sign that you 71 | probably need to split up your commit into more finely grained 72 | pieces. 73 | 74 | Commits which plainly describe the things which help 75 | reviewers check the patch and future developers understand the 76 | code are much more likely to be merged in with a minimum of 77 | bike-shedding or requested changes. Ideally, the commit message 78 | would include information, and be in a form suitable for 79 | inclusion in the release notes for the version of Puppet that 80 | includes them. 81 | 82 | Please also check that you are not introducing any trailing 83 | whitespace or other "whitespace errors". You can do this by 84 | running "git diff --check" on your changes before you commit. 85 | 86 | 2. Sending your patches 87 | 88 | To submit your changes via a GitHub pull request, we _highly_ 89 | recommend that you have them on a topic branch, instead of 90 | directly on `master`. 91 | It makes things much easier to keep track of, especially if 92 | you decide to work on another thing before your first change 93 | is merged in. 94 | 95 | GitHub has some pretty good 96 | [general documentation](http://help.github.com/) on using 97 | their site. They also have documentation on 98 | [creating pull requests](http://help.github.com/send-pull-requests/). 99 | 100 | In general, after pushing your topic branch up to your 101 | repository on GitHub, you can switch to the branch in the 102 | GitHub UI and click "Pull Request" towards the top of the page 103 | in order to open a pull request. 104 | 105 | 106 | 3. Update the related GitHub issue. 107 | 108 | If there is a GitHub issue associated with the change you 109 | submitted, then you should update the ticket to include the 110 | location of your branch, along with any other commentary you 111 | may wish to make. 112 | 113 | ## Dependencies 114 | 115 | The testing and development tools have a bunch of dependencies, 116 | all managed by [bundler](http://bundler.io/) according to the 117 | [Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). 118 | 119 | By default the tests use a baseline version of Puppet. 120 | 121 | If you have Ruby 2.x or want a specific version of Puppet, 122 | you must set an environment variable such as: 123 | 124 | ```sh 125 | export PUPPET_VERSION="~> 5.5.6" 126 | ``` 127 | 128 | You can install all needed gems for spec tests into the modules directory by 129 | running: 130 | 131 | ```sh 132 | bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" 133 | ``` 134 | 135 | If you also want to run acceptance tests: 136 | 137 | ```sh 138 | bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" 139 | ``` 140 | 141 | Our all in one solution if you don't know if you need to install or update gems: 142 | 143 | ```sh 144 | bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean 145 | ``` 146 | 147 | As an alternative to the `--jobs "$(nproc)` parameter, you can set an 148 | environment variable: 149 | 150 | ```sh 151 | BUNDLE_JOBS="$(nproc)" 152 | ``` 153 | 154 | ### Note for OS X users 155 | 156 | `nproc` isn't a valid command under OS x. As an alternative, you can do: 157 | 158 | ```sh 159 | --jobs "$(sysctl -n hw.ncpu)" 160 | ``` 161 | 162 | ## The test matrix 163 | 164 | ### Syntax and style 165 | 166 | The test suite will run [Puppet Lint](http://puppet-lint.com/) and 167 | [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to 168 | check various syntax and style things. You can run these locally with: 169 | 170 | ```sh 171 | bundle exec rake lint 172 | bundle exec rake validate 173 | ``` 174 | 175 | It will also run some [Rubocop](http://batsov.com/rubocop/) tests 176 | against it. You can run those locally ahead of time with: 177 | 178 | ```sh 179 | bundle exec rake rubocop 180 | ``` 181 | 182 | ### Running the unit tests 183 | 184 | The unit test suite covers most of the code, as mentioned above please 185 | add tests if you're adding new functionality. If you've not used 186 | [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask 187 | about how best to test your new feature. 188 | 189 | To run the linter, the syntax checker and the unit tests: 190 | 191 | ```sh 192 | bundle exec rake test 193 | ``` 194 | 195 | To run your all the unit tests 196 | 197 | ```sh 198 | bundle exec rake spec 199 | ``` 200 | 201 | To run a specific spec test set the `SPEC` variable: 202 | 203 | ```sh 204 | bundle exec rake spec SPEC=spec/foo_spec.rb 205 | ``` 206 | 207 | #### Unit tests in docker 208 | 209 | Some people don't want to run the dependencies locally or don't want to install 210 | ruby. We ship a Dockerfile that enables you to run all unit tests and linting. 211 | You only need to run: 212 | 213 | ```sh 214 | docker build . 215 | ``` 216 | 217 | Please ensure that a docker daemon is running and that your user has the 218 | permission to talk to it. You can specify a remote docker host by setting the 219 | `DOCKER_HOST` environment variable. it will copy the content of the module into 220 | the docker image. So it will not work if a Gemfile.lock exists. 221 | 222 | ### Integration tests 223 | 224 | The unit tests just check the code runs, not that it does exactly what 225 | we want on a real machine. For that we're using 226 | [beaker](https://github.com/puppetlabs/beaker). 227 | 228 | This fires up a new virtual machine (using vagrant) and runs a series of 229 | simple tests against it after applying the module. You can run this 230 | with: 231 | 232 | ```sh 233 | bundle exec rake acceptance 234 | ``` 235 | 236 | This will run the tests on the module's default nodeset. You can override the 237 | nodeset used, e.g., 238 | 239 | ```sh 240 | BEAKER_set=centos-7-x64 bundle exec rake acceptance 241 | ``` 242 | 243 | There are default rake tasks for the various acceptance test modules, e.g., 244 | 245 | ```sh 246 | bundle exec rake beaker:centos-7-x64 247 | bundle exec rake beaker:ssh:centos-7-x64 248 | ``` 249 | 250 | If you don't want to have to recreate the virtual machine every time you can 251 | use `BEAKER_destroy=no` and `BEAKER_provision=no`. On the first run you will at 252 | least need `BEAKER_provision` set to yes (the default). The Vagrantfile for the 253 | created virtual machines will be in `.vagrant/beaker_vagrant_files`. 254 | 255 | Beaker also supports docker containers. We also use that in our automated CI 256 | pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant: 257 | 258 | ```sh 259 | PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian10-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker 260 | ``` 261 | 262 | You can replace the string `debian10` with any common operating system. 263 | The following strings are known to work: 264 | 265 | * ubuntu1604 266 | * ubuntu1804 267 | * debian8 268 | * debian9 269 | * debian10 270 | * centos6 271 | * centos7 272 | * centos8 273 | 274 | The easiest way to debug in a docker container is to open a shell: 275 | 276 | ```sh 277 | docker exec -it -u root ${container_id_or_name} bash 278 | ``` 279 | 280 | The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) 281 | repository. 282 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /config_defaults.yml: -------------------------------------------------------------------------------- 1 | --- 2 | common: 3 | disable_legacy_facts: false 4 | .gitattributes: 5 | include: 6 | '*.rb': 'eol=lf' 7 | '*.erb': 'eol=lf' 8 | '*.pp': 'eol=lf' 9 | '*.sh': 'eol=lf' 10 | '*.epp': 'eol=lf' 11 | .gitignore: 12 | required: &ignorepaths 13 | - '.git/' 14 | - '.*.sw[op]' 15 | - '.metadata' 16 | - '.yardoc' 17 | - '.yardwarns' 18 | - '*.iml' 19 | - '/.bundle/' 20 | - '/.idea/' 21 | - '/.vagrant/' 22 | - '/coverage/' 23 | - '/bin/' 24 | - '/doc/' 25 | - '/Gemfile.local' 26 | - '/Gemfile.lock' 27 | - '/junit/' 28 | - '/log/' 29 | - '/pkg/' 30 | - '/spec/fixtures/manifests/' 31 | - '/spec/fixtures/modules/' 32 | - '/tmp/' 33 | - '/vendor/' 34 | - '/convert_report.txt' 35 | - '/update_report.txt' 36 | - '.DS_Store' 37 | - '.project' 38 | - '.envrc' 39 | - '/inventory.yaml' 40 | .pdkignore: 41 | required: *ignorepaths 42 | paths: 43 | - '/appveyor.yml' 44 | - '/.fixtures.yml' 45 | - '/Gemfile' 46 | - '/.gitattributes' 47 | - '/.gitignore' 48 | - '/.gitlab-ci.yml' 49 | - '/.pdkignore' 50 | - '/Rakefile' 51 | - '/rakelib/' 52 | - '/.rspec' 53 | - '/.rubocop.yml' 54 | - '/.travis.yml' 55 | - '/.yardopts' 56 | - '/spec/' 57 | - '/.vscode/' 58 | .travis.yml: 59 | stages: 60 | - static 61 | - spec 62 | - acceptance 63 | ruby_versions: 64 | - 2.5.8 65 | bundler_args: --without system_tests release 66 | docker_sets: 67 | docker_defaults: 68 | # values will replace @@SET@@ with the docker_sets' value 69 | rvm: 2.5.8 70 | sudo: required 71 | dist: trusty 72 | services: docker 73 | bundler_args: --without system_tests release 74 | env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=@@COLLECTION@@ BEAKER_set=@@SET@@ BEAKER_TESTMODE=@@TESTMODE@@ 75 | script: 'bundle exec rake $CHECK' 76 | stage: acceptance 77 | includes: 78 | - env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" 79 | stage: static 80 | - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec 81 | rvm: 2.4.9 82 | stage: spec 83 | - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec 84 | rvm: 2.5.8 85 | stage: spec 86 | branches: 87 | - master 88 | - /^v\d/ 89 | use_litmus: false 90 | litmus: 91 | provision_list: [travis_deb, travis_el] 92 | puppet_collection: [puppet5, puppet6] 93 | rvm: '2.5.8' 94 | install_wget: no 95 | notifications: 96 | email: false 97 | webhooks: https://voxpupu.li/incoming/travis 98 | irc: 99 | on_success: always 100 | on_failure: always 101 | channels: 102 | - "chat.freenode.org#voxpupuli-notifications" 103 | user: puppet 104 | deploy_to_forge: 105 | enabled: true 106 | tag_regex: "^v\\d" 107 | .yardopts: 108 | markup: markdown 109 | appveyor.yml: 110 | delete: true 111 | appveyor_bundle_install: "bundle install --jobs 4 --retry 2 --without system_tests" 112 | use_litmus: false 113 | matrix: 114 | - RUBY_VERSION: 24-x64 115 | CHECK: "syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" 116 | - PUPPET_GEM_VERSION: ~> 5.0 117 | RUBY_VERSION: 24 118 | CHECK: parallel_spec 119 | - PUPPET_GEM_VERSION: ~> 5.0 120 | RUBY_VERSION: 24-x64 121 | CHECK: parallel_spec 122 | - PUPPET_GEM_VERSION: ~> 6.0 123 | RUBY_VERSION: 25 124 | CHECK: parallel_spec 125 | - PUPPET_GEM_VERSION: ~> 6.0 126 | RUBY_VERSION: 25-x64 127 | CHECK: parallel_spec 128 | test_script: 129 | - bundle exec rake %CHECK% 130 | branches: 131 | - master 132 | - release 133 | Rakefile: 134 | requires: 135 | - require: 'voxpupuli/release/rake_tasks' 136 | conditional: "Bundler.rubygems.find_name('voxpupuli-release').any?" 137 | config.user: voxpupuli 138 | puppet_strings_patterns: [] 139 | changelog_version_tag_pattern: 'v%s' 140 | linter_fail_on_warnings: true 141 | default_disabled_lint_checks: 142 | - 'relative' 143 | - '140chars' 144 | - 'class_inherits_from_params_class' 145 | - 'documentation' 146 | - 'single_quote_string_with_variables' 147 | log_format: "'%{path}:%{line}:%{check}:%{KIND}:%{message}'" 148 | extras: [] 149 | .rubocop.yml: 150 | selected_profile: strict 151 | default_configs: &default_configs 152 | Metrics/LineLength: 153 | Description: People have wide screens, use them. 154 | Max: 200 155 | 156 | # Disabled i18n cops by default 157 | GetText: 158 | Enabled: false 159 | 160 | # Configure i18n cops for when they are enabled 161 | GetText/DecorateString: 162 | Description: We don't want to decorate test output. 163 | Exclude: 164 | - 'spec/**/*' 165 | 166 | # RSpec cops 167 | RSpec/BeforeAfterAll: 168 | Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. 169 | Exclude: 170 | - 'spec/acceptance/**/*.rb' 171 | 172 | RSpec/HookArgument: 173 | Description: Prefer explicit :each argument, matching existing module's style 174 | EnforcedStyle: each 175 | 176 | # Style Cops 177 | Style/BlockDelimiters: 178 | Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. 179 | EnforcedStyle: braces_for_chaining 180 | 181 | Style/BracesAroundHashParameters: 182 | Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. See https://github.com/rubocop-hq/rubocop/pull/7643 183 | Enabled: false 184 | 185 | Style/ClassAndModuleChildren: 186 | Description: Compact style reduces the required amount of indentation. 187 | EnforcedStyle: compact 188 | 189 | Style/EmptyElse: 190 | Description: Enforce against empty else clauses, but allow `nil` for clarity. 191 | EnforcedStyle: empty 192 | 193 | Style/FormatString: 194 | Description: Following the main puppet project's style, prefer the % format format. 195 | EnforcedStyle: percent 196 | 197 | Style/FormatStringToken: 198 | Description: Following the main puppet project's style, prefer the simpler template tokens over annotated ones. 199 | EnforcedStyle: template 200 | 201 | Style/Lambda: 202 | Description: Prefer the keyword for easier discoverability. 203 | EnforcedStyle: literal 204 | 205 | Style/RegexpLiteral: 206 | Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 207 | EnforcedStyle: percent_r 208 | 209 | Style/TernaryParentheses: 210 | Description: Checks for use of parentheses around ternary conditions. Enforce parentheses on complex expressions for better readability, but seriously consider breaking it up. 211 | EnforcedStyle: require_parentheses_when_complex 212 | 213 | Style/TrailingCommaInArguments: 214 | Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. 215 | EnforcedStyleForMultiline: comma 216 | 217 | Style/TrailingCommaInLiteral: 218 | Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. 219 | EnforcedStyleForMultiline: comma 220 | 221 | Style/SymbolArray: 222 | Description: Using percent style obscures symbolic intent of array's contents. 223 | EnforcedStyle: brackets 224 | 225 | cleanup_cops: &cleanup_cops 226 | Bundler/OrderedGems: 227 | Layout/AccessModifierIndentation: 228 | Layout/AlignArray: 229 | Layout/AlignHash: 230 | Layout/AlignParameters: 231 | Layout/BlockEndNewline: 232 | Layout/CaseIndentation: 233 | Layout/ClosingParenthesisIndentation: 234 | Layout/CommentIndentation: 235 | Layout/DotPosition: 236 | Layout/ElseAlignment: 237 | Layout/EmptyLineAfterMagicComment: 238 | Layout/EmptyLineBetweenDefs: 239 | Layout/EmptyLines: 240 | Layout/EmptyLinesAroundAccessModifier: 241 | Layout/EmptyLinesAroundBlockBody: 242 | Layout/EmptyLinesAroundClassBody: 243 | Layout/EmptyLinesAroundExceptionHandlingKeywords: 244 | Layout/EmptyLinesAroundMethodBody: 245 | Layout/EmptyLinesAroundModuleBody: 246 | Layout/ExtraSpacing: 247 | Layout/FirstParameterIndentation: 248 | Layout/IndentArray: 249 | Layout/IndentAssignment: 250 | Layout/IndentHash: 251 | Layout/IndentationConsistency: 252 | Layout/IndentationWidth: 253 | Layout/InitialIndentation: 254 | Layout/LeadingCommentSpace: 255 | Layout/MultilineArrayBraceLayout: 256 | Layout/MultilineBlockLayout: 257 | Layout/MultilineHashBraceLayout: 258 | Layout/MultilineMethodCallBraceLayout: 259 | Layout/MultilineMethodCallIndentation: 260 | Layout/MultilineMethodDefinitionBraceLayout: 261 | Layout/MultilineOperationIndentation: 262 | Layout/RescueEnsureAlignment: 263 | Layout/SpaceAfterColon: 264 | Layout/SpaceAfterComma: 265 | Layout/SpaceAfterMethodName: 266 | Layout/SpaceAfterNot: 267 | Layout/SpaceAfterSemicolon: 268 | Layout/SpaceAroundBlockParameters: 269 | Layout/SpaceAroundEqualsInParameterDefault: 270 | Layout/SpaceAroundKeyword: 271 | Layout/SpaceAroundOperators: 272 | Layout/SpaceBeforeBlockBraces: 273 | Layout/SpaceBeforeComma: 274 | Layout/SpaceBeforeComment: 275 | Layout/SpaceBeforeFirstArg: 276 | Layout/SpaceBeforeSemicolon: 277 | Layout/SpaceInLambdaLiteral: 278 | Layout/SpaceInsideArrayPercentLiteral: 279 | Layout/SpaceInsideBlockBraces: 280 | Layout/SpaceInsideBrackets: 281 | Layout/SpaceInsideHashLiteralBraces: 282 | Layout/SpaceInsideParens: 283 | Layout/SpaceInsidePercentLiteralDelimiters: 284 | Layout/SpaceInsideRangeLiteral: 285 | Layout/SpaceInsideStringInterpolation: 286 | Layout/Tab: 287 | Layout/TrailingBlankLines: 288 | Layout/TrailingWhitespace: 289 | Lint/BlockAlignment: 290 | Lint/DefEndAlignment: 291 | Lint/DeprecatedClassMethods: 292 | Lint/EmptyInterpolation: 293 | Lint/LiteralInInterpolation: 294 | Lint/MultipleCompare: 295 | Lint/PercentStringArray: 296 | Lint/PercentSymbolArray: 297 | Lint/RescueType: 298 | Lint/SafeNavigationChain: 299 | Lint/StringConversionInInterpolation: 300 | Lint/UnifiedInteger: 301 | Lint/UnneededSplatExpansion: 302 | Lint/UnusedBlockArgument: 303 | Lint/UnusedMethodArgument: 304 | Performance/CaseWhenSplat: 305 | Performance/Casecmp: 306 | Performance/CompareWithBlock: 307 | Performance/Count: 308 | Performance/Detect: 309 | Performance/DoubleStartEndWith: 310 | Performance/FlatMap: 311 | Performance/LstripRstrip: 312 | Performance/RangeInclude: 313 | Performance/RedundantBlockCall: 314 | Performance/RedundantMatch: 315 | Performance/RedundantMerge: 316 | Performance/RedundantSortBy: 317 | Performance/RegexpMatch: 318 | Performance/ReverseEach: 319 | Performance/Sample: 320 | Performance/Size: 321 | Performance/StartWith: 322 | Performance/StringReplacement: 323 | Performance/TimesMap: 324 | RSpec/BeEql: 325 | RSpec/DescribedClass: 326 | RSpec/EmptyLineAfterFinalLet: 327 | RSpec/EmptyLineAfterSubject: 328 | RSpec/ExampleWording: 329 | RSpec/HookArgument: 330 | RSpec/ImplicitExpect: 331 | RSpec/InstanceSpy: 332 | RSpec/ItBehavesLike: 333 | RSpec/LeadingSubject: 334 | RSpec/NotToNot: 335 | RSpec/SharedContext: 336 | RSpec/SingleArgumentMessageChain: 337 | Security/JSONLoad: 338 | Security/YAMLLoad: 339 | Style/Alias: 340 | Style/AndOr: 341 | Style/ArrayJoin: 342 | Style/Attr: 343 | Style/BarePercentLiterals: 344 | Style/BlockComments: 345 | Style/BlockDelimiters: 346 | Style/BracesAroundHashParameters: 347 | Style/CharacterLiteral: 348 | Style/ClassCheck: 349 | Style/ClassMethods: 350 | Style/CollectionMethods: 351 | Style/ColonMethodCall: 352 | Style/CommandLiteral: 353 | Style/CommentAnnotation: 354 | Style/ConditionalAssignment: 355 | Style/DefWithParentheses: 356 | Style/EachForSimpleLoop: 357 | Style/EachWithObject: 358 | Style/EmptyCaseCondition: 359 | Style/EmptyElse: 360 | Style/EmptyLiteral: 361 | Style/EmptyMethod: 362 | Style/EvenOdd: 363 | Style/FormatString: 364 | Style/FrozenStringLiteralComment: 365 | Style/HashSyntax: 366 | Style/InfiniteLoop: 367 | Style/InverseMethods: 368 | Style/Lambda: 369 | Style/LambdaCall: 370 | Style/LineEndConcatenation: 371 | Style/MethodCallWithoutArgsParentheses: 372 | Style/MethodDefParentheses: 373 | Style/MixinGrouping: 374 | Style/MultilineIfThen: 375 | Style/MultilineMemoization: 376 | Style/MutableConstant: 377 | Style/NegatedIf: 378 | Style/NegatedWhile: 379 | Style/NestedModifier: 380 | Style/NestedParenthesizedCalls: 381 | Style/Next: 382 | Style/NilComparison: 383 | Style/NonNilCheck: 384 | Style/Not: 385 | Style/NumericLiteralPrefix: 386 | Style/NumericLiterals: 387 | Style/OneLineConditional: 388 | Style/ParallelAssignment: 389 | Style/ParenthesesAroundCondition: 390 | Style/PercentLiteralDelimiters: 391 | Style/PercentQLiterals: 392 | Style/PerlBackrefs: 393 | Style/PreferredHashMethods: 394 | Style/Proc: 395 | Style/RaiseArgs: 396 | Style/RedundantBegin: 397 | Style/RedundantException: 398 | Style/RedundantFreeze: 399 | Style/RedundantParentheses: 400 | Style/RedundantReturn: 401 | Style/RedundantSelf: 402 | Style/RegexpLiteral: 403 | Style/RescueModifier: 404 | Style/SafeNavigation: 405 | Style/Semicolon: 406 | Style/SignalException: 407 | Style/SingleLineMethods: 408 | Style/SpecialGlobalVars: 409 | Style/StabbyLambdaParentheses: 410 | Style/StringLiterals: 411 | Style/StringLiteralsInInterpolation: 412 | Style/StringMethods: 413 | Style/SymbolArray: 414 | Style/SymbolLiteral: 415 | Style/TernaryParentheses: 416 | Style/TrailingCommaInArguments: 417 | Style/TrailingCommaInLiteral: 418 | Style/TrailingUnderscoreVariable: 419 | Style/TrivialAccessors: 420 | Style/UnlessElse: 421 | Style/UnneededCapitalW: 422 | Style/UnneededInterpolation: 423 | Style/UnneededPercentQ: 424 | Style/VariableInterpolation: 425 | Style/WhenThen: 426 | Style/WhileUntilDo: 427 | Style/WhileUntilModifier: 428 | Style/WordArray: 429 | EnforcedStyle: brackets 430 | Style/YodaCondition: 431 | Style/ZeroLengthPredicate: 432 | 433 | profiles: 434 | # no rubocops enabled, caveat emptor! 435 | off: 436 | enabled_cops: {} 437 | 438 | # a sanitized list of cops that'll cleanup a code base without much effort 439 | # they all support autocorrect, and should be fairly uncontroversial across 440 | # wide segments of the Community. 441 | cleanups_only: 442 | configs: *default_configs 443 | enabled_cops: *cleanup_cops 444 | 445 | # a good mix of cops with community recommended settings 446 | strict: 447 | configs: *default_configs 448 | enabled_cops: 449 | <<: *cleanup_cops 450 | Bundler/DuplicatedGem: 451 | Layout/EmptyLinesAroundBeginBody: 452 | Lint/AmbiguousBlockAssociation: 453 | Lint/AmbiguousOperator: 454 | Lint/AmbiguousRegexpLiteral: 455 | Lint/AssignmentInCondition: 456 | Lint/CircularArgumentReference: 457 | Lint/ConditionPosition: 458 | Lint/Debugger: 459 | Lint/DuplicateCaseCondition: 460 | Lint/DuplicateMethods: 461 | Lint/DuplicatedKey: 462 | Lint/EachWithObjectArgument: 463 | Lint/ElseLayout: 464 | Lint/EmptyEnsure: 465 | Lint/EmptyExpression: 466 | Lint/EmptyWhen: 467 | Lint/EndAlignment: 468 | Lint/EndInMethod: 469 | Lint/EnsureReturn: 470 | Lint/FloatOutOfRange: 471 | Lint/FormatParameterMismatch: 472 | Lint/HandleExceptions: 473 | Lint/ImplicitStringConcatenation: 474 | Lint/IneffectiveAccessModifier: 475 | Lint/InheritException: 476 | Lint/InvalidCharacterLiteral: 477 | Lint/LiteralInCondition: 478 | Lint/Loop: 479 | Lint/NestedMethodDefinition: 480 | Lint/NextWithoutAccumulator: 481 | Lint/NonLocalExitFromIterator: 482 | Lint/ParenthesesAsGroupedExpression: 483 | Lint/RandOne: 484 | Lint/RequireParentheses: 485 | Lint/RescueException: 486 | Lint/ScriptPermission: 487 | Lint/ShadowedException: 488 | Lint/ShadowingOuterLocalVariable: 489 | Lint/UnderscorePrefixedVariableName: 490 | Lint/UnneededDisable: 491 | Lint/UnreachableCode: 492 | Lint/UselessAccessModifier: 493 | Lint/UselessAssignment: 494 | Lint/UselessComparison: 495 | Lint/UselessElseWithoutRescue: 496 | Lint/UselessSetterCall: 497 | Lint/Void: 498 | Metrics/BlockNesting: 499 | Metrics/LineLength: 500 | Performance/Caller: 501 | Performance/EndWith: 502 | Performance/FixedSize: 503 | Performance/HashEachMethods: 504 | RSpec/AnyInstance: 505 | RSpec/AroundBlock: 506 | RSpec/BeforeAfterAll: 507 | RSpec/DescribeMethod: 508 | RSpec/DescribeSymbol: 509 | RSpec/EmptyExampleGroup: 510 | RSpec/ExpectActual: 511 | RSpec/ExpectOutput: 512 | RSpec/FilePath: 513 | RSpec/Focus: 514 | RSpec/InstanceVariable: 515 | RSpec/IteratedExpectation: 516 | RSpec/LetSetup: 517 | RSpec/MessageChain: 518 | RSpec/MessageSpies: 519 | EnforcedStyle: receive 520 | RSpec/MultipleDescribes: 521 | RSpec/NamedSubject: 522 | RSpec/OverwritingSetup: 523 | RSpec/RepeatedDescription: 524 | RSpec/RepeatedExample: 525 | RSpec/ScatteredLet: 526 | RSpec/ScatteredSetup: 527 | RSpec/SubjectStub: 528 | RSpec/VerifiedDoubles: 529 | Security/Eval: 530 | Security/MarshalLoad: 531 | Style/AccessorMethodName: 532 | Style/AsciiIdentifiers: 533 | Style/BeginBlock: 534 | Style/CaseEquality: 535 | Style/ClassAndModuleCamelCase: 536 | Style/ClassAndModuleChildren: 537 | Style/ClassVars: 538 | Style/ConstantName: 539 | Style/Documentation: 540 | Exclude: 541 | - 'lib/puppet/parser/functions/**/*' 542 | - 'spec/**/*' 543 | Style/DoubleNegation: 544 | Style/EndBlock: 545 | Style/FileName: 546 | Style/FlipFlop: 547 | Style/For: 548 | Style/FormatStringToken: 549 | Style/GlobalVars: 550 | Style/GuardClause: 551 | Style/IdenticalConditionalBranches: 552 | Style/IfInsideElse: 553 | Style/IfUnlessModifierOfIfUnless: 554 | Style/IfWithSemicolon: 555 | Style/MethodCalledOnDoEndBlock: 556 | Style/MethodMissing: 557 | Style/MethodName: 558 | Style/ModuleFunction: 559 | Style/MultilineBlockChain: 560 | Style/MultilineIfModifier: 561 | Style/MultilineTernaryOperator: 562 | Style/MultipleComparison: 563 | Style/NestedTernaryOperator: 564 | Style/NumericPredicate: 565 | Style/OpMethod: 566 | Style/OptionalArguments: 567 | Style/PredicateName: 568 | Style/SelfAssignment: 569 | Style/StructInheritance: 570 | Style/VariableName: 571 | Style/VariableNumber: 572 | 573 | # Uses rubocop default cops 574 | hardcore: 575 | configs: *default_configs 576 | enabled_cops: all 577 | Gemfile: 578 | required: 579 | ':release': 580 | - gem: voxpupuli-release 581 | require: false 582 | git: 'https://github.com/voxpupuli/voxpupuli-release-gem' 583 | - gem: github_changelog_generator 584 | git: https://github.com/voxpupuli/github-changelog-generator 585 | branch: voxpupuli_essential_fixes 586 | ':test': 587 | - gem: 'puppet-lint-absolute_classname-check' 588 | version: '>= 2.0.0' 589 | - gem: 'puppet-lint-anchor-check' 590 | - gem: 'puppet-lint-classes_and_types_beginning_with_digits-check' 591 | - gem: 'puppet-lint-leading_zero-check' 592 | - gem: 'puppet-lint-legacy_facts-check' 593 | - gem: 'puppet-lint-topscope-variable-check' 594 | - gem: 'puppet-lint-trailing_comma-check' 595 | - gem: 'puppet-lint-unquoted_string-check' 596 | - gem: 'puppet-lint-variable_contains_upcase' 597 | - gem: 'puppet-lint-version_comparison-check' 598 | - gem: 'puppet-lint-resource_reference_syntax' 599 | - gem: coveralls 600 | ':system_tests': 601 | - gem: voxpupuli-acceptance 602 | ':development': 603 | - gem: travis 604 | - gem: travis-lint 605 | - gem: guard-rake 606 | - gem: overcommit 607 | version: '>= 0.39.1' 608 | - gem: fast_gettext 609 | version: '1.1.0' 610 | condition: "Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')" 611 | - gem: fast_gettext 612 | condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')" 613 | # json_pure 2.0.2 added a requirement on ruby >= 2. We pin to 614 | # json_pure <= 2.0.1 if using ruby 1.x 615 | - gem: json_pure 616 | version: '<= 2.0.1' 617 | condition: "Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')" 618 | # hardcode JSON version to what's shipped in pdk for now 619 | - gem: json 620 | version: '= 1.8.1' 621 | condition: "Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')" 622 | - gem: json 623 | version: '= 2.0.4' 624 | condition: "Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))" 625 | - gem: json 626 | version: '= 2.1.0' 627 | condition: "Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))" 628 | - gem: 'rb-readline' 629 | version: '= 0.5.5' 630 | platforms: 631 | - mswin 632 | - mingw 633 | - x64_mingw 634 | - gem: 'puppet-module-posix-default-r#{minor_version}' 635 | version: '~> 0.4' 636 | platforms: ruby 637 | - gem: 'puppet-module-posix-dev-r#{minor_version}' 638 | version: '~> 0.4' 639 | platforms: ruby 640 | - gem: 'puppet-module-win-default-r#{minor_version}' 641 | version: '~> 0.4' 642 | platforms: 643 | - mswin 644 | - mingw 645 | - x64_mingw 646 | - gem: 'puppet-module-win-dev-r#{minor_version}' 647 | version: '~> 0.4' 648 | platforms: 649 | - mswin 650 | - mingw 651 | - x64_mingw 652 | .gitlab-ci.yml: 653 | delete: true 654 | defaults: 655 | cache: 656 | paths: 657 | - 'vendor/bundle' 658 | bundler_args: '--without system_tests --path vendor/bundle --jobs $(nproc)' 659 | ruby_versions: 660 | '2.5.8': 661 | checks: 662 | - 'syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop' 663 | - parallel_spec 664 | puppet_version: '~> 6' 665 | '2.4.9': 666 | checks: 667 | - parallel_spec 668 | puppet_version: '~> 5' 669 | # beaker: true 670 | default_before_script: true 671 | spec/default_facts.yml: 672 | delete: false 673 | spec/classes/coverage_spec.rb: 674 | delete: true 675 | spec/spec_helper.rb: 676 | coverage_report: false 677 | minimum_code_coverage_percentage: 0 678 | strict_level: ":warning" 679 | strict_variables: true 680 | mock_with: false 681 | spec/spec_helper_acceptance.rb: 682 | unmanaged: true 683 | spec/acceptance/nodesets/centos-511-x64.yml: 684 | delete: true 685 | spec/acceptance/nodesets/centos-6-x64.yml: 686 | delete: true 687 | spec/acceptance/nodesets/centos-66-x64.yml: 688 | delete: true 689 | spec/acceptance/nodesets/centos-66-x64-pe.yml: 690 | delete: true 691 | spec/acceptance/nodesets/centos-7-x64.yml: 692 | delete: true 693 | spec/acceptance/nodesets/centos-72-x64.yml: 694 | delete: true 695 | spec/acceptance/nodesets/debian-78-x64.yml: 696 | delete: true 697 | spec/acceptance/nodesets/debian-82-x64.yml: 698 | delete: true 699 | spec/acceptance/nodesets/fedora-20-x64.yml: 700 | delete: true 701 | spec/acceptance/nodesets/fedora-24-x64.yml: 702 | delete: true 703 | spec/acceptance/nodesets/fedora-25-x64.yml: 704 | delete: true 705 | spec/acceptance/nodesets/fedora-26-x64.yml: 706 | delete: true 707 | spec/acceptance/nodesets/fedora-27-x64.yml: 708 | delete: true 709 | spec/acceptance/nodesets/ubuntu-server-1204-x64.yml: 710 | delete: true 711 | spec/acceptance/nodesets/ubuntu-server-1404-x64.yml: 712 | delete: true 713 | spec/acceptance/nodesets/ubuntu-server-1604-x64.yml: 714 | delete: true 715 | spec/acceptance/nodesets/windows-2008R2-serverstandard-x64.yml: 716 | delete: true 717 | spec/acceptance/nodesets/windows-2012-serverstandard-x64.yml: 718 | delete: true 719 | spec/acceptance/nodesets/windows-2012R2-serverstandard-x64.yml: 720 | delete: true 721 | CONTRIBUTING.md: 722 | delete: true 723 | # vim: syntax=yaml 724 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PDK Templates 2 | 3 | The PDK Templates is the default templates repository for use with the [Puppet Development Kit](https://github.com/puppetlabs/pdk), within which we have defined all the templates for the creation and configuration of a module. Look into these directories to find the templates: 4 | 5 | * `moduleroot` templates get deployed on `new module`, `convert` and `update`; use them to enforce a common boilerplate for central files. 6 | * `moduleroot_init` templates get only deployed when the target module does not yet exist; use them to provide skeletons for files the developer needs to modify heavily. 7 | * `object_templates` templates are used by the various `new ...` commands for classes, defined types, etc. 8 | 9 | PDK builds the configuration of the module by reading a set of default configuration from `config_defaults.yml` and merging it with the contents of `.sync.yml` from module's root directory, if exists. Top-level keys of the resulting hash correspond to target files or represent a global configuration. Global configuration will be merged with the configuration hash for a particular target file. This allows a module developer to override/amend the configuration by putting new values into `.sync.yml`. A knockout prefix may be applied to elements within `.sync.yml` to [remove elements from the default set](#removing-default-configuration-values). Target files are created by rendering a corresponding template which is referring its configuration via the `@configs` hash. The data for a target file may include `delete: true` or `unmanaged: true` in order to have the particular file removed from the module or left unmanaged, respectively. 10 | 11 | * [Basic usage](#basic-usage) 12 | * [Values of config\_defaults](#values) 13 | * [Making local changes to the Template](#making-local-changes-to-the-template) 14 | * [Further Notes](#notes) 15 | 16 | ## Basic Usage 17 | 18 | Templates like this one can be used in conjunction with the PDK. As default the PDK itself uses the templates within this repository to render files for use within a module. Templates can be passed to the PDK as a flag for several of the commands. 19 | 20 | > pdk convert --template-url https://github.com/puppetlabs/pdk-templates 21 | 22 | Please note that the template only needs to be passed in once if you wish to change it, every command run on the PDK will use the last specified template. 23 | For more on basic usage and more detailed description of the PDK in action please refer to the [PDK documentation](https://github.com/puppetlabs/pdk/blob/master/README.md). 24 | 25 | ## Values of config\_defaults 26 | 27 | The following is a description and explaination of each of the keys within config\_defaults. This will help clarify the default settings we choose to apply to pdk modules. 28 | 29 | ### common 30 | 31 | > A namespace for settings that affect multiple templates 32 | 33 | | Key | Description | 34 | |:-----------------------|:------------| 35 | | disable\_legacy\_facts | Set to `true` to configure PDK to prevent the use of [legacy Facter facts][legacy_facts_doc]. Currently this will install and enable the [legacy\_facts][legacy_facts_pl_plugin] plugin for puppet-lint for use during `pdk validate`. | 36 | 37 | 38 | ### .gitattributes 39 | 40 | >A .gitattributes file in your repo allows you to ensure consistent git settings. 41 | 42 | | Key | Description | 43 | | :-----------------|:--------------| 44 | | include | Defines which extensions are handled by git automatic conversions (see the [gitattributes](https://git-scm.com/docs/gitattributes) documentation). The default configuration helps to keep line endings consistent between windows and linux users.| 45 | 46 | ### .gitignore 47 | 48 | >A .gitignore file in your repo allows you to specify intentionally untracked files to ignore. 49 | 50 | | Key | Description | 51 | | :-----------------|:--------------| 52 | | required | The default list of files or paths for git to ignore or untrack that are commonly specified in a module project. 53 | | paths | Defines any additional files or paths for git to ignore or untrack. (see the [gitignore](https://git-scm.com/docs/gitignore) documentation). 54 | 55 | ### .gitlab-ci.yml 56 | 57 | >[Gitlab CI](https://about.gitlab.com/features/gitlab-ci-cd/) is a continuous integration platform that is free for all open source projects hosted on Github and Gitlab.com, it also has a self-hosted option that is free as well. We can trigger automated pipelines with ever change to our code base in the master branch, other branches, tags, or additional triggers. 58 | Gitlab CI uses a .gitlab-ci.yml file in the root of your repository tell Gitlab CI what jobs to run when in the pipeline. 59 | 60 | Key | Description | 61 | | :------------- |:--------------| 62 | | override |Defines whether your local `.sync.yml` will ignore the default values in pdk-templates. Defaults to `false`| 63 | | defaults/custom | The `defaults` and `custom` keys are special keys used to denote when configuration is coming from `config_defaults.yml` or `.sync.yml`. While it is possible for users to extend the defaults provided by PDK, it's suggested that the user should only use the `custom` key to separate their overrides/extended configuration from the PDK provided defaults. | 64 | | custom_stages |Defines a custom job stage for when the CI/CD jobs will be executed in the pipeline. By default `syntax` and `unit` are defined unless `override: true`.| 65 | | beaker |Defines if you want the default, Docker-in-Docker acceptance job added. Can be set to `true` to enable the default `acceptance` job, or you can specify the `variables` and `tags` subkeys. These subkeys function the same as the `global_variables` option and the `tags` subkey found in the `ruby_versions` option.| 66 | | global_variables |Allows you to set any global environment variables for the gitlab-ci pipeline. Currently includes setting the Puppet gem version.| 67 | | cache | If this setting exists, it expects a single sub-key called `paths`. `paths` is an array of paths that will be cached for each subsequent job. Defaults to `['vendor/bundle']`| 68 | | bundler\_args |Define any arguments you want to pass through to bundler. The default is `--without system_tests --path vendor/bundle --jobs $(nproc)` which avoids installing unnessesary gems while installing them to the `vendor/bundler.| 69 | | ruby_versions |Define a list of ruby_versions to test against. Each version can have a series of sub-keys that are options. `checks` is the rake command(s) to run during the job. `puppet_version` sets the PUPPET_GEM_VERSION environment variable. `allow_failure` is an array of `checks` where you want to allow failures. `tags` is an array of Gitlab CI Runner tags. | 70 | | ruby_versions\\{job}\\**except/only**|Basic `except`/`only` is an hash of `checks` with array of references of conditions for the `checks`:

ruby_versions:
  2.4.9:
    except:
      unit:
      - tags
      - master


Advanced `except`/`only` is an hash of `checks` with hash using 4 keywords `'variables', 'refs', 'changes', 'kubernetes'` each with it's own array of references or conditions for the `checks`:

ruby_versions:
  2.4.9:
    except:
      unit:
        refs:
        - tags
        - master
        variables:
        - $CI_COMMIT_MESSAGE =~ /\[skip[ _-]tests?\]/i
https://docs.gitlab.com/ce/ci/yaml/README.html#onlyexcept-advanced | 71 | | custom_jobs |Define custom Gitlab CI jobs that will be executed. It is recommended that you use this option if you need customized Gitlab CI jobs. Please see the [.gitlab-ci.yml](https://docs.gitlab.com/ce/ci/yaml/README.html) docs for specifics.| 72 | | rubygems_mirror | Use a custom rubygems mirror url | 73 | | image |Define the Docker image to use, when using the Docker runner. Please see the [Using Docker images](https://docs.gitlab.com/ee/ci/docker/using_docker_images.html) docs for specifics.| 74 | | custom_before_steps |Allows you to pass additional steps to the GitLab CI before_script. Please see the [.gitlab-ci.yml](https://docs.gitlab.com/ce/ci/yaml/#before_script-and-after_script) docs for specifics.| 75 | | default_before_script |If false, removes the default `before_script` section. Useful if you need a customised Bundler install, or to remove Bundler entirely. If the key is unset the default behaviour is to add `before_script`.| 76 | 77 | ### .pdkignore 78 | 79 | >A .pdkignore file in your repo allows you to specify files to ignore when building a module package with `pdk build`. 80 | 81 | | Key | Description | 82 | | :-----------------|:--------------| 83 | | required | The default list of files or paths for PDK to ignore when building a module package. 84 | | paths | Defines additional files or paths for PDK to ignore when building a module package. 85 | 86 | ### .travis.yml 87 | 88 | >[Travis CI](https://travis-ci.org/) is a hosted continuous integration platform that is free for all open source projects hosted on Github. 89 | We can trigger automated builds with every change to our code base in the master branch, other branches or even a pull request. 90 | Travis uses a .travis.yml file in the root of your repository to learn about your project and how you want your builds to be executed. 91 | 92 | | Key | Description | 93 | | :------------- |:--------------| 94 | | os | Set to an array of operating systems to test. See the [TravisCI documentation](https://docs.travis-ci.com/user/multi-os/) for more details. | 95 | | dist | If specified, it will set the dist attribute. See the [TravisCI documentation](https://docs.travis-ci.com/user/reference/overview/#virtualisation-environment-vs-operating-system) for more details. | 96 | | simplecov |Set to `true` to enable collecting ruby code coverage.| 97 | | ruby\_versions |Define the ruby versions on which you want your builds to be executed.| 98 | | bundler\_args |Define any arguments you want to pass through to bundler. The default is `--without system_tests` which avoids installing unnessesary gems.| 99 | | env |Allows you to add new travis job matrix entries based on the included environmnet variables, one per `env` entry; for example, for adding jobs with specific `PUPPET_GEM_VERSION` and/or `CHECK` values. See the [Travis Environment Variables](https://docs.travis-ci.com/user/environment-variables) documentation for details.| 100 | | global\_env |Allows you to set global environment variables which will be defined for all travis jobs; for example, `PARALLEL_TEST_PROCESSORS` or `TIMEOUT`. See the [Travis Global Environment Variables](https://docs.travis-ci.com/user/environment-variables/#Global-Variables) documentation for details.| 101 | |docker\_sets |Allows you to configure sets of docker to run your tests on. For example, if I wanted to run on a docker instance of Ubuntu I would add `set:docker/ubuntu-14.04` to my docker\_sets attribute. The docker_sets is a hash that supports the 'set', 'testmode', and 'collection' keys. | 102 | |docker\_sets['set']| This should refrence the docker nodeset that you wish to run. | 103 | |docker\_sets['testmode']| This configures the `BEAKER_TESTMODE` to use when testing the docker instance. The two options are `apply` and `agent` if omitted `apply` is used by default. | 104 | |docker_sets['collection]| This configures the `BEAKER_PUPPET_COLLECTION` to use when testing the docker instance. The default is `puppet6`. 105 | |docker_defaults |Defines what values are used as default when using the `docker_sets` definition. Includes ruby version, sudo being enabled, the distro, the services, the env variables and the script to execute.| 106 | |stages |Allows the specification of order and conditions for travis-ci build stages. See [Specifying Stage Order and Conditions](https://docs.travis-ci.com/user/build-stages/#specifying-stage-order-and-conditions).| 107 | |before_install_pre |Add install steps to the start of `before_install`. | 108 | |before_install_post |Add install steps to the end of `before_install`. | 109 | |includes |Ensures that the .travis file includes the following checks by default: Rubocop, Puppet Lint, Metadata Lint.| 110 | |remove_includes |Allows you to remove includes set in `config_defaults.yml`.| 111 | |branches |Allows you to specify the only branches that travis will run builds on. The default branches are `master` and `/^v\d/`. | 112 | |branches_except |Allows you to specify branches that travis will not build on.| 113 | |remove_branches |Allows you to remove default branches set in config_defaults.yml.| 114 | |notifications |Allows you to specify the notifications configuration in the .travis.yml file.| 115 | |remove_notifications |Allows you to remove default branches set in config_defaults.yml.| 116 | |deploy_to_forge|Allows you to change the automatic deployment of modules to the forge. Sub keys are `enabled` and `tag_regex` which are detailed below| 117 | |deploy_to_forge\\**enabled**|Allows you to enable or disable automatic forge deployments. Default is true| 118 | |deploy_to_forge\\**tag_regex**|Allows you to use a regular expression to define which tags will trigger a deployment. The default is `^v\d`| 119 | |before_deploy|An array which can allow a user to specify the commands to run before kicking off a deployment. See [https://docs.travis-ci.com/user/deployment/releases/#setting-the-tag-at-deployment-time].| 120 | |use_litmus| By default it is disabled. Set to `true` to configure travis to use Litmus testing tool for acceptance testing jobs with default values.| 121 | |litmus|Allows you to update default config values. Its sub keys are `provision_list`, `puppet_collection`, `rvm`, `install_wget` which are detailed below.| 122 | |litmus\\**puppet_collection**|Allows you to specify the puppet version under test. Default test are ran on _puppet 5_ and _puppet 6_.| 123 | |litmus\\**provision_list**|Allows you to specify the platforms list under test. Default test are ran on platformes defined in provision.yaml file under _travis_deb_ and _travis_el_| 124 | |litmus\\**rvm**|Allows you to specify the ruby version under test. Default it is set to _2.5.7_| 125 | |litmus\\**install_wget**|Allows you to enable automatic installation of wget on the platform under test. We need this when installing agent on travis_deb platforms. Default it is disabled. | 126 | |user|This string needs to be set to the Puppet Forge user name. To enable deployment the secure key also needs to be set.| 127 | |secure|This string needs to be set to the encrypted password to enable deployment. See [https://docs.travis-ci.com/user/encryption-keys/#usage](https://docs.travis-ci.com/user/encryption-keys/#usage) for instructions on how to encrypt your password.| 128 | 129 | ### .yardopts 130 | 131 | >[YARD](https://yardoc.org/) is a documentation generation tool for the Ruby programming language. It enables the user to generate consistent, usable documentation that can be exported to a number of formats very easily, and also supports extending for custom Ruby constructs such as custom class level definitions. 132 | 133 | | Key | Description | 134 | | :------------- |:--------------| 135 | | markup |Specifies the markup formatting of your documentation. Default is `markdown`.| 136 | | optional |Define any additional arguments you want to pass through to the `yardoc` command.| 137 | 138 | ### appveyor.yml 139 | 140 | >[AppVeyor](https://www.appveyor.com/) is a hosted, distributed continuous integration service used to build and test projects hosted on GitHub by spinning up a Microsoft Windows virtual machine. AppVeyor is configured by adding a file named appveyor.yml, which is a YAML format text file, to the root directory of the code repository. 141 | 142 | | Key | Description | 143 | | :------------- |:--------------| 144 | |appveyor\_bundle\_install|Defines the bundle install command for the appveyor execution run. In our case we use bundle install `--without system_tests` as default, therefore avoiding redundant gem installation.| 145 | |install_pre |Add install steps to the start of `install`. | 146 | |install_post |Add install steps to the end of `install`. | 147 | |environment|Defines any environment variables wanted for the job run. In our case we default to the latest Puppet 4 gem version.| 148 | |matrix|This defines the matrix of jobs to be executed at runtime. Each defines environment variables for that specific job run. In our defaults we have a Ruby version specfied, followed by the check that will be run for that job.| 149 | |simplecov|Set to `true` to enable collecting ruby code coverage.| 150 | |test\_script|This defines the test script that will be executed. For our purposes the default is set to `bundle exec rake %CHECK%`. As appveyor iterates through the test matrix as we defined above, it resolves the variable CHECK and runs the resulting command. For example, our last test script would be executed as `bundle exec rake spec`, which would run the spec tests of the module.| 151 | |use_litmus|Configures Appveyor to be able to use Litmus for acceptance testing jobs| 152 | 153 | ### Rakefile 154 | 155 | >[Rake](https://github.com/ruby/rake) is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax within the Rakefile, present in the root directory of the code repository. Within modules context Rake tasks are used quite frequently, from ensuring the integrity of a module, running validation and tests, to tasks for releasing modules. 156 | 157 | | Key | Description | 158 | | :------------- |:--------------| 159 | |requires|A list of hashes with the library to `'require'`, and an optional `'conditional'`.| 160 | |changelog\_user|Sets the github user for the change_log_generator rake task. Optional, if not set it will read the `author` from the `metadata.json` file.| 161 | |changelog\_project|Sets the github project name for the change\_log\_generator rake task. Optional, if not set it will parse the `source` from the `metadata.json` file| 162 | |changelog\_since\_tag|Sets the github since_tag for the change\_log\_generator rake task. Required for the changlog rake task.| 163 | |changelog\_version\_tag\_pattern|Template how the version tag is to be generated. Defaults to `'v%s'` which eventually align with tag\_pattern property of puppet-blacksmith, thus changelog is referring to the correct version tags and compare URLs. | 164 | |github_site|Override built-in default for public GitHub. Useful for GitHub Enterprise and other. (Example: `github_site = https://git.domain.tld`) | 165 | |github_endpoint|Override built-in default for public GitHub. Useful for GitHub Enterprise and other. (Example: `github_endpoint = https://git.domain.tld/api/v4`) | 166 | |gitlab|Allows to work with GitLab (Pending ![GitLab support](https://github.com/github-changelog-generator/github-changelog-generator/pull/657)). (Example: `gitlab = true` # Boolean default is false)| 167 | |default\_disabled\_lint\_checks| Defines any checks that are to be disabled by default when running lint checks. As default we disable the `--relative` lint check, which compares the module layout relative to the module root. _Does affect **.puppet-lint.rc**._ | 168 | |extra\_disabled\_lint\_checks| Defines any checks that are to be disabled as extras when running lint checks. No defaults are defined for this configuration. _Does affect **.puppet-lint.rc**._ | 169 | |extras|An array of extra lines to add into your Rakefile. As an alternative you can add a directory named `rakelib` to your module and files in that directory that end in `.rake` would be loaded by the Rakefile.| 170 | |linter\_options| An array of options to be passed into linter config. _Does affect **.puppet-lint.rc**._ | 171 | |linter\_fail\_on\_warnings| A boolean indicating if the linter should exit non-zero on warnings as well as failures. _Does affect **.puppet-lint.rc**._ | 172 | 173 | ### .rubocop.yml 174 | 175 | >[RuboCop](https://github.com/bbatsov/rubocop) is a Ruby static code analyzer. We use Rubocop to enforce a level of quility and consistancy within Ruby code. Rubocop can be configured within .rubocop.yml which is located in the root directory of the code repository. Rubocop works by defining a sanitized list of cops that'll cleanup a code base without much effort, all of which support autocorrect and that are fairly uncontroversial across wide segments of the Community. 176 | 177 | | Key | Description | 178 | | :------------- |:--------------| 179 | |include\_todos|Allows you to use rubocop's "TODOs" to temporarily skip checks by setting this to `true`. See rubocop's `--auto-gen-config` option for details. Defaults to `false`.| 180 | |selected\_profile|Allows you to define which profile is used by default, which is set to `strict`, which is fully defined within the `profiles` section.| 181 | |default\_configs |Allows you to define the default configuration of which cops will run. Includes the full name of the cop followed by a description of it and an enforced style. Can also make use of the key `excludes` to exclude any files from that specific cop.| 182 | |cleanup\_cops |Defines a set of cleanup cops to then be included within a rubocop profile. Cops are defined by their full name, and further configuration can be done by specifying secondary keys. By default we specify a large amount of cleanup cops using their default configuration.| 183 | |profiles |Defines the profiles that can be enabled and used within rubocop through the `selected_profile` option. By default we have set up three profiles: cleanups\_only, strict, hardcore and off.| 184 | 185 | ### Gemfile 186 | 187 | >A Gemfile is a file we create which is used for describing gem dependencies for Ruby programs. All modules should have an associated Gemfile for installing the relevant gems. As development and testing is somewhat consistant between modules we have used the template to define a set of gems relevant to these processes. 188 | 189 | | Key | Description | 190 | | :------------- |:--------------| 191 | |required|Allows you to specify gems that are required within the Gemfile. Gems can be defined here within groups, for example we use the :development gem group to add in several gems that are relevant to the development of any module and the :system_tests gem group for gems relevant only to acceptance testing.| 192 | |optional|Allows you to specify additional gems that are required within the Gemfile. This key can be used to further configure the Gemfile through assignment of a value in the .sync.yml file.| 193 | 194 | >Within each Gem group defined using the options above one or more gem item definitions may be listed in an array. Each item in that array must be a gem item hash. 195 | 196 | | Gem Item Hash Keys | Description | 197 | | :----------------- |:-------------| 198 | |gem|Required option specifying the gem name.| 199 | |version|Required option to specify version or range of versions required using [RubyGem version syntax](https://guides.rubygems.org/patterns/#pessimistic-version-constraint).| 200 | |platforms|Defines an array of platforms for which the Gem should be included. See the [Gemfile platform guide](https://bundler.io/man/gemfile.5.html#PLATFORMS) for a list of valid platforms.| 201 | |git|If required, specify a specific Git repository in which this Gem is located. See the [Bundler docs](https://bundler.io/man/gemfile.5.html#GIT) for details.| 202 | |branch|Optionally specify a branch to use if using the `git` option. Defaults to `master`.| 203 | |ref|Optionally specify an arbitrary valid Git reference to use for the module version.| 204 | |source|Specify an alternate Rubygems repository to load the gem from.| 205 | |from_env|Specifies an environment variable containing either a Rubygem version specification indicating the version to use OR a URL indicating the location from which to load the gem.| 206 | |condition|An optional string containing a Ruby-code conditional controlling if this gem will be processed in the Gemfile.| 207 | 208 | ### spec/default_facts.yml 209 | 210 | > The spec/default_facts.yml file contains a list of facts to be used by default when running rspec tests 211 | 212 | | Key | Description | 213 | | :------------- |:--------------| 214 | |concat_basedir|Overrides the concat_basedir fact's value in the base template. Defaults to "/tmp".| 215 | |ipaddress|Overrides the ipaddress fact's value in the base template. Defaults to "172.16.254.254".| 216 | |is_pe|Overrides the is_pe fact's value in the base template. Defaults to false. 217 | |macaddress|Overrides the macaddress fact's value in the base template. Defaults to "AA:AA:AA:AA:AA:AA". 218 | |extra_facts|List of extra facts to be added to the default_facts.yml file. They are in the form: "`name of fact`: `value of fact`"| 219 | 220 | ### spec/spec_helper.rb 221 | 222 | > The spec/spec_helper.rb file contains setup for rspec tests 223 | 224 | | Key | Description | 225 | | :------------- |:--------------| 226 | |default_facter_version|Sets the [`default_facter_version`](https://github.com/mcanevet/rspec-puppet-facts#specifying-a-default-facter-version) rspec-puppet-facts parameter.| 227 | |hiera_config|Sets the [`hiera_config`](http://rspec-puppet.com/documentation/configuration/#hiera_config) rspec-puppet parameter.| 228 | |hiera_config_ruby|Sets the [`hiera_config`](http://rspec-puppet.com/documentation/configuration/#hiera_config) rspec-puppet parameter. A ruby expression returning the path to your hiera.yaml file. `hiera_config` takes precedence if both values `hiera_config` and `hiera_config_ruby` are specified. | 229 | |mock_with|Defaults to `':mocha'`. Recommended to be set to `':rspec'`, which uses RSpec's built-in mocking library, instead of a third-party one.| 230 | |spec_overrides|An array of extra lines to add into your `spec_helper.rb`. Can be used as an alternative to `spec_helper_local`| 231 | |strict_level| Defines the [Puppet Strict configuration parameter](https://puppet.com/docs/puppet/5.4/configuration.html#strict). Defaults to `:warning`. Other values are: `:error` and `:off`. `:error` provides strictest level checking and is encouraged.| 232 | |strict_variables| Defines the [Puppet Strict Variables configuration parameter](https://puppet.com/docs/puppet/5.4/configuration.html#strict_variables). Defaults to `true` however due to `puppetlabs_spec_helper` forced override (https://github.com/puppetlabs/puppetlabs_spec_helper/blob/070ecb79a63cb8fa10f46532c413c055e2697682/lib/puppetlabs_spec_helper/module_spec_helper.rb#L71). Set to `false` to align with true default or with `STRICT_VARIABLES=no` environment setting.| 233 | |coverage_report|Enable [rspec-puppet coverage reports](https://rspec-puppet.com/documentation/coverage/). Defaults to `false`| 234 | |minimum_code_coverage_percentage|The desired code coverage percentage required for tests to pass. Defaults to `0`| 235 | 236 | ## Making local changes to the template 237 | 238 | > While we provide a basic template it is likely that it will not match what you need exactly, as such we allow it to be altered or added to through the use of the `.sync.yml` file. 239 | 240 | ### Adding configuration values 241 | 242 | Values can be added to the data passed to the templates by adding them to your local `.sync.yml` file, thus allowing you to make changes such as testing against additional operating systems or adding new rubocop rules. 243 | 244 | To add a value to an array simply place it into the `.sync.yml` file as shown below, here I am adding an additional unit test run against Puppet 4: 245 | 246 | ```yaml 247 | .travis.yml: 248 | includes: 249 | - env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec 250 | rvm: 2.1.9 251 | ``` 252 | 253 | ### Removing default configuration values 254 | 255 | Values can be removed from the data passed to the templates using the [knockout prefix](https://www.rubydoc.info/gems/puppet/DeepMerge) `---` in `.sync.yml`. 256 | 257 | To remove a value from an array, prefix the value `---`. For example, to remove 258 | `2.5.1` from the `ruby_versions` array in `.travis.yml`: 259 | 260 | ```yaml 261 | .travis.yml: 262 | ruby_versions: 263 | - '---2.5.1' 264 | ``` 265 | 266 | To remove a key from a hash, set the value to `---`. For example, to remove the 267 | `ipaddress` fact from `spec/default_facts.yml`: 268 | 269 | ```yaml 270 | spec/default_facts.yml: 271 | ipaddress: '---' 272 | ``` 273 | 274 | ## Setting custom gems in the Gemfile 275 | 276 | To add a custom internal `puppet-lint` plugin served from an internal Rubygems source, add 277 | an entry similar to the following in `.sync.yml` file and run `pdk update`. 278 | 279 | ```yaml 280 | Gemfile: 281 | optional: 282 | ':development': 283 | - gem: 'puppet-lint-my_awesome_custom_module' 284 | version: '>= 2.0' 285 | source: 'https://myrubygems.example.com/' 286 | ``` 287 | 288 | ## Enabling Beaker system tests 289 | 290 | To enable the ability to run Beaker system tests on your module, add the 291 | following entry to your `.sync.yml` and run `pdk update`. 292 | 293 | ```yaml 294 | Gemfile: 295 | required: 296 | ':system_tests': 297 | - gem: 'puppet-module-posix-system-r#{minor_version}' 298 | platforms: ruby 299 | - gem: 'puppet-module-win-system-r#{minor_version}' 300 | platforms: 301 | - mswin 302 | - mingw 303 | - x64_mingw 304 | .gitlab-ci.yml: 305 | bundler_args: --with system_tests --path vendor/bundle --jobs $(nproc) 306 | beaker: true 307 | appveyor.yml: 308 | appveyor_bundle_install: "bundle install --jobs 4 --retry 2 --with system_tests" 309 | ``` 310 | 311 | ## Further Notes 312 | 313 | Please note that the early version of this template contained only a 'moduleroot' directory, and did not have a 'moduleroot\_init'. The PDK 'pdk new module' command will still work with templates that only have 'moduleroot', however the 'pdk convert' command will fail if the template does not have a 'moduleroot_init' directory present. To remedy this please use the up to date version of the template. 314 | 315 | [legacy_facts_doc]: https://puppet.com/docs/facter/latest/core_facts.html#legacy-facts 316 | [legacy_facts_pl_plugin]: https://github.com/mmckinst/puppet-lint-legacy_facts-check 317 | --------------------------------------------------------------------------------