diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..12ed4ff1 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM puppet/pdk:latest + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..f1a55dc3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet +{ + "name": "Puppet Development Kit (Community)", + "dockerFile": "Dockerfile", + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "puppet.puppet-vscode", + "rebornix.Ruby" + ] + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pdk --version", +} diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 49554d91..100430f7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -3,13 +3,13 @@ BEFORE YOU CREATE A PULL REQUEST: Ensure you have read over -CONTRIBUTING - https://github.com/puppetlabs/puppetlabs-powershell/blob/master/CONTRIBUTING.md +CONTRIBUTING - https://github.com/puppetlabs/puppetlabs-powershell/blob/main/CONTRIBUTING.md We provide defined guidance (as such, we strongly adhere to it). A summary of our expectations: - A ticket was created at https://tickets.puppetlabs.com/secure/CreateIssueDetails!init.jspa?pid=10707&issuetype=1&components=12015&summary=%5BPOWERSHELL%5D%20, or you have an existing ticket # - - You are not submitting a pull request from your MASTER branch. + - You are not submitting a pull request from your MAIN branch. - The first line of your git commit message has the ticket # and a short summary of the fix, followed by a detailed explanation of the fix in the git commit body. - Your git commit message format is important. We have a very defined expectation for this format and are keep to it. Really, READ the entire Contributing document. It will save you and us time. - Do not reformat code, it makes it hard to see what has changed. Leave the formatting to us. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dacc2ff7..43f4754e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Litmus Parallel - uses: puppetlabs/action-litmus_parallel@master + uses: puppetlabs/action-litmus_parallel@main with: platform: ${{ matrix.platform }} agent_family: ${{ matrix.agent_family }} @@ -37,7 +37,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Spec Tests - uses: puppetlabs/action-litmus_spec@master + uses: puppetlabs/action-litmus_spec@main with: puppet_gem_version: ${{ matrix.puppet_gem_version }} check: ${{ matrix.check }} diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 00000000..0814c5e6 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,18 @@ +FROM gitpod/workspace-full +RUN sudo wget https://apt.puppet.com/puppet-tools-release-bionic.deb && \ + wget https://apt.puppetlabs.com/puppet6-release-bionic.deb && \ + sudo dpkg -i puppet6-release-bionic.deb && \ + sudo dpkg -i puppet-tools-release-bionic.deb && \ + sudo apt-get update && \ + sudo apt-get install -y pdk zsh puppet-agent && \ + sudo apt-get clean && \ + sudo rm -rf /var/lib/apt/lists/* +RUN sudo usermod -s $(which zsh) gitpod && \ + sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ + echo "plugins=(git gitignore github gem pip bundler python ruby docker docker-compose)" >> /home/gitpod/.zshrc && \ + echo 'PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin"' >> /home/gitpod/.zshrc && \ + sudo /opt/puppetlabs/puppet/bin/gem install puppet-debugger hub -N && \ + mkdir -p /home/gitpod/.config/puppet && \ + /opt/puppetlabs/puppet/bin/ruby -r yaml -e "puts ({'disabled' => true}).to_yaml" > /home/gitpod/.config/puppet/analytics.yml +RUN rm -f puppet6-release-bionic.deb puppet-tools-release-bionic.deb +ENTRYPOINT /usr/bin/zsh diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..18406c50 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,9 @@ +image: + file: .gitpod.Dockerfile + +tasks: + - init: pdk bundle install + +vscode: + extensions: + - puppet.puppet-vscode@1.0.0:oSzfTkDf6Cmc1jOjgW33VA== diff --git a/.pdkignore b/.pdkignore index e6215cd0..254808c8 100644 --- a/.pdkignore +++ b/.pdkignore @@ -32,6 +32,7 @@ /.gitignore /.gitlab-ci.yml /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec @@ -40,3 +41,4 @@ /.yardopts /spec/ /.vscode/ +/.sync.yml diff --git a/.sync.yml b/.sync.yml index b0b21a79..d32702bb 100644 --- a/.sync.yml +++ b/.sync.yml @@ -13,6 +13,7 @@ use_litmus: true litmus: provision_list: + - ---travis_el - travis_deb - travis_ub - travis_el7 @@ -58,3 +59,7 @@ Gemfile: condition: Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2') spec/spec_helper.rb: coverage_report: true +.gitpod.Dockerfile: + unmanaged: false +.gitpod.yml: + unmanaged: false diff --git a/.travis.yml b/.travis.yml index 30150baf..dffd0cf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,22 +40,22 @@ jobs: stage: acceptance - before_script: - - "bundle exec rake 'litmus:provision_list[travis_el7]'" + - "bundle exec rake 'litmus:provision_list[travis_ub]'" - "bundle exec rake 'litmus:install_agent[puppet5]'" - "bundle exec rake litmus:install_module" bundler_args: - env: PLATFORMS=travis_el7_puppet5 + env: PLATFORMS=travis_ub_puppet5 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker stage: acceptance - before_script: - - "bundle exec rake 'litmus:provision_list[travis_ub]'" + - "bundle exec rake 'litmus:provision_list[travis_el7]'" - "bundle exec rake 'litmus:install_agent[puppet5]'" - "bundle exec rake litmus:install_module" bundler_args: - env: PLATFORMS=travis_ub_puppet5 + env: PLATFORMS=travis_el7_puppet5 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker @@ -73,22 +73,22 @@ jobs: stage: acceptance - before_script: - - "bundle exec rake 'litmus:provision_list[travis_el7]'" + - "bundle exec rake 'litmus:provision_list[travis_ub]'" - "bundle exec rake 'litmus:install_agent[puppet6]'" - "bundle exec rake litmus:install_module" bundler_args: - env: PLATFORMS=travis_el7_puppet6 + env: PLATFORMS=travis_ub_puppet6 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker stage: acceptance - before_script: - - "bundle exec rake 'litmus:provision_list[travis_ub]'" + - "bundle exec rake 'litmus:provision_list[travis_el7]'" - "bundle exec rake 'litmus:install_agent[puppet6]'" - "bundle exec rake litmus:install_module" bundler_args: - env: PLATFORMS=travis_ub_puppet6 + env: PLATFORMS=travis_el7_puppet6 rvm: 2.5.7 script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"] services: docker @@ -118,7 +118,7 @@ jobs: stage: acceptance branches: only: - - master + - main - /^v\d/ notifications: email: false diff --git a/CHANGELOG.md b/CHANGELOG.md index e2a48ba5..5398545f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -218,7 +218,7 @@ All notable changes to this project will be documented in this file. The format - Fixed issue with metadata and PE version requirement -[Unreleased]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.3.0...master +[Unreleased]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.3.0...main [2.3.0]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.2.0...2.3.0 [2.2.0]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.1.5...2.2.0 [2.1.5]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.1.4...2.1.5 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a9fb3a5..9c171f99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,7 +108,7 @@ process as easy as possible. To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of - directly on "master". + directly on "main". It makes things much easier to keep track of, especially if you decide to work on another thing before your first change is merged in. diff --git a/Gemfile b/Gemfile index 3378919b..1202a551 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,7 @@ group :development do gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) 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)) + 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)) gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] diff --git a/HISTORY.md b/HISTORY.md index f1b53983..2c4bdfc1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -177,7 +177,7 @@ - Fixed issue with metadata and PE version requirement -[Unreleased]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.3.0...master +[Unreleased]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.3.0...main [2.3.0]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.2.0...2.3.0 [2.2.0]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.1.5...2.2.0 [2.1.5]: https://github.com/puppetlabs/puppetlabs-powershell/compare/2.1.4...2.1.5 diff --git a/Rakefile b/Rakefile index cb7ed0cc..0a5093b3 100644 --- a/Rakefile +++ b/Rakefile @@ -52,7 +52,7 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? 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)." config.add_pr_wo_labels = true config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" + config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB" config.configure_sections = { "Changed" => { "prefix" => "### Changed", @@ -60,11 +60,11 @@ if Bundler.rubygems.find_name('github_changelog_generator').any? }, "Added" => { "prefix" => "### Added", - "labels" => ["feature", "enhancement"], + "labels" => ["enhancement", "feature"], }, "Fixed" => { "prefix" => "### Fixed", - "labels" => ["bugfix"], + "labels" => ["bug", "documentation", "bugfix"], }, } end @@ -72,16 +72,15 @@ else desc 'Generate a Changelog from GitHub' task :changelog do raise <= Gem::Version.new('2.2.2')" + version: '~> 1.15' + condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')" EOM end end diff --git a/appveyor.yml b/appveyor.yml index e4f2e745..eb3dcfbf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ version: 1.1.x.{build} branches: only: - - master + - main - release skip_commits: message: /^\(?doc\)?.*/ diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 00000000..2fbf0ffd --- /dev/null +++ b/data/common.yaml @@ -0,0 +1 @@ +--- {} diff --git a/hiera.yaml b/hiera.yaml new file mode 100644 index 00000000..545fff32 --- /dev/null +++ b/hiera.yaml @@ -0,0 +1,21 @@ +--- +version: 5 + +defaults: # Used for any hierarchy level that omits these keys. + datadir: data # This path is relative to hiera.yaml's directory. + data_hash: yaml_data # Use the built-in YAML backend. + +hierarchy: + - name: "osfamily/major release" + paths: + # Used to distinguish between Debian and Ubuntu + - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" + - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" + # Used for Solaris + - "os/%{facts.os.family}/%{facts.kernelrelease}.yaml" + - name: "osfamily" + paths: + - "os/%{facts.os.name}.yaml" + - "os/%{facts.os.family}.yaml" + - name: 'common' + path: 'common.yaml' diff --git a/lib/puppet/provider/exec/powershell.rb b/lib/puppet/provider/exec/powershell.rb index 881fd4ab..3fab17fa 100644 --- a/lib/puppet/provider/exec/powershell.rb +++ b/lib/puppet/provider/exec/powershell.rb @@ -45,9 +45,9 @@ def self.upgrade_message @upgrade_warning_issued = true end - def ps_manager + def ps_manager(pipe_timeout) debug_output = Puppet::Util::Log.level == :debug - Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args, debug: debug_output) + Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args, debug: debug_output, pipe_timeout: pipe_timeout) end def run(command, check = false) @@ -77,7 +77,7 @@ def execute_resource(powershell_code, resource) timeout_ms = resource[:timeout].nil? ? nil : resource[:timeout] * 1000 environment_variables = resource[:environment].nil? ? [] : resource[:environment] - result = ps_manager.execute(powershell_code, timeout_ms, working_dir, environment_variables) + result = ps_manager(resource[:timeout]).execute(powershell_code, timeout_ms, working_dir, environment_variables) stdout = result[:stdout] native_out = result[:native_stdout] stderr = result[:stderr] diff --git a/lib/puppet/provider/exec/pwsh.rb b/lib/puppet/provider/exec/pwsh.rb index 4ebc859b..f51dbcb1 100644 --- a/lib/puppet/provider/exec/pwsh.rb +++ b/lib/puppet/provider/exec/pwsh.rb @@ -68,9 +68,9 @@ def pwsh_args # # @api private # @return [Pwsh::Manager] The PowerShell manager for this resource - def ps_manager + def ps_manager(pipe_timeout) debug_output = Puppet::Util::Log.level == :debug - Pwsh::Manager.instance(@pwsh, pwsh_args, debug: debug_output) + Pwsh::Manager.instance(@pwsh, pwsh_args, debug: debug_output, pipe_timeout: pipe_timeout) end def execute_resource(powershell_code, resource) @@ -81,7 +81,7 @@ def execute_resource(powershell_code, resource) timeout_ms = resource[:timeout].nil? ? nil : resource[:timeout] * 1000 environment_variables = resource[:environment].nil? ? [] : resource[:environment] - result = ps_manager.execute(powershell_code, timeout_ms, working_dir, environment_variables) + result = ps_manager(resource[:timeout]).execute(powershell_code, timeout_ms, working_dir, environment_variables) stdout = result[:stdout] native_out = result[:native_stdout] stderr = result[:stderr] diff --git a/metadata.json b/metadata.json index 55595cde..3ee145cb 100644 --- a/metadata.json +++ b/metadata.json @@ -80,7 +80,7 @@ "version_requirement": ">= 5.5.0 < 7.0.0" } ], - "pdk-version": "1.18.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#master", - "template-ref": "heads/master-0-g9c14433" + "pdk-version": "1.18.1", + "template-url": "https://github.com/puppetlabs/pdk-templates#main", + "template-ref": "heads/main-0-g874030e" } diff --git a/provision.yaml b/provision.yaml index 99bc1752..cc86b647 100644 --- a/provision.yaml +++ b/provision.yaml @@ -1,22 +1,57 @@ --- default: provisioner: docker - images: ['waffleimage/ubuntu18.04', 'waffleimage/centos7'] + images: + - waffleimage/ubuntu18.04 + - waffleimage/centos7 vagrant: provisioner: vagrant - images: ['centos/7', 'generic/ubuntu1804', 'generic/debian8', 'gusztavvargadr/windows-server'] + images: + - centos/7 + - generic/ubuntu1804 + - generic/debian8 + - gusztavvargadr/windows-server travis_deb: - provisioner: docker - images: ['litmusimage/debian:8', 'litmusimage/debian:9', 'litmusimage/debian:10'] + provisioner: docker + images: + - litmusimage/debian:8 + - litmusimage/debian:9 + - litmusimage/debian:10 travis_ub: - provisioner: docker - images: ['litmusimage/ubuntu:16.04', 'litmusimage/ubuntu:18.04'] -travis_el6: - provisioner: docker - images: [] + provisioner: docker + images: + - litmusimage/ubuntu:16.04 + - litmusimage/ubuntu:18.04 travis_el7: - provisioner: docker - images: ['litmusimage/centos:7'] + provisioner: docker + images: + - litmusimage/centos:7 release_checks: provisioner: abs - images: ['redhat-7-x86_64', 'redhat-8-x86_64', 'centos-7-x86_64', 'centos-8-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'debian-10-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'win-2012r2-x86_64', 'win-2016-core-x86_64', 'win-2019-core-x86_64'] + images: + - redhat-7-x86_64 + - redhat-8-x86_64 + - centos-7-x86_64 + - centos-8-x86_64 + - debian-8-x86_64 + - debian-9-x86_64 + - debian-10-x86_64 + - ubuntu-1604-x86_64 + - ubuntu-1804-x86_64 + - win-2012r2-x86_64 + - win-2016-core-x86_64 + - win-2019-core-x86_64 +release_checks_7: + provisioner: abs + images: + - win-2012r2-x86_64 + - win-2016-core-x86_64 + - win-2019-core-x86_64 + - win-10-pro-x86_64 + - centos-7-x86_64 + - centos-8-x86_64 + - debian-9-x86_64 + - debian-10-x86_64 + - redhat-7-x86_64 + - redhat-8-x86_64 + - ubuntu-1804-x86_64 diff --git a/spec/fixtures/scripts/install_pwsh/windows.ps1 b/spec/fixtures/scripts/install_pwsh/windows.ps1 index 19ce5caf..213cbd02 100644 --- a/spec/fixtures/scripts/install_pwsh/windows.ps1 +++ b/spec/fixtures/scripts/install_pwsh/windows.ps1 @@ -1,4 +1,5 @@ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +# Replace the below `master` reference when possible Invoke-WebRequest -Uri https://github.com/PowerShell/PowerShell/raw/master/tools/install-powershell.ps1 -UseBasicParsing -OutFile install-pwsh.ps1 & ./install-pwsh.ps1 -AddToPath