├── .github ├── dependabot.yml └── workflows │ ├── build-test-push.yml │ ├── build-test.yml │ ├── mend.yml │ └── publish-4x-image.yml ├── .gitignore ├── CODEOWNERS ├── Dockerfile ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── build-rootless.sh ├── build.sh ├── pdk_1_18_1_dependencies ├── .rubocop.yml ├── Gemfile └── metadata.json ├── tests ├── control-repo │ ├── badsyntax │ │ ├── Puppetfile │ │ ├── data │ │ │ └── common.yaml │ │ └── site │ │ │ └── profile │ │ │ ├── manifests │ │ │ └── common.pp │ │ │ └── templates │ │ │ └── bad_template.epp │ └── goodsyntax │ │ ├── Puppetfile │ │ ├── data │ │ └── common.yaml │ │ ├── environment.conf │ │ ├── hiera.yaml │ │ ├── manifests │ │ └── site.pp │ │ ├── metadata.json │ │ └── site │ │ └── profile │ │ ├── manifests │ │ └── common.pp │ │ └── templates │ │ └── good_template.epp ├── module │ └── test │ │ ├── .devcontainer │ │ ├── Dockerfile │ │ └── devcontainer.json │ │ ├── .fixtures.yml │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .gitlab-ci.yml │ │ ├── .pdkignore │ │ ├── .puppet-lint.rc │ │ ├── .rspec │ │ ├── .rubocop.yml │ │ ├── .sync.yml │ │ ├── .travis.yml │ │ ├── .vscode │ │ └── extensions.json │ │ ├── .yardopts │ │ ├── CHANGELOG.md │ │ ├── Gemfile │ │ ├── README.md │ │ ├── Rakefile │ │ ├── appveyor.yml │ │ ├── data │ │ └── common.yaml │ │ ├── hiera.yaml │ │ ├── manifests │ │ └── defer.pp │ │ ├── metadata.json │ │ └── spec │ │ ├── classes │ │ └── defer_spec.rb │ │ ├── default_facts.yml │ │ └── spec_helper.rb └── run_tests.sh └── update_readme.sh /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "13:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.github/workflows/build-test-push.yml: -------------------------------------------------------------------------------- 1 | name: Build-Test-Push 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | tag: 7 | description: Optional tag to create in addition to the `latest` and `-` image tags. 8 | required: false 9 | push: 10 | branches: 11 | - main 12 | 13 | jobs: 14 | Build-Test-Push: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v1 18 | - name: Build rootless image 19 | run: ./build-rootless.sh $(echo $GITHUB_REPOSITORY |cut -d '/' -f1) 20 | - name: Build standard image 21 | run: ./build.sh $(echo $GITHUB_REPOSITORY |cut -d '/' -f1) 22 | - name: Trivy scan 23 | uses: aquasecurity/trivy-action@master 24 | with: 25 | image-ref: puppet-dev-tools:latest 26 | exit-code: 1 27 | ignore-unfixed: true 28 | severity: 'CRITICAL,HIGH,MEDIUM' 29 | vuln-type: os 30 | timeout: 10m0s 31 | skip-files: "/root/.pdk/cache/ruby/*/gems/aws-sdk-core-*/lib/aws-sdk-ssooidc/client.rb" 32 | - name: Run tests 33 | run: cd tests; ./run_tests.sh 34 | - name: Tag Docker images 35 | run: | 36 | docker tag puppet-dev-tools:latest-rootless ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD)-rootless 37 | docker tag puppet-dev-tools:latest ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD) 38 | - name: Additional Tag 39 | if: inputs.tag 40 | run: | 41 | docker tag puppet-dev-tools:latest-rootless ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }}-rootless 42 | docker tag puppet-dev-tools:latest ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }} 43 | - name: List Docker images 44 | run: docker images --filter "reference=puppet-dev-tools*" --filter "reference=*/puppet-dev-tools*" 45 | - name: Show Docker image labels 46 | run: | 47 | docker inspect --format='{{json .Config.Labels}}' ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD) 48 | - name: Login to Docker Hub 49 | run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_LOGIN_USERNAME }} --password-stdin 50 | - name: Push Docker images 51 | run: | 52 | docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD)-rootless 53 | docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:$(date +"%F")-$(git rev-parse --short HEAD) 54 | - name: Push Additional Tag 55 | if: inputs.tag 56 | run: | 57 | docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }}-rootless 58 | docker push ${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools:${{ inputs.tag }} 59 | -------------------------------------------------------------------------------- /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: Build-Test 2 | 3 | on: 4 | pull_request: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | Build-Test: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Build rootless image 13 | run: ./build-rootless.sh $(echo $GITHUB_REPOSITORY |cut -d '/' -f1) 14 | - name: Build standard image 15 | run: ./build.sh $(echo $GITHUB_REPOSITORY |cut -d '/' -f1) 16 | - name: List Docker images 17 | run: docker images --filter "reference=puppet-dev-tools*" --filter "reference=*/puppet-dev-tools*" 18 | - name: Show Docker image labels 19 | run: | 20 | docker inspect --format='{{json .Config.Labels}}' ${{ secrets.DOCKERHUB_USERNAME }}/puppet-dev-tools 21 | - name: Trivy scan 22 | uses: aquasecurity/trivy-action@master 23 | with: 24 | image-ref: puppet-dev-tools:latest 25 | exit-code: 1 26 | ignore-unfixed: true 27 | severity: 'CRITICAL,HIGH,MEDIUM' 28 | vuln-type: os 29 | timeout: 10m0s 30 | skip-files: "/root/.pdk/cache/ruby/*/gems/aws-sdk-core-*/lib/aws-sdk-ssooidc/client.rb" 31 | - name: Run tests 32 | working-directory: ${{ github.workspace }}/tests 33 | run: ./run_tests.sh 34 | -------------------------------------------------------------------------------- /.github/workflows/mend.yml: -------------------------------------------------------------------------------- 1 | name: mend_scan 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - main 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: checkout repo content 12 | uses: actions/checkout@v2 # checkout the repository content to github runner. 13 | with: 14 | fetch-depth: 1 15 | - name: setup ruby 16 | uses: ruby/setup-ruby@v1 17 | with: 18 | ruby-version: 2.7 19 | - name: create lock 20 | run: bundle lock 21 | # install java 22 | - uses: actions/setup-java@v3 23 | with: 24 | distribution: 'temurin' # See 'Supported distributions' for available options 25 | java-version: '17' 26 | # download mend 27 | - name: download_mend 28 | run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar 29 | - name: run mend 30 | run: java -jar wss-unified-agent.jar 31 | env: 32 | WS_FILESYSTEMSCAN: true 33 | WS_CHECKPOLICIES: true 34 | WS_FORCEUPDATE: true 35 | WS_APIKEY: ${{ secrets.MEND_API_KEY }} 36 | WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent 37 | WS_USERKEY: ${{ secrets.MEND_TOKEN }} 38 | WS_PRODUCTNAME: CD4PE 39 | WS_PROJECTNAME: ${{ github.event.repository.name }} 40 | -------------------------------------------------------------------------------- /.github/workflows/publish-4x-image.yml: -------------------------------------------------------------------------------- 1 | name: "Publish images to 4.x and 4.x-rootless tags" 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | image_tag: 7 | description: Image tag on dockerhub to promote to the puppet-dev-tools 4.x image tag (ie. 2021-06-29-da6666a) 8 | required: true 9 | image_tag_rootless: 10 | description: Image tag on dockerhub to promote to the puppet-dev-tools 4.x-rootless image tag (ie. 2021-06-29-da6666a-rootless) 11 | required: true 12 | 13 | jobs: 14 | publish-4x-image: 15 | runs-on: ubuntu-latest 16 | env: 17 | IMAGE_BASE: "${{ secrets.DOCKERHUB_PUSH_USERNAME }}/puppet-dev-tools" 18 | steps: 19 | - name: Login to Docker Hub 20 | run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_LOGIN_USERNAME }} --password-stdin 21 | - name: Pull image 22 | env: 23 | IMAGE_TAG: ${{ github.event.inputs.image_tag }} 24 | run: | 25 | docker pull ${IMAGE_BASE}:${IMAGE_TAG} 26 | - name: Trivy scan 27 | uses: aquasecurity/trivy-action@master 28 | with: 29 | image-ref: ${{ env.IMAGE_BASE }}:${{ github.event.inputs.image_tag }} 30 | exit-code: 1 31 | ignore-unfixed: true 32 | severity: 'CRITICAL,HIGH,MEDIUM' 33 | vuln-type: os 34 | timeout: 10m0s 35 | skip-files: "/root/.pdk/cache/ruby/*/gems/aws-sdk-core-*/lib/aws-sdk-ssooidc/client.rb" 36 | - name: Publish standard image to 4.x 37 | env: 38 | IMAGE_TAG: ${{ github.event.inputs.image_tag }} 39 | run: | 40 | docker tag ${IMAGE_BASE}:${IMAGE_TAG} ${IMAGE_BASE}:4.x 41 | docker push ${IMAGE_BASE}:4.x 42 | - name: Publish rootless image to 4.x-rootless 43 | env: 44 | IMAGE_TAG: ${{ github.event.inputs.image_tag_rootless }} 45 | run: | 46 | docker pull ${IMAGE_BASE}:${IMAGE_TAG} 47 | docker tag ${IMAGE_BASE}:${IMAGE_TAG} ${IMAGE_BASE}:4.x-rootless 48 | docker push ${IMAGE_BASE}:4.x-rootless 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | Vagrantfile 3 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @puppetlabs/cd4pe 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # specifying the platform here allows builds to work 2 | # correctly on Apple Silicon machines 3 | FROM --platform=amd64 ruby:2.7.4-slim-buster as base 4 | 5 | ARG VCS_REF 6 | ARG GH_USER=puppetlabs 7 | 8 | LABEL org.label-schema.vcs-ref="${VCS_REF}" \ 9 | org.label-schema.vcs-url="https://github.com/${GH_USER}/puppet-dev-tools" 10 | 11 | ENV DEBIAN_FRONTEND=noninteractive 12 | 13 | RUN apt-get update -qq \ 14 | && apt-get install -y locales \ 15 | && sed -i -e 's/# \(en_US\.UTF-8 .*\)/\1/' /etc/locale.gen \ 16 | && locale-gen 17 | 18 | ENV LANG en_US.UTF-8 19 | ENV LANGUAGE en_US:en 20 | ENV LC_ALL en_US.UTF-8 21 | 22 | RUN apt-get install -y apt-utils \ 23 | && apt-get update -qq \ 24 | && apt-get upgrade -y \ 25 | && apt-get install -y --no-install-recommends curl libxml2-dev libxslt1-dev g++ gcc git gnupg2 make openssh-client ruby-dev wget zlib1g-dev libldap-2.4-2 libldap-common libssl1.1 openssl cmake\ 26 | && wget https://apt.puppet.com/puppet-tools-release-buster.deb \ 27 | && dpkg -i puppet-tools-release-buster.deb \ 28 | && apt-get update -qq \ 29 | && apt-get install -y --no-install-recommends pdk=2.7.1.0-1buster \ 30 | && apt-get autoremove -y \ 31 | && rm -rf /var/lib/apt/lists/* \ 32 | && rm -rf /opt/puppetlabs/pdk/private/puppet/ruby/2.5.0/gems/httpclient-2.8.3/sample/ssl/* \ 33 | && rm -rf /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/httpclient-2.8.3/sample/ssl/* \ 34 | && rm -rf /opt/puppetlabs/pdk/private/ruby/2.5.9/lib/ruby/gems/2.5.0/gems/httpclient-2.8.3/test/* \ 35 | && rm -rf /opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/httpclient-2.8.3/sample/ssl/* 36 | 37 | RUN ln -s /bin/mkdir /usr/bin/mkdir 38 | 39 | # Run tests on a module created with PDK 1.18.1 using the current PDK to pull in 40 | # any other dependencies and then delete the 1.18.1 test module. 41 | # 42 | # Simply running "bundle install" against the module is not enough, 43 | # as PDK has further dependencies to pull in. 44 | COPY pdk_1_18_1_dependencies /test_module 45 | RUN cd test_module \ 46 | && pdk validate \ 47 | && cd .. \ 48 | && rm -rf test_module 49 | 50 | RUN groupadd --gid 1001 puppetdev \ 51 | && useradd --uid 1001 --gid puppetdev --create-home puppetdev 52 | 53 | # Prep for non-root user 54 | RUN gem install bundler -v 2.4.22 \ 55 | && chown -R puppetdev:puppetdev /usr/local/bundle \ 56 | && mkdir /setup \ 57 | && chown -R puppetdev:puppetdev /setup \ 58 | && mkdir /repo \ 59 | && chown -R puppetdev:puppetdev /repo 60 | 61 | # Switch to a non-root user for everything below here 62 | USER puppetdev 63 | 64 | # Install dependent gems 65 | WORKDIR /setup 66 | ADD Gemfile* /setup/ 67 | COPY Rakefile /Rakefile 68 | 69 | RUN bundle config set system 'true' \ 70 | && bundle config set jobs 3 \ 71 | && bundle install \ 72 | && rm -f /home/puppetdev/.bundle/config \ 73 | && rm -rf /usr/local/bundle/gems/puppet-7.*.0/spec 74 | 75 | WORKDIR /repo 76 | 77 | FROM base AS rootless 78 | 79 | FROM base AS main 80 | USER root 81 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'ffi', '~> 1.12', '>= 1.12.2' 4 | gem 'hiera-eyaml', '~> 3.2', '>= 3.2.1' 5 | gem 'json', '~> 2.3' 6 | gem 'nokogiri', '~> 1.10', '>= 1.10.9' 7 | gem 'onceover', '~> 3.20', '>= 3.20.0' 8 | gem 'onceover-codequality', '~> 0.8', '>= 0.8.0' 9 | gem 'onceover-octocatalog-diff', '~> 0.1', '>= 0.1.8' 10 | gem 'onceover-lookup', '~> 0.1', '>= 0.1.1' 11 | gem 'parallel', '~> 1.20', '>= 1.20.1' 12 | gem 'puppet-lint-classes_and_types_beginning_with_digits-check', '~> 1.0' 13 | gem 'puppet-lint-leading_zero-check', '~> 1.0' 14 | gem 'puppet-lint-legacy_facts-check', '~> 1.0', '>= 1.0.4' 15 | gem 'puppet-lint-top_scope_facts-check', '~> 1.0' 16 | gem 'puppet-lint-trailing_comma-check', '~> 0.4.1' 17 | gem 'puppet-lint-unquoted_string-check', '~> 2.0' 18 | gem 'puppet-lint-variable_contains_upcase', '~> 1.2' 19 | gem 'puppet-lint-version_comparison-check', '~> 1.0' 20 | gem 'puppet-lint', '~> 2.4' 21 | gem 'puppet-strings', '~> 2.6' 22 | gem 'puppet-syntax', '~> 3.2.0' 23 | gem 'puppet', '~> 7.5' 24 | gem 'puppetlabs_spec_helper', '~> 5.0' 25 | gem 'r10k', '~> 3.8' 26 | gem 'ra10ke', '~> 1.0' 27 | gem 'rspec-puppet', '~> 2.12.0' 28 | gem 'rubocop', '~> 1.12' 29 | gem 'unf_ext', '~> 0.0.8' 30 | gem 'yamllint', '~> 0.0.9' 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Puppet Dev Tools 2 | 3 | ![GitHub Actions Build-Test-Push status](https://github.com/puppetlabs/puppet-dev-tools/workflows/Build-Test-Push/badge.svg) 4 | [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=puppetlabs/puppet-dev-tools)](https://dependabot.com) 5 | [![](https://images.microbadger.com/badges/version/puppet/puppet-dev-tools.svg)](https://microbadger.com/images/puppet/puppet-dev-tools "Get your own version badge on microbadger.com") 6 | [![](https://images.microbadger.com/badges/commit/puppet/puppet-dev-tools.svg)](https://microbadger.com/images/puppet/puppet-dev-tools "Get your own commit badge on microbadger.com") 7 | 8 | ## Docker Tags 9 | 10 | - `---`: Each merge to master generates an image tagged with the date of its build followed by a short git SHA. These images are suitable for pinning to if you do not wish to live on the edge with `4.x`. Changes from one image to the next will include things shown in the [commit history](https://github.com/puppetlabs/puppet-dev-tools/commits/master) on GitHub and updated operating system packages pulled in at build time. The latest version of the PDK is also pulled in at build time. 11 | - `----rootless`: This is just like the tag above but the container runs as a user namecd `puppetdev`. 12 | - `4.x`: This the tag that is used in the 4.x versions of CD4PE. This tag is updated manually from time to time. 13 | - `latest`: This is a legacy tag and not not actually the current build of puppet-dev-tools. It is the build used in older versions of CD4PE (prior to 4.0). These builds are manually created by the CD4PE team. 14 | 15 | ## Running 16 | 17 | This container is designed to run commands against control repos or modules that you want to test. It assumes that the repo code is mounted to /repo inside the container. To run test commands, from the root of a repo you want to test, run docker run --rm -v $(pwd):/repo puppet/puppet-dev-tools where is any of the ones listed below. 18 | 19 | ## Supported Commands 20 | 21 | 1. PDK - `pdk` 22 | - run `docker run --rm puppet/puppet-dev-tools:4.x pdk --help` to see builtin help 23 | - see the [PDK command reference](https://puppet.com/docs/pdk/1.x/pdk_reference.html) for details 24 | 2. Onceover - `onceover` 25 | - run `docker run --rm puppet/puppet-dev-tools:4.x onceover --help` to see builtin help 26 | - see [Onceover's readme](https://github.com/dylanratcliffe/onceover/blob/master/README.md) for details 27 | 3. Rake tasks from the installed gems (see below) 28 | - run a single rake task like so: `docker run --rm -v $(pwd):/repo puppet/puppet-dev-tools:4.x rake -f /Rakefile lint` 29 | - run multiple rake tasks sequentially like so: `docker run --rm -v $(pwd):/repo puppet/puppet-dev-tools:4.x rake -f /Rakefile lint syntax yamllint` 30 | 31 | ### A note on Onceover usage 32 | 33 | If your control repository contains a Gemfile you will likely want to modify the commands listed above to something like this: 34 | 35 | ```bash 36 | docker run --rm -v $(pwd):/repo puppet/puppet-dev-tools:latest \ 37 | /bin/bash -c "bundle install && bundle exec onceover run spec --force --trace --parallel" 38 | ``` 39 | 40 | 41 | 42 | ### Rake Tasks 43 | 44 | | Command | Description | 45 | | ------- | ----------- | 46 | | rake beaker | Run beaker acceptance tests | 47 | | rake beaker:sets | List available beaker nodesets | 48 | | rake beaker:ssh[set,node] | Try to use vagrant to login to the Beaker node | 49 | | rake build | Build puppet module package | 50 | | rake build:pdk | Build Puppet module with PDK | 51 | | rake build:pmt | Build Puppet module package with PMT (Puppet < 6.0.0 only) | 52 | | rake check | Run static pre release checks | 53 | | rake check:dot_underscore | Fails if any ._ files are present in directory | 54 | | rake check:git_ignore | Fails if directories contain the files specified in .gitignore | 55 | | rake check:symlinks | Fails if symlinks are present in directory | 56 | | rake check:test_file | Fails if .pp files present in tests folder | 57 | | rake check_for_spec_tests | Get spec test status | 58 | | rake clean | Clean a built module package | 59 | | rake compute_dev_version | Print development version of module | 60 | | rake generate_fixtures | Writes a `fixtures.yml` file based on the Puppetfile / Generate Fixtures files for role/profile | 61 | | rake generate_spec_tests | Generate spec tests for missing classes | 62 | | rake help | Display the list of available rake tasks | 63 | | rake hiera_setup | Modifies your `hiera.yaml` to point at the hieradata relative to its position | 64 | | rake lint | Run puppet-lint | 65 | | rake lint_fix | Run puppet-lint | 66 | | rake parallel_spec | Run spec tests in parallel and clean the fixtures directory if successful | 67 | | rake parallel_spec_standalone | Parallel spec tests | 68 | | rake pe_only_mods | Show PE Only Modules | 69 | | rake r10k:dependencies | Print outdated forge modules | 70 | | rake r10k:duplicates | Check Puppetfile for duplicates | 71 | | rake r10k:install | Install modules specified in Puppetfile | 72 | | rake r10k:solve_dependencies[allow_major_bump] | Find missing or outdated module dependencies | 73 | | rake r10k:syntax | Syntax check Puppetfile | 74 | | rake r10k:validate | Validate the git urls and branches, refs, or tags | 75 | | rake release_checks | Runs all necessary checks on a module in preparation for a release | 76 | | rake rubocop | Run RuboCop | 77 | | rake rubocop:auto_correct | Auto-correct RuboCop offenses | 78 | | rake run_tests | Run tests | 79 | | rake spec | Run spec tests and clean the fixtures directory if successful | 80 | | rake spec:simplecov | Run spec tests with ruby simplecov code coverage | 81 | | rake spec_clean | Clean up the fixtures directory | 82 | | rake spec_clean_symlinks | Clean up any fixture symlinks | 83 | | rake spec_list_json | List spec tests in a JSON document | 84 | | rake spec_prep | Create the fixtures directory | 85 | | rake spec_standalone | Run RSpec code examples | 86 | | rake strings:generate[patterns,debug,backtrace,markup,json,markdown,yard_args] | Generate Puppet documentation with YARD | 87 | | rake strings:generate:reference[patterns,debug,backtrace] | Generate Puppet Reference documentation | 88 | | rake strings:gh_pages:update | Update docs on the gh-pages branch and push to GitHub | 89 | | rake syntax | Syntax check Puppet manifests and templates | 90 | | rake syntax:hiera | Syntax check Hiera config files | 91 | | rake syntax:manifests | Syntax check Puppet manifests | 92 | | rake syntax:templates | Syntax check Puppet templates | 93 | | rake validate | Check syntax of Ruby files and call :syntax and :metadata_lint | 94 | | rake yamllint | Run yamllint | 95 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'erb' 2 | require 'fileutils' 3 | require 'json' 4 | require 'onceover/rake_tasks' 5 | require 'puppet-lint/tasks/puppet-lint' 6 | require 'puppet-syntax/tasks/puppet-syntax' 7 | require 'puppetlabs_spec_helper/rake_tasks' 8 | require 'r10k/puppetfile' 9 | require 'ra10ke' 10 | require 'yamllint/rake_task' 11 | 12 | #Use the environment variable EXCLUDE_PATHS, delineated by ':', to know what 13 | #paths to exclude from syntax and linting checks 14 | exclude_paths = if ENV['EXCLUDE_PATHS'] 15 | ENV['EXCLUDE_PATHS'].split(':') 16 | else 17 | [ 18 | ".onceover/**/*", 19 | "bundle/**/*", 20 | "modules/**/plans/*", 21 | "pkg/**/*.pp", 22 | "site-modules/**/plans/*", 23 | "site/**/plans/*", 24 | "site/*/spec/**/*", 25 | "spec/**/*.pp", 26 | "vendor/**/*", 27 | ] 28 | end 29 | 30 | PuppetLint.configuration.fail_on_warnings = true 31 | PuppetLint.configuration.send('relative') 32 | PuppetLint.configuration.send('disable_140chars') 33 | PuppetLint.configuration.send('disable_class_inherits_from_params_class') 34 | PuppetLint.configuration.send('disable_documentation') 35 | PuppetLint.configuration.ignore_paths = exclude_paths 36 | 37 | PuppetSyntax.exclude_paths = exclude_paths 38 | PuppetSyntax.check_hiera_keys = true 39 | 40 | ps_hieradata_paths = [ 41 | "data/*.yaml", 42 | "data/**/*.yaml", 43 | "hieradata/**/*.yaml", 44 | "hiera*.yaml", 45 | ] 46 | 47 | yl_paths = %w( 48 | *.yml 49 | *.yaml 50 | data/*.yaml 51 | data/**/*.yaml 52 | hieradata/**/*.yml 53 | hieradata/**/*.yaml 54 | ) 55 | 56 | if File.file?('spec/testing.yaml') 57 | ps_hieradata_paths.push('spec/testing.yaml') 58 | yl_paths.push('spec/testing.yaml') 59 | end 60 | 61 | PuppetSyntax.hieradata_paths = ps_hieradata_paths 62 | 63 | YamlLint::RakeTask.new do |yamllint| 64 | yamllint.paths = yl_paths 65 | end 66 | 67 | Rake::Task[:spec_prep].enhance [:generate_fixtures] 68 | 69 | # Pull in the ra10ke rake tasks 70 | Ra10ke::RakeTask.new 71 | 72 | desc "Run tests" 73 | task :run_tests do 74 | print "Executing Lint Test...\n" 75 | Rake::Task[:lint].execute 76 | print " -> Success!\n\n" 77 | 78 | print "Executing Syntax Test...\n" 79 | Rake::Task[:syntax].execute 80 | print " -> Success!\n\n" 81 | 82 | print "Executing r10k(Puppetfile) Syntax Test...\n -> " 83 | Rake::Task['r10k:syntax'].execute 84 | print "\n" 85 | 86 | print "Checking for missing spec tests...\n" 87 | Rake::Task[:check_for_spec_tests].execute 88 | print " -> No missing tests!\n\n" 89 | 90 | print "Launching rspec tests...\n" 91 | Rake::Task[:spec].execute 92 | end 93 | 94 | desc "Generate Fixtures files for role/profile" 95 | task :generate_fixtures do 96 | print "Generating Fixtures..." 97 | build_fixtures(File.dirname(__FILE__)) 98 | print "Done!\n" 99 | end 100 | 101 | desc "Generate spec tests for missing classes" 102 | task :generate_spec_tests do 103 | spec_gen(true) 104 | end 105 | 106 | desc "Get spec test status" 107 | task :check_for_spec_tests do 108 | spec_gen 109 | end 110 | 111 | desc "Show PE Only Modules" 112 | task :pe_only_mods do 113 | puts get_pe_modules 114 | end 115 | 116 | def get_pe_modules 117 | # Query Puppet Forge for the latest list of PE-only modules 118 | # Thanks to dan-wittenberg for the original logic on this! 119 | modules = {} 120 | 121 | url="https://forgeapi.puppetlabs.com/v3/modules?module_groups=pe_only" 122 | r = RestClient.get url, { :accept => 'application/json', :charset => 'utf-8' } 123 | 124 | JSON.parse(r.force_encoding("UTF-8"))['results'].each do |x| 125 | name = x['current_release']['metadata']['name'].gsub('/','-') 126 | modules[name] = "git@github.com:puppetlabs/#{name}.git" 127 | end 128 | 129 | modules 130 | end 131 | 132 | def spec_gen(create=false) 133 | exit_code = 0 134 | ['role','profile'].each do |m| 135 | # For role or profile, find all the classes 136 | classes = Array.new 137 | 138 | pattern = 'site/profile/manifests/*/*.pp' if m == 'profile' 139 | pattern = 'site/role/manifests/*/*.pp' if m == 'role' 140 | Dir.glob("#{pattern}").each do |f| 141 | File.open(f).read.each_line do |l| 142 | c = l.scan(/(\s+)?class\s+([a-zA-Z:_]+)\s+[\{,\(]/) 143 | # Add this class to the classes array 144 | classes.push(c[0][1]) if !c.empty? 145 | end 146 | end 147 | 148 | # For each class, see if a spec file exists - using naming convention 149 | # _[__]_spec.rb 150 | classes.each do |c| 151 | spec_file = "#{File.dirname(__FILE__)}/spec/classes/#{m}/#{c.split('::').join('_')}_spec.rb" 152 | 153 | # If no spec file exists, create a blank should compile test file 154 | if File.exists?(spec_file) 155 | puts "Class #{c} - Spec file already exists at #{spec_file}!" if create == true 156 | else 157 | if create == true 158 | puts "Class #{c} - Creating... #{spec_file}!" 159 | File.open(spec_file, 'w') do |f| 160 | f.write evaluate_template('spec_template.rb.erb',binding) 161 | end 162 | else 163 | puts "Class #{c} - Spec file missing!" 164 | exit_code = 1 165 | end 166 | end 167 | end 168 | end 169 | 170 | if exit_code != 0 171 | raise(exit_code) 172 | end 173 | end 174 | 175 | # Most of this logic was lifted from onceover (comments and all) - thank you! 176 | # https://github.com/dylanratcliffe/onceover/blob/98811bee7bf373e1a22706d98f9ccc1360aff482/lib/onceover/controlrepo.rb 177 | def evaluate_template(template_name,bind) 178 | template_dir = File.expand_path('./scripts',File.dirname(__FILE__)) 179 | template = File.read(File.expand_path("./#{template_name}",template_dir)) 180 | ERB.new(template, nil, '-').result(bind) 181 | end 182 | 183 | def build_fixtures(controlrepo) 184 | # Load up the Puppetfile using R10k 185 | puppetfile = R10K::Puppetfile.new(controlrepo) 186 | fail 'Could not load Puppetfile' unless puppetfile.load 187 | modules = puppetfile.modules 188 | 189 | # Store PE Only Mods list 190 | pe_only = get_pe_modules 191 | 192 | # Iterate over everything and seperate it out for the sake of readability 193 | symlinks = [] 194 | forge_modules = [] 195 | repositories = [] 196 | 197 | modules.each do |mod| 198 | # This logic could probably be cleaned up. A lot. 199 | if mod.is_a? R10K::Module::Forge 200 | if mod.expected_version.is_a?(Hash) 201 | # Set it up as a symlink, because we are using local files in the Puppetfile 202 | symlinks << { 203 | 'name' => mod.name, 204 | 'dir' => mod.expected_version[:path] 205 | } 206 | elsif mod.expected_version.is_a?(String) 207 | 208 | # Verify if this is a PE mod or not 209 | # if it is a PE only module; we need to set it up as a git repo for fixtures b/c of license issues 210 | if pe_only.keys.include?(mod.title.gsub('/','-')) 211 | # Its PE Only 212 | repositories << { 213 | 'name' => mod.name, 214 | 'repo' => mod.instance_variable_get(:@remote) =~ /\.git/ ? mod.instance_variable_get(:@remote) : pe_only[mod.title], 215 | # ^^ This isn't perfect, as some of the repo names don't match - but its a start 216 | 'ref' => mod.expected_version 217 | } 218 | else 219 | # Set it up as a normal forge module 220 | forge_modules << { 221 | 'name' => mod.name, 222 | 'repo' => mod.title, 223 | 'ref' => mod.expected_version 224 | } 225 | end 226 | 227 | end 228 | elsif mod.is_a? R10K::Module::Git 229 | # Set it up as a git repo 230 | repositories << { 231 | 'name' => mod.name, 232 | 'repo' => mod.instance_variable_get(:@remote), 233 | 'ref' => mod.version 234 | } 235 | end 236 | end 237 | 238 | symlinks << { 239 | 'name' => "profile", 240 | 'dir' => '"#{source_dir}/site/profile"', 241 | } 242 | 243 | symlinks << { 244 | 'name' => "role", 245 | 'dir' => '"#{source_dir}/site/role"', 246 | } 247 | 248 | symlinks << { 249 | 'name' => "manifests", 250 | 'dir' => '"#{source_dir}/manifests"', 251 | } 252 | 253 | File.open("#{File.dirname(__FILE__)}/.fixtures.yml",'w') do |f| 254 | f.write evaluate_template('fixtures.yml.erb',binding) 255 | end 256 | end 257 | 258 | 259 | -------------------------------------------------------------------------------- /build-rootless.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | GH_USER=${1:-puppetlabs} 6 | DOCKER_IMAGE=${2:-'puppet-dev-tools:latest-rootless'} 7 | 8 | docker build \ 9 | --target rootless \ 10 | -t ${DOCKER_IMAGE} \ 11 | --build-arg VCS_REF=$(git rev-parse --short HEAD) \ 12 | --build-arg GH_USER=${GH_USER} \ 13 | -f Dockerfile . 14 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | GH_USER=${1:-puppetlabs} 6 | DOCKER_IMAGE=${2:-'puppet-dev-tools:latest'} 7 | 8 | docker build \ 9 | -t ${DOCKER_IMAGE} \ 10 | --build-arg VCS_REF=$(git rev-parse --short HEAD) \ 11 | --build-arg GH_USER=${GH_USER} \ 12 | -f Dockerfile . 13 | 14 | echo "Updating rake tasks in README.md..." 15 | ./update_readme.sh 16 | -------------------------------------------------------------------------------- /pdk_1_18_1_dependencies/.rubocop.yml: -------------------------------------------------------------------------------- 1 | --- 2 | require: 3 | - rubocop-rspec 4 | - rubocop-i18n 5 | AllCops: 6 | DisplayCopNames: true 7 | TargetRubyVersion: "2.1" 8 | Include: 9 | - "./**/*.rb" 10 | Exclude: 11 | - bin/* 12 | - ".vendor/**/*" 13 | - "**/Gemfile" 14 | - "**/Rakefile" 15 | - pkg/**/* 16 | - spec/fixtures/**/* 17 | - vendor/**/* 18 | - "**/Puppetfile" 19 | - "**/Vagrantfile" 20 | - "**/Guardfile" 21 | Metrics/LineLength: 22 | Description: People have wide screens, use them. 23 | Max: 200 24 | GetText: 25 | Enabled: false 26 | GetText/DecorateString: 27 | Description: We don't want to decorate test output. 28 | Exclude: 29 | - spec/**/* 30 | Enabled: false 31 | RSpec/BeforeAfterAll: 32 | Description: 33 | Beware of using after(:all) as it may cause state to leak between tests. 34 | A necessary evil in acceptance testing. 35 | Exclude: 36 | - spec/acceptance/**/*.rb 37 | RSpec/HookArgument: 38 | Description: Prefer explicit :each argument, matching existing module's style 39 | EnforcedStyle: each 40 | Style/BlockDelimiters: 41 | Description: 42 | Prefer braces for chaining. Mostly an aesthetical choice. Better to 43 | be consistent then. 44 | EnforcedStyle: braces_for_chaining 45 | Style/BracesAroundHashParameters: 46 | Description: 47 | Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. 48 | See https://github.com/rubocop-hq/rubocop/pull/7643 49 | Enabled: true 50 | Style/ClassAndModuleChildren: 51 | Description: Compact style reduces the required amount of indentation. 52 | EnforcedStyle: compact 53 | Style/EmptyElse: 54 | Description: Enforce against empty else clauses, but allow `nil` for clarity. 55 | EnforcedStyle: empty 56 | Style/FormatString: 57 | Description: Following the main puppet project's style, prefer the % format format. 58 | EnforcedStyle: percent 59 | Style/FormatStringToken: 60 | Description: 61 | Following the main puppet project's style, prefer the simpler template 62 | tokens over annotated ones. 63 | EnforcedStyle: template 64 | Style/Lambda: 65 | Description: Prefer the keyword for easier discoverability. 66 | EnforcedStyle: literal 67 | Style/RegexpLiteral: 68 | Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 69 | EnforcedStyle: percent_r 70 | Style/TernaryParentheses: 71 | Description: 72 | Checks for use of parentheses around ternary conditions. Enforce parentheses 73 | on complex expressions for better readability, but seriously consider breaking 74 | it up. 75 | EnforcedStyle: require_parentheses_when_complex 76 | Style/TrailingCommaInArguments: 77 | Description: 78 | Prefer always trailing comma on multiline argument lists. This makes 79 | diffs, and re-ordering nicer. 80 | EnforcedStyleForMultiline: comma 81 | Style/TrailingCommaInLiteral: 82 | Description: 83 | Prefer always trailing comma on multiline literals. This makes diffs, 84 | and re-ordering nicer. 85 | EnforcedStyleForMultiline: comma 86 | Style/SymbolArray: 87 | Description: Using percent style obscures symbolic intent of array's contents. 88 | EnforcedStyle: brackets 89 | RSpec/MessageSpies: 90 | EnforcedStyle: receive 91 | Style/Documentation: 92 | Exclude: 93 | - lib/puppet/parser/functions/**/* 94 | - spec/**/* 95 | Style/WordArray: 96 | EnforcedStyle: brackets 97 | Style/CollectionMethods: 98 | Enabled: true 99 | Style/MethodCalledOnDoEndBlock: 100 | Enabled: true 101 | Style/StringMethods: 102 | Enabled: true 103 | GetText/DecorateFunctionMessage: 104 | Enabled: false 105 | GetText/DecorateStringFormattingUsingInterpolation: 106 | Enabled: false 107 | GetText/DecorateStringFormattingUsingPercent: 108 | Enabled: false 109 | Layout/EndOfLine: 110 | Enabled: false 111 | Layout/IndentHeredoc: 112 | Enabled: false 113 | Metrics/AbcSize: 114 | Enabled: false 115 | Metrics/BlockLength: 116 | Enabled: false 117 | Metrics/ClassLength: 118 | Enabled: false 119 | Metrics/CyclomaticComplexity: 120 | Enabled: false 121 | Metrics/MethodLength: 122 | Enabled: false 123 | Metrics/ModuleLength: 124 | Enabled: false 125 | Metrics/ParameterLists: 126 | Enabled: false 127 | Metrics/PerceivedComplexity: 128 | Enabled: false 129 | RSpec/DescribeClass: 130 | Enabled: false 131 | RSpec/ExampleLength: 132 | Enabled: false 133 | RSpec/MessageExpectation: 134 | Enabled: false 135 | RSpec/MultipleExpectations: 136 | Enabled: false 137 | RSpec/NestedGroups: 138 | Enabled: false 139 | Style/AsciiComments: 140 | Enabled: false 141 | Style/IfUnlessModifier: 142 | Enabled: false 143 | Style/SymbolProc: 144 | Enabled: false 145 | -------------------------------------------------------------------------------- /pdk_1_18_1_dependencies/Gemfile: -------------------------------------------------------------------------------- 1 | source ENV['GEM_SOURCE'] || 'https://rubygems.org' 2 | 3 | def location_for(place_or_version, fake_version = nil) 4 | git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} 5 | file_url_regex = %r{\Afile:\/\/(?.*)} 6 | 7 | if place_or_version && (git_url = place_or_version.match(git_url_regex)) 8 | [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact 9 | elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) 10 | ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] 11 | else 12 | [place_or_version, { require: false }] 13 | end 14 | end 15 | 16 | ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments 17 | minor_version = ruby_version_segments[0..1].join('.') 18 | 19 | group :development do 20 | gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') 21 | gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') 22 | gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') 23 | gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') 24 | gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) 25 | gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) 26 | gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] 27 | gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] 28 | gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] 29 | gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] 30 | gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] 31 | end 32 | 33 | puppet_version = ENV['PUPPET_GEM_VERSION'] 34 | facter_version = ENV['FACTER_GEM_VERSION'] 35 | hiera_version = ENV['HIERA_GEM_VERSION'] 36 | 37 | gems = {} 38 | 39 | gems['puppet'] = location_for(puppet_version) 40 | 41 | # If facter or hiera versions have been specified via the environment 42 | # variables 43 | 44 | gems['facter'] = location_for(facter_version) if facter_version 45 | gems['hiera'] = location_for(hiera_version) if hiera_version 46 | 47 | if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} 48 | # If we're using a Puppet gem on Windows which handles its own win32-xxx gem 49 | # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). 50 | gems['win32-dir'] = ['<= 0.4.9', require: false] 51 | gems['win32-eventlog'] = ['<= 0.6.5', require: false] 52 | gems['win32-process'] = ['<= 0.7.5', require: false] 53 | gems['win32-security'] = ['<= 0.2.5', require: false] 54 | gems['win32-service'] = ['0.8.8', require: false] 55 | end 56 | 57 | gems.each do |gem_name, gem_params| 58 | gem gem_name, *gem_params 59 | end 60 | 61 | # Evaluate Gemfile.local and ~/.gemfile if they exist 62 | extra_gemfiles = [ 63 | "#{__FILE__}.local", 64 | File.join(Dir.home, '.gemfile'), 65 | ] 66 | 67 | extra_gemfiles.each do |gemfile| 68 | if File.file?(gemfile) && File.readable?(gemfile) 69 | eval(File.read(gemfile), binding) 70 | end 71 | end 72 | # vim: syntax=ruby 73 | -------------------------------------------------------------------------------- /pdk_1_18_1_dependencies/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testuser-test_module", 3 | "version": "0.1.0", 4 | "author": "testuser", 5 | "summary": "", 6 | "license": "Apache-2.0", 7 | "source": "", 8 | "dependencies": [ 9 | 10 | ], 11 | "operatingsystem_support": [ 12 | { 13 | "operatingsystem": "CentOS", 14 | "operatingsystemrelease": [ 15 | "7" 16 | ] 17 | }, 18 | { 19 | "operatingsystem": "OracleLinux", 20 | "operatingsystemrelease": [ 21 | "7" 22 | ] 23 | }, 24 | { 25 | "operatingsystem": "RedHat", 26 | "operatingsystemrelease": [ 27 | "8" 28 | ] 29 | }, 30 | { 31 | "operatingsystem": "Scientific", 32 | "operatingsystemrelease": [ 33 | "7" 34 | ] 35 | }, 36 | { 37 | "operatingsystem": "Debian", 38 | "operatingsystemrelease": [ 39 | "9" 40 | ] 41 | }, 42 | { 43 | "operatingsystem": "Ubuntu", 44 | "operatingsystemrelease": [ 45 | "18.04" 46 | ] 47 | }, 48 | { 49 | "operatingsystem": "windows", 50 | "operatingsystemrelease": [ 51 | "2019", 52 | "10" 53 | ] 54 | } 55 | ], 56 | "requirements": [ 57 | { 58 | "name": "puppet", 59 | "version_requirement": ">= 4.10.0 < 7.0.0" 60 | } 61 | ], 62 | "pdk-version": "1.18.1", 63 | "template-url": "pdk-default#1.18.1", 64 | "template-ref": "tags/1.18.1-0-g3d2e75c" 65 | } 66 | -------------------------------------------------------------------------------- /tests/control-repo/badsyntax/Puppetfile: -------------------------------------------------------------------------------- 1 | forge "https://forgeapi.puppetlabs.com" 2 | 3 | mod 'puppetlabs/dummy_service' BAD SYNTAX 4 | mod 'puppetlabs/pe_upgrade' 5 | mod 'puppetlabs/java', '2.0.0' 6 | -------------------------------------------------------------------------------- /tests/control-repo/badsyntax/data/common.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | splunk::params::version: "6.0" 3 | splunk::params::build: "182037" 4 | oaiwjefoiajoiawefj:::oijweoifj$$ 5 | -------------------------------------------------------------------------------- /tests/control-repo/badsyntax/site/profile/manifests/common.pp: -------------------------------------------------------------------------------- 1 | class profile::common { 2 | include profile::pe_env 3 | include profile::firewall 4 | 5 | case BAD SYNTAX $::osfamily { 6 | default: { } # for OS's not listed, do nothing 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/control-repo/badsyntax/site/profile/templates/bad_template.epp: -------------------------------------------------------------------------------- 1 | This file is a template with bad syntax on the next line 2 | <%= oaiwejfoiajweoifj $ $$ %> 3 | It should fail 4 | 5 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/Puppetfile: -------------------------------------------------------------------------------- 1 | forge "https://forgeapi.puppetlabs.com" 2 | 3 | mod 'puppetlabs/dummy_service' 4 | mod 'puppetlabs/pe_upgrade' 5 | mod 'puppetlabs/java', '2.0.0' 6 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/data/common.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | splunk::params::version: "6.0" 3 | splunk::params::build: "182037" 4 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/environment.conf: -------------------------------------------------------------------------------- 1 | modulepath = site:modules:$basemodulepath 2 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | version: 5 4 | 5 | hierarchy: 6 | - name: "Per-node data" 7 | path: "nodes/%{trusted.certname}.yaml" 8 | 9 | - name: "Kubernetes Configurations" 10 | path: "kubernetes.yaml" 11 | 12 | - name: "Per-datacenter business group data" 13 | path: "datacenter/%{trusted.extensions.pp_datacenter}.yaml" 14 | 15 | - name: "Per-datacenter secret data (encrypted)" 16 | lookup_key: eyaml_lookup_key 17 | path: "secrets/%{trusted.extensions.pp_datacenter}.eyaml" 18 | options: 19 | pkcs7_private_key: /etc/puppetlabs/puppet/eyaml/private_key.pkcs7.pem 20 | pkcs7_public_key: /etc/puppetlabs/puppet/eyaml/public_key.pkcs7.pem 21 | 22 | - name: "Per-environment data" 23 | path: "environment/%{trusted.extensions.pp_environment}.yaml" 24 | 25 | - name: "Per-OS defaults" 26 | path: "os/%{facts.os.family}.yaml" 27 | 28 | - name: "Per-Host defaults" 29 | path: "nodes/%{trusted.certname}.yaml" 30 | 31 | - name: "Common data" 32 | path: "common.yaml" 33 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/manifests/site.pp: -------------------------------------------------------------------------------- 1 | ## site.pp ## 2 | 3 | # This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point 4 | # used when an agent connects to a master and asks for an updated configuration. 5 | # 6 | # Global objects like filebuckets and resource defaults should go in this file, 7 | # as should the default node definition. (The default node can be omitted 8 | # if you use the console and don't define any other nodes in site.pp. See 9 | # http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on 10 | # node definitions.) 11 | 12 | ## Active Configurations ## 13 | 14 | # PRIMARY FILEBUCKET 15 | # This configures puppet agent and puppet inspect to back up file contents when 16 | # they run. The Puppet Enterprise console needs this to display file contents 17 | # and differences. 18 | 19 | # Define filebucket 'main': 20 | filebucket { 'main': 21 | path => false, 22 | #server => $::puppet_server, 23 | } 24 | 25 | # Make filebucket 'main' the default backup location for all File resources: 26 | File { backup => 'main' } 27 | 28 | Package { allow_virtual => false } 29 | 30 | if $facts['os']['family'] == 'windows' { 31 | File { 32 | source_permissions => ignore, 33 | } 34 | } 35 | 36 | # DEFAULT NODE 37 | # Node definitions in this file are merged with node data from the console. See 38 | # http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on 39 | # node definitions. 40 | 41 | # The default node definition matches any node lacking a more specific node 42 | # definition. If there are no other nodes in this file, classes declared here 43 | # will be included in every node's catalog, *in addition* to any classes 44 | # specified in the console for that node. 45 | 46 | node default { } 47 | 48 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-controlrepo", 3 | "version": "0.0.1", 4 | "author": "puppet", 5 | "summary": "Control-Repo", 6 | "license": "Apache-2.0", 7 | "dependencies": [ 8 | { 9 | "name": "puppetlabs-stdlib", 10 | "version_requirement": ">= 4.12.0" 11 | } 12 | ], 13 | "operatingsystem_support": [ 14 | { 15 | "operatingsystem": "RedHat", 16 | "operatingsystemrelease": [ 17 | "6", 18 | "7" 19 | ] 20 | }, 21 | { 22 | "operatingsystem": "CentOS", 23 | "operatingsystemrelease": [ 24 | "6", 25 | "7" 26 | ] 27 | }, 28 | { 29 | "operatingsystem": "Ubuntu", 30 | "operatingsystemrelease": [ 31 | "14.04", 32 | "16.04" 33 | ] 34 | }, 35 | { 36 | "operatingsystem": "windows", 37 | "operatingsystemrelease": [ 38 | "2012 R2" 39 | ] 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/site/profile/manifests/common.pp: -------------------------------------------------------------------------------- 1 | # Common profile class 2 | class profile::common { 3 | include profile::pe_env 4 | include profile::firewall 5 | 6 | case $facts['os']['family'] { 7 | default: { } # for OS's not listed, do nothing 8 | 'redhat': { 9 | notify { 'I found redhat': } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/control-repo/goodsyntax/site/profile/templates/good_template.epp: -------------------------------------------------------------------------------- 1 | This file is a template with no bad syntax on the next line 2 | <%= $variable %> 3 | It should not fail 4 | 5 | -------------------------------------------------------------------------------- /tests/module/test/.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM puppet/pdk:latest 2 | 3 | # [Optional] Uncomment this section to install additional packages. 4 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 5 | # && apt-get -y install --no-install-recommends 6 | 7 | -------------------------------------------------------------------------------- /tests/module/test/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet 3 | { 4 | "name": "Puppet Development Kit (Community)", 5 | "dockerFile": "Dockerfile", 6 | 7 | // Set *default* container specific settings.json values on container create. 8 | "settings": { 9 | "terminal.integrated.shell.linux": "/bin/bash" 10 | }, 11 | 12 | // Add the IDs of extensions you want installed when the container is created. 13 | "extensions": [ 14 | "puppet.puppet-vscode", 15 | "rebornix.Ruby" 16 | ] 17 | 18 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 19 | // "forwardPorts": [], 20 | 21 | // Use 'postCreateCommand' to run commands after the container is created. 22 | // "postCreateCommand": "pdk --version", 23 | } 24 | -------------------------------------------------------------------------------- /tests/module/test/.fixtures.yml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /tests/module/test/.gitattributes: -------------------------------------------------------------------------------- 1 | *.rb eol=lf 2 | *.erb eol=lf 3 | *.pp eol=lf 4 | *.sh eol=lf 5 | *.epp eol=lf 6 | -------------------------------------------------------------------------------- /tests/module/test/.gitignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | .*.sw[op] 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 | /pkg/ 18 | /spec/fixtures/manifests/ 19 | /spec/fixtures/modules/ 20 | /tmp/ 21 | /vendor/ 22 | /convert_report.txt 23 | /update_report.txt 24 | .DS_Store 25 | .project 26 | .envrc 27 | /inventory.yaml 28 | /spec/fixtures/litmus_inventory.yaml 29 | -------------------------------------------------------------------------------- /tests/module/test/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | stages: 3 | - syntax 4 | - unit 5 | 6 | default: 7 | cache: 8 | paths: 9 | - vendor/bundle 10 | 11 | before_script: &before_script 12 | - bundle -v 13 | - rm Gemfile.lock || true 14 | - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" 15 | - "# Set `rubygems_version` in the .sync.yml to set a value" 16 | - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" 17 | - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' 18 | - gem --version 19 | - bundle -v 20 | - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) 21 | 22 | syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.7-Puppet ~> 6: 23 | stage: syntax 24 | image: ruby:2.5.7 25 | script: 26 | - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop 27 | variables: 28 | PUPPET_GEM_VERSION: '~> 6' 29 | 30 | parallel_spec-Ruby 2.5.7-Puppet ~> 6: 31 | stage: unit 32 | image: ruby:2.5.7 33 | script: 34 | - bundle exec rake parallel_spec 35 | variables: 36 | PUPPET_GEM_VERSION: '~> 6' 37 | 38 | syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.7.2-Puppet ~> 7: 39 | stage: syntax 40 | image: ruby:2.7.2 41 | script: 42 | - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop 43 | variables: 44 | PUPPET_GEM_VERSION: '~> 7' 45 | 46 | parallel_spec-Ruby 2.7.2-Puppet ~> 7: 47 | stage: unit 48 | image: ruby:2.7.2 49 | script: 50 | - bundle exec rake parallel_spec 51 | variables: 52 | PUPPET_GEM_VERSION: '~> 7' 53 | 54 | -------------------------------------------------------------------------------- /tests/module/test/.pdkignore: -------------------------------------------------------------------------------- 1 | .git/ 2 | .*.sw[op] 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 | /pkg/ 18 | /spec/fixtures/manifests/ 19 | /spec/fixtures/modules/ 20 | /tmp/ 21 | /vendor/ 22 | /convert_report.txt 23 | /update_report.txt 24 | .DS_Store 25 | .project 26 | .envrc 27 | /inventory.yaml 28 | /spec/fixtures/litmus_inventory.yaml 29 | /appveyor.yml 30 | /.editorconfig 31 | /.fixtures.yml 32 | /Gemfile 33 | /.gitattributes 34 | /.gitignore 35 | /.gitlab-ci.yml 36 | /.pdkignore 37 | /.puppet-lint.rc 38 | /Rakefile 39 | /rakelib/ 40 | /.rspec 41 | /.rubocop.yml 42 | /.travis.yml 43 | /.yardopts 44 | /spec/ 45 | /.vscode/ 46 | /.sync.yml 47 | /.devcontainer/ 48 | -------------------------------------------------------------------------------- /tests/module/test/.puppet-lint.rc: -------------------------------------------------------------------------------- 1 | --relative 2 | -------------------------------------------------------------------------------- /tests/module/test/.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /tests/module/test/.rubocop.yml: -------------------------------------------------------------------------------- 1 | --- 2 | require: 3 | - rubocop-performance 4 | - rubocop-rspec 5 | AllCops: 6 | DisplayCopNames: true 7 | TargetRubyVersion: '2.4' 8 | Include: 9 | - "**/*.rb" 10 | Exclude: 11 | - bin/* 12 | - ".vendor/**/*" 13 | - "**/Gemfile" 14 | - "**/Rakefile" 15 | - pkg/**/* 16 | - spec/fixtures/**/* 17 | - vendor/**/* 18 | - "**/Puppetfile" 19 | - "**/Vagrantfile" 20 | - "**/Guardfile" 21 | Layout/LineLength: 22 | Description: People have wide screens, use them. 23 | Max: 200 24 | RSpec/BeforeAfterAll: 25 | Description: Beware of using after(:all) as it may cause state to leak between tests. 26 | A necessary evil in acceptance testing. 27 | Exclude: 28 | - spec/acceptance/**/*.rb 29 | RSpec/HookArgument: 30 | Description: Prefer explicit :each argument, matching existing module's style 31 | EnforcedStyle: each 32 | RSpec/DescribeSymbol: 33 | Exclude: 34 | - spec/unit/facter/**/*.rb 35 | Style/BlockDelimiters: 36 | Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to 37 | be consistent then. 38 | EnforcedStyle: braces_for_chaining 39 | Style/ClassAndModuleChildren: 40 | Description: Compact style reduces the required amount of indentation. 41 | EnforcedStyle: compact 42 | Style/EmptyElse: 43 | Description: Enforce against empty else clauses, but allow `nil` for clarity. 44 | EnforcedStyle: empty 45 | Style/FormatString: 46 | Description: Following the main puppet project's style, prefer the % format format. 47 | EnforcedStyle: percent 48 | Style/FormatStringToken: 49 | Description: Following the main puppet project's style, prefer the simpler template 50 | tokens over annotated ones. 51 | EnforcedStyle: template 52 | Style/Lambda: 53 | Description: Prefer the keyword for easier discoverability. 54 | EnforcedStyle: literal 55 | Style/RegexpLiteral: 56 | Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 57 | EnforcedStyle: percent_r 58 | Style/TernaryParentheses: 59 | Description: Checks for use of parentheses around ternary conditions. Enforce parentheses 60 | on complex expressions for better readability, but seriously consider breaking 61 | it up. 62 | EnforcedStyle: require_parentheses_when_complex 63 | Style/TrailingCommaInArguments: 64 | Description: Prefer always trailing comma on multiline argument lists. This makes 65 | diffs, and re-ordering nicer. 66 | EnforcedStyleForMultiline: comma 67 | Style/TrailingCommaInArrayLiteral: 68 | Description: Prefer always trailing comma on multiline literals. This makes diffs, 69 | and re-ordering nicer. 70 | EnforcedStyleForMultiline: comma 71 | Style/SymbolArray: 72 | Description: Using percent style obscures symbolic intent of array's contents. 73 | EnforcedStyle: brackets 74 | RSpec/MessageSpies: 75 | EnforcedStyle: receive 76 | Style/Documentation: 77 | Exclude: 78 | - lib/puppet/parser/functions/**/* 79 | - spec/**/* 80 | Style/WordArray: 81 | EnforcedStyle: brackets 82 | Performance/AncestorsInclude: 83 | Enabled: true 84 | Performance/BigDecimalWithNumericArgument: 85 | Enabled: true 86 | Performance/BlockGivenWithExplicitBlock: 87 | Enabled: true 88 | Performance/CaseWhenSplat: 89 | Enabled: true 90 | Performance/ConstantRegexp: 91 | Enabled: true 92 | Performance/MethodObjectAsBlock: 93 | Enabled: true 94 | Performance/RedundantSortBlock: 95 | Enabled: true 96 | Performance/RedundantStringChars: 97 | Enabled: true 98 | Performance/ReverseFirst: 99 | Enabled: true 100 | Performance/SortReverse: 101 | Enabled: true 102 | Performance/Squeeze: 103 | Enabled: true 104 | Performance/StringInclude: 105 | Enabled: true 106 | Performance/Sum: 107 | Enabled: true 108 | Style/CollectionMethods: 109 | Enabled: true 110 | Style/MethodCalledOnDoEndBlock: 111 | Enabled: true 112 | Style/StringMethods: 113 | Enabled: true 114 | Bundler/InsecureProtocolSource: 115 | Enabled: false 116 | Gemspec/DuplicatedAssignment: 117 | Enabled: false 118 | Gemspec/OrderedDependencies: 119 | Enabled: false 120 | Gemspec/RequiredRubyVersion: 121 | Enabled: false 122 | Gemspec/RubyVersionGlobalsUsage: 123 | Enabled: false 124 | Layout/ArgumentAlignment: 125 | Enabled: false 126 | Layout/BeginEndAlignment: 127 | Enabled: false 128 | Layout/ClosingHeredocIndentation: 129 | Enabled: false 130 | Layout/EmptyComment: 131 | Enabled: false 132 | Layout/EmptyLineAfterGuardClause: 133 | Enabled: false 134 | Layout/EmptyLinesAroundArguments: 135 | Enabled: false 136 | Layout/EmptyLinesAroundAttributeAccessor: 137 | Enabled: false 138 | Layout/EndOfLine: 139 | Enabled: false 140 | Layout/FirstArgumentIndentation: 141 | Enabled: false 142 | Layout/HashAlignment: 143 | Enabled: false 144 | Layout/HeredocIndentation: 145 | Enabled: false 146 | Layout/LeadingEmptyLines: 147 | Enabled: false 148 | Layout/SpaceAroundMethodCallOperator: 149 | Enabled: false 150 | Layout/SpaceInsideArrayLiteralBrackets: 151 | Enabled: false 152 | Layout/SpaceInsideReferenceBrackets: 153 | Enabled: false 154 | Lint/BigDecimalNew: 155 | Enabled: false 156 | Lint/BooleanSymbol: 157 | Enabled: false 158 | Lint/ConstantDefinitionInBlock: 159 | Enabled: false 160 | Lint/DeprecatedOpenSSLConstant: 161 | Enabled: false 162 | Lint/DisjunctiveAssignmentInConstructor: 163 | Enabled: false 164 | Lint/DuplicateElsifCondition: 165 | Enabled: false 166 | Lint/DuplicateRequire: 167 | Enabled: false 168 | Lint/DuplicateRescueException: 169 | Enabled: false 170 | Lint/EmptyConditionalBody: 171 | Enabled: false 172 | Lint/EmptyFile: 173 | Enabled: false 174 | Lint/ErbNewArguments: 175 | Enabled: false 176 | Lint/FloatComparison: 177 | Enabled: false 178 | Lint/HashCompareByIdentity: 179 | Enabled: false 180 | Lint/IdentityComparison: 181 | Enabled: false 182 | Lint/InterpolationCheck: 183 | Enabled: false 184 | Lint/MissingCopEnableDirective: 185 | Enabled: false 186 | Lint/MixedRegexpCaptureTypes: 187 | Enabled: false 188 | Lint/NestedPercentLiteral: 189 | Enabled: false 190 | Lint/NonDeterministicRequireOrder: 191 | Enabled: false 192 | Lint/OrderedMagicComments: 193 | Enabled: false 194 | Lint/OutOfRangeRegexpRef: 195 | Enabled: false 196 | Lint/RaiseException: 197 | Enabled: false 198 | Lint/RedundantCopEnableDirective: 199 | Enabled: false 200 | Lint/RedundantRequireStatement: 201 | Enabled: false 202 | Lint/RedundantSafeNavigation: 203 | Enabled: false 204 | Lint/RedundantWithIndex: 205 | Enabled: false 206 | Lint/RedundantWithObject: 207 | Enabled: false 208 | Lint/RegexpAsCondition: 209 | Enabled: false 210 | Lint/ReturnInVoidContext: 211 | Enabled: false 212 | Lint/SafeNavigationConsistency: 213 | Enabled: false 214 | Lint/SafeNavigationWithEmpty: 215 | Enabled: false 216 | Lint/SelfAssignment: 217 | Enabled: false 218 | Lint/SendWithMixinArgument: 219 | Enabled: false 220 | Lint/ShadowedArgument: 221 | Enabled: false 222 | Lint/StructNewOverride: 223 | Enabled: false 224 | Lint/ToJSON: 225 | Enabled: false 226 | Lint/TopLevelReturnWithArgument: 227 | Enabled: false 228 | Lint/TrailingCommaInAttributeDeclaration: 229 | Enabled: false 230 | Lint/UnreachableLoop: 231 | Enabled: false 232 | Lint/UriEscapeUnescape: 233 | Enabled: false 234 | Lint/UriRegexp: 235 | Enabled: false 236 | Lint/UselessMethodDefinition: 237 | Enabled: false 238 | Lint/UselessTimes: 239 | Enabled: false 240 | Metrics/AbcSize: 241 | Enabled: false 242 | Metrics/BlockLength: 243 | Enabled: false 244 | Metrics/BlockNesting: 245 | Enabled: false 246 | Metrics/ClassLength: 247 | Enabled: false 248 | Metrics/CyclomaticComplexity: 249 | Enabled: false 250 | Metrics/MethodLength: 251 | Enabled: false 252 | Metrics/ModuleLength: 253 | Enabled: false 254 | Metrics/ParameterLists: 255 | Enabled: false 256 | Metrics/PerceivedComplexity: 257 | Enabled: false 258 | Migration/DepartmentName: 259 | Enabled: false 260 | Naming/AccessorMethodName: 261 | Enabled: false 262 | Naming/BlockParameterName: 263 | Enabled: false 264 | Naming/HeredocDelimiterCase: 265 | Enabled: false 266 | Naming/HeredocDelimiterNaming: 267 | Enabled: false 268 | Naming/MemoizedInstanceVariableName: 269 | Enabled: false 270 | Naming/MethodParameterName: 271 | Enabled: false 272 | Naming/RescuedExceptionsVariableName: 273 | Enabled: false 274 | Naming/VariableNumber: 275 | Enabled: false 276 | Performance/BindCall: 277 | Enabled: false 278 | Performance/DeletePrefix: 279 | Enabled: false 280 | Performance/DeleteSuffix: 281 | Enabled: false 282 | Performance/InefficientHashSearch: 283 | Enabled: false 284 | Performance/UnfreezeString: 285 | Enabled: false 286 | Performance/UriDefaultParser: 287 | Enabled: false 288 | RSpec/Be: 289 | Enabled: false 290 | RSpec/Capybara/CurrentPathExpectation: 291 | Enabled: false 292 | RSpec/Capybara/FeatureMethods: 293 | Enabled: false 294 | RSpec/Capybara/VisibilityMatcher: 295 | Enabled: false 296 | RSpec/ContextMethod: 297 | Enabled: false 298 | RSpec/ContextWording: 299 | Enabled: false 300 | RSpec/DescribeClass: 301 | Enabled: false 302 | RSpec/EmptyHook: 303 | Enabled: false 304 | RSpec/EmptyLineAfterExample: 305 | Enabled: false 306 | RSpec/EmptyLineAfterExampleGroup: 307 | Enabled: false 308 | RSpec/EmptyLineAfterHook: 309 | Enabled: false 310 | RSpec/ExampleLength: 311 | Enabled: false 312 | RSpec/ExampleWithoutDescription: 313 | Enabled: false 314 | RSpec/ExpectChange: 315 | Enabled: false 316 | RSpec/ExpectInHook: 317 | Enabled: false 318 | RSpec/FactoryBot/AttributeDefinedStatically: 319 | Enabled: false 320 | RSpec/FactoryBot/CreateList: 321 | Enabled: false 322 | RSpec/FactoryBot/FactoryClassName: 323 | Enabled: false 324 | RSpec/HooksBeforeExamples: 325 | Enabled: false 326 | RSpec/ImplicitBlockExpectation: 327 | Enabled: false 328 | RSpec/ImplicitSubject: 329 | Enabled: false 330 | RSpec/LeakyConstantDeclaration: 331 | Enabled: false 332 | RSpec/LetBeforeExamples: 333 | Enabled: false 334 | RSpec/MissingExampleGroupArgument: 335 | Enabled: false 336 | RSpec/MultipleExpectations: 337 | Enabled: false 338 | RSpec/MultipleMemoizedHelpers: 339 | Enabled: false 340 | RSpec/MultipleSubjects: 341 | Enabled: false 342 | RSpec/NestedGroups: 343 | Enabled: false 344 | RSpec/PredicateMatcher: 345 | Enabled: false 346 | RSpec/ReceiveCounts: 347 | Enabled: false 348 | RSpec/ReceiveNever: 349 | Enabled: false 350 | RSpec/RepeatedExampleGroupBody: 351 | Enabled: false 352 | RSpec/RepeatedExampleGroupDescription: 353 | Enabled: false 354 | RSpec/RepeatedIncludeExample: 355 | Enabled: false 356 | RSpec/ReturnFromStub: 357 | Enabled: false 358 | RSpec/SharedExamples: 359 | Enabled: false 360 | RSpec/StubbedMock: 361 | Enabled: false 362 | RSpec/UnspecifiedException: 363 | Enabled: false 364 | RSpec/VariableDefinition: 365 | Enabled: false 366 | RSpec/VoidExpect: 367 | Enabled: false 368 | RSpec/Yield: 369 | Enabled: false 370 | Security/Open: 371 | Enabled: false 372 | Style/AccessModifierDeclarations: 373 | Enabled: false 374 | Style/AccessorGrouping: 375 | Enabled: false 376 | Style/AsciiComments: 377 | Enabled: false 378 | Style/BisectedAttrAccessor: 379 | Enabled: false 380 | Style/CaseLikeIf: 381 | Enabled: false 382 | Style/ClassEqualityComparison: 383 | Enabled: false 384 | Style/ColonMethodDefinition: 385 | Enabled: false 386 | Style/CombinableLoops: 387 | Enabled: false 388 | Style/CommentedKeyword: 389 | Enabled: false 390 | Style/Dir: 391 | Enabled: false 392 | Style/DoubleCopDisableDirective: 393 | Enabled: false 394 | Style/EmptyBlockParameter: 395 | Enabled: false 396 | Style/EmptyLambdaParameter: 397 | Enabled: false 398 | Style/Encoding: 399 | Enabled: false 400 | Style/EvalWithLocation: 401 | Enabled: false 402 | Style/ExpandPathArguments: 403 | Enabled: false 404 | Style/ExplicitBlockArgument: 405 | Enabled: false 406 | Style/ExponentialNotation: 407 | Enabled: false 408 | Style/FloatDivision: 409 | Enabled: false 410 | Style/FrozenStringLiteralComment: 411 | Enabled: false 412 | Style/GlobalStdStream: 413 | Enabled: false 414 | Style/HashAsLastArrayItem: 415 | Enabled: false 416 | Style/HashLikeCase: 417 | Enabled: false 418 | Style/HashTransformKeys: 419 | Enabled: false 420 | Style/HashTransformValues: 421 | Enabled: false 422 | Style/IfUnlessModifier: 423 | Enabled: false 424 | Style/KeywordParametersOrder: 425 | Enabled: false 426 | Style/MinMax: 427 | Enabled: false 428 | Style/MixinUsage: 429 | Enabled: false 430 | Style/MultilineWhenThen: 431 | Enabled: false 432 | Style/NegatedUnless: 433 | Enabled: false 434 | Style/NumericPredicate: 435 | Enabled: false 436 | Style/OptionalBooleanParameter: 437 | Enabled: false 438 | Style/OrAssignment: 439 | Enabled: false 440 | Style/RandomWithOffset: 441 | Enabled: false 442 | Style/RedundantAssignment: 443 | Enabled: false 444 | Style/RedundantCondition: 445 | Enabled: false 446 | Style/RedundantConditional: 447 | Enabled: false 448 | Style/RedundantFetchBlock: 449 | Enabled: false 450 | Style/RedundantFileExtensionInRequire: 451 | Enabled: false 452 | Style/RedundantRegexpCharacterClass: 453 | Enabled: false 454 | Style/RedundantRegexpEscape: 455 | Enabled: false 456 | Style/RedundantSelfAssignment: 457 | Enabled: false 458 | Style/RedundantSort: 459 | Enabled: false 460 | Style/RescueStandardError: 461 | Enabled: false 462 | Style/SingleArgumentDig: 463 | Enabled: false 464 | Style/SlicingWithRange: 465 | Enabled: false 466 | Style/SoleNestedConditional: 467 | Enabled: false 468 | Style/StderrPuts: 469 | Enabled: false 470 | Style/StringConcatenation: 471 | Enabled: false 472 | Style/Strip: 473 | Enabled: false 474 | Style/SymbolProc: 475 | Enabled: false 476 | Style/TrailingBodyOnClass: 477 | Enabled: false 478 | Style/TrailingBodyOnMethodDefinition: 479 | Enabled: false 480 | Style/TrailingBodyOnModule: 481 | Enabled: false 482 | Style/TrailingCommaInHashLiteral: 483 | Enabled: false 484 | Style/TrailingMethodEndStatement: 485 | Enabled: false 486 | Style/UnpackFirst: 487 | Enabled: false 488 | Lint/DuplicateBranch: 489 | Enabled: false 490 | Lint/DuplicateRegexpCharacterClassElement: 491 | Enabled: false 492 | Lint/EmptyBlock: 493 | Enabled: false 494 | Lint/EmptyClass: 495 | Enabled: false 496 | Lint/NoReturnInBeginEndBlocks: 497 | Enabled: false 498 | Lint/ToEnumArguments: 499 | Enabled: false 500 | Lint/UnexpectedBlockArity: 501 | Enabled: false 502 | Lint/UnmodifiedReduceAccumulator: 503 | Enabled: false 504 | Performance/CollectionLiteralInLoop: 505 | Enabled: false 506 | Style/ArgumentsForwarding: 507 | Enabled: false 508 | Style/CollectionCompact: 509 | Enabled: false 510 | Style/DocumentDynamicEvalDefinition: 511 | Enabled: false 512 | Style/NegatedIfElseCondition: 513 | Enabled: false 514 | Style/NilLambda: 515 | Enabled: false 516 | Style/RedundantArgument: 517 | Enabled: false 518 | Style/SwapValues: 519 | Enabled: false 520 | -------------------------------------------------------------------------------- /tests/module/test/.sync.yml: -------------------------------------------------------------------------------- 1 | # This file can be used to customize the files managed by PDK. 2 | # 3 | # See https://github.com/puppetlabs/pdk-templates/blob/main/README.md 4 | # for more information. 5 | # 6 | # See https://github.com/puppetlabs/pdk-templates/blob/main/config_defaults.yml 7 | # for the default values. 8 | --- {} 9 | -------------------------------------------------------------------------------- /tests/module/test/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: linux 3 | dist: xenial 4 | language: ruby 5 | cache: bundler 6 | before_install: 7 | - bundle -v 8 | - rm -f Gemfile.lock 9 | - "# Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" 10 | - "# See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" 11 | - "# Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" 12 | - '[ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION' 13 | - gem --version 14 | - bundle -v 15 | script: 16 | - 'bundle exec rake $CHECK' 17 | bundler_args: --without system_tests 18 | rvm: 19 | - 2.5.7 20 | stages: 21 | - static 22 | - spec 23 | - acceptance 24 | - 25 | if: tag =~ ^v\d 26 | name: deploy 27 | jobs: 28 | fast_finish: true 29 | include: 30 | - 31 | env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" 32 | stage: static 33 | - 34 | env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec 35 | rvm: 2.5.7 36 | stage: spec 37 | - 38 | env: DEPLOY_TO_FORGE=yes 39 | stage: deploy 40 | branches: 41 | only: 42 | - main 43 | - /^v\d/ 44 | notifications: 45 | email: false 46 | -------------------------------------------------------------------------------- /tests/module/test/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "puppet.puppet-vscode", 4 | "rebornix.Ruby" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /tests/module/test/.yardopts: -------------------------------------------------------------------------------- 1 | --markup markdown 2 | -------------------------------------------------------------------------------- /tests/module/test/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## Release 0.1.0 6 | 7 | **Features** 8 | 9 | **Bugfixes** 10 | 11 | **Known Issues** 12 | -------------------------------------------------------------------------------- /tests/module/test/Gemfile: -------------------------------------------------------------------------------- 1 | source ENV['GEM_SOURCE'] || 'https://rubygems.org' 2 | 3 | def location_for(place_or_version, fake_version = nil) 4 | git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} 5 | file_url_regex = %r{\Afile:\/\/(?.*)} 6 | 7 | if place_or_version && (git_url = place_or_version.match(git_url_regex)) 8 | [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact 9 | elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) 10 | ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] 11 | else 12 | [place_or_version, { require: false }] 13 | end 14 | end 15 | 16 | ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments 17 | minor_version = ruby_version_segments[0..1].join('.') 18 | 19 | group :development do 20 | gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) 21 | gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) 22 | gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 2.8.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) 23 | gem "puppet-module-posix-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] 24 | gem "puppet-module-posix-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] 25 | gem "puppet-module-win-default-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] 26 | gem "puppet-module-win-dev-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] 27 | end 28 | group :system_tests do 29 | gem "puppet-module-posix-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:ruby] 30 | gem "puppet-module-win-system-r#{minor_version}", '~> 1.0', require: false, platforms: [:mswin, :mingw, :x64_mingw] 31 | end 32 | 33 | puppet_version = ENV['PUPPET_GEM_VERSION'] 34 | facter_version = ENV['FACTER_GEM_VERSION'] 35 | hiera_version = ENV['HIERA_GEM_VERSION'] 36 | 37 | gems = {} 38 | 39 | gems['puppet'] = location_for(puppet_version) 40 | 41 | # If facter or hiera versions have been specified via the environment 42 | # variables 43 | 44 | gems['facter'] = location_for(facter_version) if facter_version 45 | gems['hiera'] = location_for(hiera_version) if hiera_version 46 | 47 | gems.each do |gem_name, gem_params| 48 | gem gem_name, *gem_params 49 | end 50 | 51 | # Evaluate Gemfile.local and ~/.gemfile if they exist 52 | extra_gemfiles = [ 53 | "#{__FILE__}.local", 54 | File.join(Dir.home, '.gemfile'), 55 | ] 56 | 57 | extra_gemfiles.each do |gemfile| 58 | if File.file?(gemfile) && File.readable?(gemfile) 59 | eval(File.read(gemfile), binding) 60 | end 61 | end 62 | # vim: syntax=ruby 63 | -------------------------------------------------------------------------------- /tests/module/test/README.md: -------------------------------------------------------------------------------- 1 | # test 2 | 3 | Welcome to your new module. A short overview of the generated parts can be found 4 | in the [PDK documentation][1]. 5 | 6 | The README template below provides a starting point with details about what 7 | information to include in your README. 8 | 9 | ## Table of Contents 10 | 11 | 1. [Description](#description) 12 | 1. [Setup - The basics of getting started with test](#setup) 13 | * [What test affects](#what-test-affects) 14 | * [Setup requirements](#setup-requirements) 15 | * [Beginning with test](#beginning-with-test) 16 | 1. [Usage - Configuration options and additional functionality](#usage) 17 | 1. [Limitations - OS compatibility, etc.](#limitations) 18 | 1. [Development - Guide for contributing to the module](#development) 19 | 20 | ## Description 21 | 22 | Briefly tell users why they might want to use your module. Explain what your 23 | module does and what kind of problems users can solve with it. 24 | 25 | This should be a fairly short description helps the user decide if your module 26 | is what they want. 27 | 28 | ## Setup 29 | 30 | ### What test affects **OPTIONAL** 31 | 32 | If it's obvious what your module touches, you can skip this section. For 33 | example, folks can probably figure out that your mysql_instance module affects 34 | their MySQL instances. 35 | 36 | If there's more that they should know about, though, this is the place to 37 | mention: 38 | 39 | * Files, packages, services, or operations that the module will alter, impact, 40 | or execute. 41 | * Dependencies that your module automatically installs. 42 | * Warnings or other important notices. 43 | 44 | ### Setup Requirements **OPTIONAL** 45 | 46 | If your module requires anything extra before setting up (pluginsync enabled, 47 | another module, etc.), mention it here. 48 | 49 | If your most recent release breaks compatibility or requires particular steps 50 | for upgrading, you might want to include an additional "Upgrading" section here. 51 | 52 | ### Beginning with test 53 | 54 | The very basic steps needed for a user to get the module up and running. This 55 | can include setup steps, if necessary, or it can be an example of the most basic 56 | use of the module. 57 | 58 | ## Usage 59 | 60 | Include usage examples for common use cases in the **Usage** section. Show your 61 | users how to use your module to solve problems, and be sure to include code 62 | examples. Include three to five examples of the most important or common tasks a 63 | user can accomplish with your module. Show users how to accomplish more complex 64 | tasks that involve different types, classes, and functions working in tandem. 65 | 66 | ## Reference 67 | 68 | This section is deprecated. Instead, add reference information to your code as 69 | Puppet Strings comments, and then use Strings to generate a REFERENCE.md in your 70 | module. For details on how to add code comments and generate documentation with 71 | Strings, see the [Puppet Strings documentation][2] and [style guide][3]. 72 | 73 | If you aren't ready to use Strings yet, manually create a REFERENCE.md in the 74 | root of your module directory and list out each of your module's classes, 75 | defined types, facts, functions, Puppet tasks, task plans, and resource types 76 | and providers, along with the parameters for each. 77 | 78 | For each element (class, defined type, function, and so on), list: 79 | 80 | * The data type, if applicable. 81 | * A description of what the element does. 82 | * Valid values, if the data type doesn't make it obvious. 83 | * Default value, if any. 84 | 85 | For example: 86 | 87 | ``` 88 | ### `pet::cat` 89 | 90 | #### Parameters 91 | 92 | ##### `meow` 93 | 94 | Enables vocalization in your cat. Valid options: 'string'. 95 | 96 | Default: 'medium-loud'. 97 | ``` 98 | 99 | ## Limitations 100 | 101 | In the Limitations section, list any incompatibilities, known issues, or other 102 | warnings. 103 | 104 | ## Development 105 | 106 | In the Development section, tell other users the ground rules for contributing 107 | to your project and how they should submit their work. 108 | 109 | ## Release Notes/Contributors/Etc. **Optional** 110 | 111 | If you aren't using changelog, put your release notes here (though you should 112 | consider using changelog). You can also add any additional sections you feel are 113 | necessary or important to include here. Please use the `##` header. 114 | 115 | [1]: https://puppet.com/docs/pdk/latest/pdk_generating_modules.html 116 | [2]: https://puppet.com/docs/puppet/latest/puppet_strings.html 117 | [3]: https://puppet.com/docs/puppet/latest/puppet_strings_style.html 118 | -------------------------------------------------------------------------------- /tests/module/test/Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'bundler' 4 | require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? 5 | require 'puppetlabs_spec_helper/rake_tasks' 6 | require 'puppet-syntax/tasks/puppet-syntax' 7 | require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? 8 | require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? 9 | require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? 10 | 11 | def changelog_user 12 | return unless Rake.application.top_level_tasks.include? "changelog" 13 | returnVal = nil || JSON.load(File.read('metadata.json'))['author'] 14 | raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? 15 | puts "GitHubChangelogGenerator user:#{returnVal}" 16 | returnVal 17 | end 18 | 19 | def changelog_project 20 | return unless Rake.application.top_level_tasks.include? "changelog" 21 | 22 | returnVal = nil 23 | returnVal ||= begin 24 | metadata_source = JSON.load(File.read('metadata.json'))['source'] 25 | metadata_source_match = metadata_source && metadata_source.match(%r{.*\/([^\/]*?)(?:\.git)?\Z}) 26 | 27 | metadata_source_match && metadata_source_match[1] 28 | end 29 | 30 | raise "unable to find the changelog_project in .sync.yml or calculate it from the source in metadata.json" if returnVal.nil? 31 | 32 | puts "GitHubChangelogGenerator project:#{returnVal}" 33 | returnVal 34 | end 35 | 36 | def changelog_future_release 37 | return unless Rake.application.top_level_tasks.include? "changelog" 38 | returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] 39 | raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? 40 | puts "GitHubChangelogGenerator future_release:#{returnVal}" 41 | returnVal 42 | end 43 | 44 | PuppetLint.configuration.send('disable_relative') 45 | 46 | if Bundler.rubygems.find_name('github_changelog_generator').any? 47 | GitHubChangelogGenerator::RakeTask.new :changelog do |config| 48 | 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? 49 | config.user = "#{changelog_user}" 50 | config.project = "#{changelog_project}" 51 | config.future_release = "#{changelog_future_release}" 52 | config.exclude_labels = ['maintenance'] 53 | 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)." 54 | config.add_pr_wo_labels = true 55 | config.issues = false 56 | config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" 57 | config.configure_sections = { 58 | "Changed" => { 59 | "prefix" => "### Changed", 60 | "labels" => ["backwards-incompatible"], 61 | }, 62 | "Added" => { 63 | "prefix" => "### Added", 64 | "labels" => ["enhancement", "feature"], 65 | }, 66 | "Fixed" => { 67 | "prefix" => "### Fixed", 68 | "labels" => ["bug", "documentation", "bugfix"], 69 | }, 70 | } 71 | end 72 | else 73 | desc 'Generate a Changelog from GitHub' 74 | task :changelog do 75 | raise < 1.15' 84 | condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" 85 | EOM 86 | end 87 | end 88 | 89 | -------------------------------------------------------------------------------- /tests/module/test/appveyor.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 1.1.x.{build} 3 | branches: 4 | only: 5 | - main 6 | - release 7 | skip_commits: 8 | message: /^\(?doc\)?.*/ 9 | clone_depth: 10 10 | init: 11 | - SET 12 | - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' 13 | - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' 14 | - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' 15 | - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' 16 | environment: 17 | matrix: 18 | - 19 | RUBY_VERSION: 25-x64 20 | CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop 21 | - 22 | PUPPET_GEM_VERSION: ~> 6.0 23 | RUBY_VERSION: 25 24 | CHECK: parallel_spec 25 | - 26 | PUPPET_GEM_VERSION: ~> 6.0 27 | RUBY_VERSION: 25-x64 28 | CHECK: parallel_spec 29 | matrix: 30 | fast_finish: true 31 | install: 32 | - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% 33 | - bundle install --jobs 4 --retry 2 --without system_tests 34 | - type Gemfile.lock 35 | build: off 36 | test_script: 37 | - bundle exec puppet -V 38 | - ruby -v 39 | - gem -v 40 | - bundle -v 41 | - bundle exec rake %CHECK% 42 | notifications: 43 | - provider: Email 44 | to: 45 | - nobody@nowhere.com 46 | on_build_success: false 47 | on_build_failure: false 48 | on_build_status_changed: false 49 | -------------------------------------------------------------------------------- /tests/module/test/data/common.yaml: -------------------------------------------------------------------------------- 1 | --- {} 2 | -------------------------------------------------------------------------------- /tests/module/test/hiera.yaml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /tests/module/test/manifests/defer.pp: -------------------------------------------------------------------------------- 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 test::defer 7 | class test::defer { 8 | notify { 'message': 9 | message => Deferred( 10 | 'inline_epp', 11 | [ 12 | 'VAULT_VALUE=<%= unwrap($secret) %>', 13 | {'secret'=> Sensitive('a thing') } 14 | ] 15 | ) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/module/test/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "puppet-test", 3 | "version": "0.1.0", 4 | "author": "Puppet", 5 | "summary": "", 6 | "license": "Apache-2.0", 7 | "source": "", 8 | "dependencies": [ 9 | 10 | ], 11 | "operatingsystem_support": [ 12 | { 13 | "operatingsystem": "CentOS", 14 | "operatingsystemrelease": [ 15 | "7" 16 | ] 17 | }, 18 | { 19 | "operatingsystem": "OracleLinux", 20 | "operatingsystemrelease": [ 21 | "7" 22 | ] 23 | }, 24 | { 25 | "operatingsystem": "RedHat", 26 | "operatingsystemrelease": [ 27 | "8" 28 | ] 29 | }, 30 | { 31 | "operatingsystem": "Scientific", 32 | "operatingsystemrelease": [ 33 | "7" 34 | ] 35 | }, 36 | { 37 | "operatingsystem": "Debian", 38 | "operatingsystemrelease": [ 39 | "10" 40 | ] 41 | }, 42 | { 43 | "operatingsystem": "Ubuntu", 44 | "operatingsystemrelease": [ 45 | "18.04" 46 | ] 47 | }, 48 | { 49 | "operatingsystem": "windows", 50 | "operatingsystemrelease": [ 51 | "2019", 52 | "10" 53 | ] 54 | } 55 | ], 56 | "requirements": [ 57 | { 58 | "name": "puppet", 59 | "version_requirement": ">= 6.21.0 < 8.0.0" 60 | } 61 | ], 62 | "pdk-version": "2.1.1", 63 | "template-url": "pdk-default#2.1.1", 64 | "template-ref": "tags/2.1.1-0-g03daa92" 65 | } 66 | -------------------------------------------------------------------------------- /tests/module/test/spec/classes/defer_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'test::defer' 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 | -------------------------------------------------------------------------------- /tests/module/test/spec/default_facts.yml: -------------------------------------------------------------------------------- 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: "172.16.254.254" 6 | ipaddress6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" 7 | is_pe: false 8 | macaddress: "AA:AA:AA:AA:AA:AA" 9 | -------------------------------------------------------------------------------- /tests/module/test/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RSpec.configure do |c| 4 | c.mock_with :rspec 5 | end 6 | 7 | require 'puppetlabs_spec_helper/module_spec_helper' 8 | require 'rspec-puppet-facts' 9 | 10 | require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) 11 | 12 | include RspecPuppetFacts 13 | 14 | default_facts = { 15 | puppetversion: Puppet.version, 16 | facterversion: Facter.version, 17 | } 18 | 19 | default_fact_files = [ 20 | File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), 21 | File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), 22 | ] 23 | 24 | default_fact_files.each do |f| 25 | next unless File.exist?(f) && File.readable?(f) && File.size?(f) 26 | 27 | begin 28 | default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) 29 | rescue => e 30 | RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" 31 | end 32 | end 33 | 34 | # read default_facts and merge them over what is provided by facterdb 35 | default_facts.each do |fact, value| 36 | add_custom_fact fact, value 37 | end 38 | 39 | RSpec.configure do |c| 40 | c.default_facts = default_facts 41 | c.before :each do 42 | # set to strictest setting for testing 43 | # by default Puppet runs at warning level 44 | Puppet.settings[:strict] = :warning 45 | Puppet.settings[:strict_variables] = true 46 | end 47 | c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] 48 | c.after(:suite) do 49 | end 50 | 51 | # Filter backtrace noise 52 | backtrace_exclusion_patterns = [ 53 | %r{spec_helper}, 54 | %r{gems}, 55 | ] 56 | 57 | if c.respond_to?(:backtrace_exclusion_patterns) 58 | c.backtrace_exclusion_patterns = backtrace_exclusion_patterns 59 | elsif c.respond_to?(:backtrace_clean_patterns) 60 | c.backtrace_clean_patterns = backtrace_exclusion_patterns 61 | end 62 | end 63 | 64 | # Ensures that a module is defined 65 | # @param module_name Name of the module 66 | def ensure_module_defined(module_name) 67 | module_name.split('::').reduce(Object) do |last_module, next_module| 68 | last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) 69 | last_module.const_get(next_module, false) 70 | end 71 | end 72 | 73 | # 'spec_overrides' from sync.yml will appear below this line 74 | -------------------------------------------------------------------------------- /tests/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | DOCKER_IMAGE=${1:-'puppet-dev-tools:latest'} 4 | 5 | function runtest() { 6 | title=$1 7 | cmd=$2 8 | expectedexit=$3 9 | greptext=$4 10 | 11 | #Colors 12 | YELLOW='\033[0;33m' 13 | RED='\033[0;31m' 14 | GREEN='\033[0;32m' 15 | NC='\033[0m' 16 | 17 | echo -e "${YELLOW}${title}${NC} should exit ${YELLOW}${expectedexit}${NC}... \c" 18 | 19 | output=$($cmd 2>&1) 20 | exitcode=$? 21 | 22 | if [ "$greptext" != "" ]; then 23 | echo -e $output | grep -q "$greptext" 24 | 25 | is_found=$? 26 | notfound=1 27 | 28 | if [ "$is_found" -eq "$notfound" ]; then 29 | echo -e "${RED}FAIL" 30 | echo -e "String not found: ${greptext}" 31 | echo -e $output 32 | echo -e "${NC}" 33 | exit 1 34 | fi 35 | fi 36 | 37 | if [ "$exitcode" -eq "$expectedexit" ]; then 38 | echo -e "${GREEN}PASS${NC}" 39 | else 40 | echo -e "${RED}FAIL" 41 | echo -e $output 42 | echo -e "${NC}" 43 | exit 1 44 | fi 45 | } 46 | 47 | runtest 'Puppetfile with bad syntax' "docker run -v `pwd`/control-repo/badsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile r10k:syntax" 1 'Puppetfile syntax check failed'; 48 | runtest 'Puppetfile with good syntax' "docker run -v `pwd`/control-repo/goodsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile r10k:syntax" 0 'Syntax OK'; 49 | 50 | runtest 'Templates with bad syntax' "docker run -v `pwd`/control-repo/badsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile syntax:templates" 1 "Syntax error at '' (file: site/profile/templates/bad_template.epp, line: 2, column: 23)"; 51 | runtest 'Templates with good syntax' "docker run -v `pwd`/control-repo/goodsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile syntax:templates" 0 ""; 52 | 53 | runtest 'Manifests with bad syntax' "docker run -v `pwd`/control-repo/badsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile syntax:manifests" 1 "Could not parse for environment \*root\*: Syntax error at 'SYNTAX' (file: /repo/site/profile/manifests/common.pp, line: 5, column: 12)"; 54 | runtest 'Manifests with good syntax' "docker run -v `pwd`/control-repo/goodsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile syntax:manifests" 0 ''; 55 | 56 | runtest 'Hiera with bad syntax' "docker run -v `pwd`/control-repo/badsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile syntax:hiera" 1 "ERROR: Failed to parse data/common.yaml: (data/common.yaml): could not find expected ':' while scanning a simple key at line 4 column 1"; 57 | runtest 'Hiera with good syntax' "docker run -v `pwd`/control-repo/goodsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile syntax:hiera" 0 ''; 58 | 59 | runtest 'Linting check catches errors' "docker run -v `pwd`/control-repo/badsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile lint syntax yamllint" 1 'site/profile/manifests/common.pp - WARNING: legacy fact on line 5'; 60 | runtest 'Linting check finds no errors' "docker run -v `pwd`/control-repo/goodsyntax:/repo ${DOCKER_IMAGE} rake -f /Rakefile lint syntax yamllint" 0 ''; 61 | 62 | runtest 'rspec-puppet passes Deferred unwrap test' "docker run -v `pwd`/module/test:/repo ${DOCKER_IMAGE} pdk test unit --tests spec/classes/defer_spec.rb --clean-fixtures" 0 63 | -------------------------------------------------------------------------------- /update_readme.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | DOCKER_IMAGE=${1:-'puppet-dev-tools:latest'} 6 | 7 | if [ $(which gsed) ]; then 8 | # workaround for macOS. 9 | # Installed via brew install gnu-sed 10 | gsed -i '/### Rake Tasks/,$d' README.md 11 | else 12 | sed -i '/### Rake Tasks/,$d' README.md 13 | fi 14 | 15 | echo '### Rake Tasks' >> README.md 16 | echo >> README.md 17 | echo '| Command | Description |' >> README.md 18 | echo '| ------- | ----------- |' >> README.md 19 | while read -r line; do 20 | f1=$(echo $line |cut -d '#' -f1) 21 | f2=$(echo $line |cut -d '#' -f2-) 22 | echo "| $f1 | $f2 |" >> README.md 23 | done < <(docker run --rm ${DOCKER_IMAGE} rake -f /Rakefile -T |tr -s ' ') 24 | --------------------------------------------------------------------------------