diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..c6a67e70 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,7 @@ +FROM mcr.microsoft.com/vscode/devcontainers/ruby:3 + +ENV DEBIAN_FRONTEND=noninteractive +RUN curl -L https://apt.puppet.com/puppet-tools-release-focal.deb -o /tmp/puppet-tools-release-focal.deb && \ + sudo dpkg -i /tmp/puppet-tools-release-focal.deb && \ + sudo apt-get update && \ + sudo apt-get install pdk \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..7c1501ee --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,7 @@ +{ + "build": { "dockerfile": "Dockerfile" }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + } +} \ No newline at end of file diff --git a/.fixtures.yml b/.fixtures.yml index ecb659a9..73c6493f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,8 +2,8 @@ fixtures: repositories: stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" concat: "https://github.com/puppetlabs/puppetlabs-concat.git" - augeasproviders_core: "https://github.com/hercules-team/augeasproviders_core.git" - augeasproviders_shellvar: "https://github.com/hercules-team/augeasproviders_shellvar.git" + augeasproviders_core: "https://github.com/voxpupuli/puppet-augeasproviders_core.git" + augeasproviders_shellvar: "https://github.com/voxpupuli/puppet-augeasproviders_shellvar.git" augeas_core: repo: "https://github.com/puppetlabs/puppetlabs-augeas_core.git" puppet_version: ">= 6.0.0" diff --git a/.github/workflows/test-suite.yaml b/.github/workflows/test-suite.yaml index 6f55e3da..0dec901b 100644 --- a/.github/workflows/test-suite.yaml +++ b/.github/workflows/test-suite.yaml @@ -7,20 +7,63 @@ on: branches: [ master ] jobs: - test-static: + test-static-current: strategy: fail-fast: false matrix: - puppet: [5.0, 6.0, 7.0] + puppet: [7.22.0] + ruby: [2.7.7, 3.0.5, 3.1.3] + + name: Static code analysis + runs-on: ubuntu-20.04 + permissions: + contents: read + + steps: + - uses: actions/checkout@v3 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + env: + PUPPET_VERSION: ${{ matrix.puppet }} + + - name: Run metadata lint + run: | + PUPPET_VERSION=${{ matrix.puppet }} bundle exec rake metadata_lint + + - name: Run puppet lint + run: | + PUPPET_VERSION=${{ matrix.puppet }} bundle exec rake lint + + - name: Run puppet syntax check + run: | + PUPPET_VERSION=${{ matrix.puppet }} bundle exec rake syntax + + - name: Run puppet rspec tests + run: | + PUPPET_VERSION=${{ matrix.puppet }} STRICT_VARIABLES=yes bundle exec rake spec + + - name: Run rubocop tests + run: | + PUPPET_VERSION=${{ matrix.puppet }} bundle exec rake rubocop + + test-static-old: + strategy: + fail-fast: false + matrix: + puppet: [5.5.22, 6.29.0] ruby: [2.5.9, 2.6.9] name: Static code analysis - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 permissions: contents: read steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -55,10 +98,10 @@ jobs: fail-fast: false matrix: puppet: [puppet6, puppet7] - beakerset: [ubuntu-18.04, ubuntu-20.04, centos-7, debian-10, debian-11] + beakerset: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, centos-7, debian-10, debian-11] name: Integration tests - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 permissions: contents: read @@ -68,7 +111,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 2.5.9 + ruby-version: 2.6.9 bundler-cache: true env: BEAKER_set: ${{ matrix.beakerset }} @@ -81,4 +124,4 @@ jobs: env: BEAKER_set: ${{ matrix.beakerset }} BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet }} - PUPPET_INSTALL_TYPE: agent \ No newline at end of file + PUPPET_INSTALL_TYPE: agent diff --git a/.rubocop.yml b/.rubocop.yml index 07a4c723..3456f542 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,8 @@ require: rubocop-rspec AllCops: - NewCops: enable - TargetRubyVersion: 2.5 + NewCops: disable + TargetRubyVersion: 2.6 Include: - '**/*.rb' Exclude: diff --git a/Gemfile b/Gemfile index d8d51210..e7652ea2 100644 --- a/Gemfile +++ b/Gemfile @@ -21,14 +21,14 @@ group :test do gem 'puppet-lint-unquoted_string-check', require: false gem 'puppet-lint-variable_contains_upcase', require: false gem 'puppet-lint-version_comparison-check', require: false - gem 'puppet-strings', require: false, git: 'https://github.com/puppetlabs/puppetlabs-strings.git', branch: 'main' + gem 'puppet-strings', require: false gem 'puppet-syntax', require: false gem 'puppetlabs_spec_helper', require: false gem 'semantic_puppet', require: false gem 'rake', require: false gem 'rspec', require: false gem 'rspec-core', require: false - gem 'rspec-puppet', require: false, git: 'https://github.com/rodjek/rspec-puppet.git' + gem 'rspec-puppet', require: false, git: 'https://github.com/puppetlabs/rspec-puppet.git' gem 'rspec-puppet-facts', require: false gem 'rspec-puppet-utils', require: false gem 'rubocop', require: false @@ -38,8 +38,6 @@ end group :development do gem 'guard-rake', require: false - gem 'travis', require: false - gem 'travis-lint', require: false end if RUBY_VERSION >= '2.3.0' diff --git a/Makefile b/Makefile index dfe883fa..8c6c1bc9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ ifneq ($(origin PUPPET_VERSION), undefined) puppet_version := ${PUPPET_VERSION} else - puppet_version := 7.0 + puppet_version := 7.20.0 endif ifneq ($(origin STRICT_VARIABLES), undefined) @@ -13,13 +13,15 @@ endif ifneq ($(origin RVM), undefined) rvm := ${RVM} else - rvm := 2.5.0 + rvm := 3.1.3 endif +export rvm_beaker := 2.6.9 + ifneq ($(origin BEAKER_set), undefined) beaker_set := ${BEAKER_set} else - beaker_set := ubuntu-20.04 + beaker_set := ubuntu-22.04 endif ifneq ($(origin PUPPET_collection), undefined) @@ -29,12 +31,12 @@ else endif DOCKER_CMD := docker run -it --rm -v $$(pwd):/puppet/module derdanne/rvm:$(rvm) /bin/bash -l -c -PREPARE := rm -f Gemfile.lock && $(DOCKER_CMD) "PUPPET_VERSION=$(puppet_version) bundle install --quiet --without system_tests development --path=vendor/bundle" +PREPARE := $(DOCKER_CMD) "PUPPET_VERSION=$(puppet_version)" bundle config set --local without 'system_tests development' path 'vendor/bundle' && rm -f Gemfile.lock && $(DOCKER_CMD) "PUPPET_VERSION=$(puppet_version) bundle install --quiet" -DOCKER_CMD_BEAKER := docker run --net host --privileged -it --rm -v $$(pwd):/puppet/module -v /var/run/docker.sock:/var/run/docker.sock derdanne/rvm:$(rvm) /bin/bash -l -c -PREPARE_BEAKER := rm -f Gemfile.lock && $(DOCKER_CMD) "bundle install --quiet --without system_tests development --path=vendor/bundle" +DOCKER_CMD_BEAKER := docker run --net host --privileged -it --rm -v $$(pwd):/puppet/module -v /var/run/docker.sock:/var/run/docker.sock derdanne/rvm:$(rvm_beaker) /bin/bash -l -c +PREPARE_BEAKER := rm -f Gemfile.lock && $(DOCKER_CMD_BEAKER) "bundle config set --local without 'system_tests development path 'vendor/bundle'' && bundle install --quiet" -VARIABLES := echo "PUPPET_VERSION=$(puppet_version), STRICT_VARIABLES=$(strict_variables), RVM=$(rvm)" +VARIABLES := echo "PUPPET_VERSION=$(puppet_version), STRICT_VARIABLES=$(strict_variables), RVM=$(rvm), RVM_BEAKER=$(rvm_beaker)" build: @cd spec/local-testing && docker build --squash --build-arg RUBY_VERSION=$(rvm) -t derdanne/rvm:$(rvm) . diff --git a/README.md b/README.md index 70ee748e..8ee4b42a 100644 --- a/README.md +++ b/README.md @@ -464,12 +464,12 @@ This will mount /data on client in /share/data. ##### `nfs_v4` Boolean. If set to true, this module will use nfs version 4 - for exporting and mounting nfs resources. + for exporting and mounting nfs resources. It defaults to true. ##### `nfs_v4_client` Boolean. If set to true, this module will use nfs version 4 for mounting nfs resources. If set to false it will use nfs - version 3 to mount nfs resources. It defaults to the setting of `nfs_v4` + version 3 to mount nfs resources. It defaults to true. ##### `exports_file` String. It defines the location of the file with the nfs export resources used diff --git a/manifests/functions/nfsv4_bindmount.pp b/manifests/functions/nfsv4_bindmount.pp index 5f479265..104386f5 100644 --- a/manifests/functions/nfsv4_bindmount.pp +++ b/manifests/functions/nfsv4_bindmount.pp @@ -33,7 +33,8 @@ $bind, $ensure = 'mounted', ) { - $expdir = "${nfs::server::nfs_v4_export_root}/${v4_export_name}" + $normalize_export_root = regsubst($nfs::server::nfs_v4_export_root, '/$', '') + $expdir = "${normalize_export_root}/${v4_export_name}" nfs::functions::mkdir { $expdir: ensure => $ensure, } diff --git a/manifests/params.pp b/manifests/params.pp index d1ec0eca..d6eba161 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -154,7 +154,7 @@ $server_service_name = 'nfs-kernel-server' $client_gssdopt_name = 'GSSDARGS' } - 'focal', 'bionic', 'focal': { + 'bionic', 'focal', 'jammy', 'kinetic': { $client_services = {'rpcbind' => {}} $client_gssd_service_name = { 'rpc-gssd' => { ensure => 'running', diff --git a/metadata.json b/metadata.json index cbda0b8f..46add175 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "derdanne-nfs", - "version": "2.1.8", + "version": "2.1.11", "source": "https://github.com/derdanne/puppet-nfs.git", "author": "derdanne", "license": "Apache-2.0", @@ -23,7 +23,8 @@ "14.04", "16.04", "18.04", - "20.04" + "20.04", + "22.04" ] }, { diff --git a/spec/acceptance/nodesets/ubuntu-22.04.yml b/spec/acceptance/nodesets/ubuntu-22.04.yml new file mode 100644 index 00000000..06760632 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-22.04.yml @@ -0,0 +1,28 @@ +HOSTS: + ubuntu-2204-x64: + platform: ubuntu-22.04-amd64 + hypervisor: docker + image: ubuntu:22.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + # ensure that upstart is booting correctly in the container + - 'apt-get update && apt-get install -y distro-info-data locales lsb-release && locale-gen en_US.UTF-8' + # for local development + - 'echo "MaxAuthTries 100" >> /etc/ssh/sshd_config' + # exportfs does not work on overlayfs - mounting local filesystem + mount_folders: + export: + host_path: .spec/fixtures/export + container_path: /export + data_folder: + host_path: .spec/fixtures/export/data_folder + container_path: /export/data_folder + homeexport: + host_path: .spec/fixtures/export/homeexport + container_path: /export/homeexport +CONFIG: + type: foss + trace_limit: 200 +... +# vim: syntax=yaml diff --git a/spec/classes/nfs_spec.rb b/spec/classes/nfs_spec.rb index eb6622b7..586963f4 100644 --- a/spec/classes/nfs_spec.rb +++ b/spec/classes/nfs_spec.rb @@ -4,7 +4,7 @@ describe 'nfs' do # supported_os = %w[Ubuntu_default Ubuntu_16.04 Debian_default Debian_8 RedHat_default RedHat_7 RedHat_75 RedHat_8 Gentoo SLES Archlinux] - supported_os = %w[Ubuntu_16.04 Ubuntu_18.04 Ubuntu_20.04 Debian_8 Debian_9 Debian_10 Debian_11 RedHat_default RedHat_7 RedHat_75 RedHat_8 Gentoo SLES] + supported_os = %w[Ubuntu_16.04 Ubuntu_18.04 Ubuntu_20.04 Ubuntu_22.04 Debian_8 Debian_9 Debian_10 Debian_11 RedHat_default RedHat_7 RedHat_75 RedHat_8 Gentoo SLES] supported_os.each do |os| context os do let(:default_facts) do @@ -144,6 +144,37 @@ client_rpcbind_config = '/etc/default/rpcbind' client_rpcbind_optname = 'OPTIONS' + when 'Ubuntu_22.04' + + let(:facts) do + default_facts.merge( + 'operatingsystem' => 'Ubuntu', + 'os' => { + 'family' => 'Debian', + 'distro' => { + 'codename' => 'focal' + }, + 'release' => { + 'major' => '20', + 'minor' => '04', + 'full' => '20.04' + } + } + ) + end + + server_service = 'nfs-kernel-server' + server_servicehelpers = '' + server_packages = %w[nfs-common nfs-kernel-server nfs4-acl-tools rpcbind] + client_services = %w[rpcbind] + client_nfs_vfour_services = %w[rpcbind] + client_packages = %w[nfs-common nfs4-acl-tools] + client_gssdopt_name = 'GSSDARGS' + defaults_file = '/etc/default/nfs-common' + idmapd_file = '/etc/idmapd.conf' + client_rpcbind_config = '/etc/default/rpcbind' + client_rpcbind_optname = 'OPTIONS' + when 'Debian_default' let(:facts) do diff --git a/spec/defines/client_mount_spec.rb b/spec/defines/client_mount_spec.rb index 065bbaaa..372d8cc3 100644 --- a/spec/defines/client_mount_spec.rb +++ b/spec/defines/client_mount_spec.rb @@ -13,12 +13,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -49,12 +49,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -85,12 +85,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -121,12 +121,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -158,12 +158,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -194,12 +194,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', diff --git a/spec/defines/server_export_spec.rb b/spec/defines/server_export_spec.rb index a762ea22..ed022024 100644 --- a/spec/defines/server_export_spec.rb +++ b/spec/defines/server_export_spec.rb @@ -13,12 +13,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -51,12 +51,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -87,12 +87,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -124,12 +124,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -160,12 +160,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', @@ -196,12 +196,12 @@ 'os' => { 'family' => 'Debian', 'distro' => { - 'codename' => 'xenial' + 'codename' => 'focal' }, 'release' => { - 'major' => '16', + 'major' => '20', 'minor' => '04', - 'full' => '16.04' + 'full' => '20.04' } }, 'concat_basedir' => '/tmp', diff --git a/spec/local-testing/Dockerfile b/spec/local-testing/Dockerfile index 71fd695e..990ed466 100644 --- a/spec/local-testing/Dockerfile +++ b/spec/local-testing/Dockerfile @@ -1,6 +1,6 @@ # Dockerfile used to build base image for projects using Python, Node, and Ruby. -FROM ubuntu:latest -MAINTAINER Daniel Klockenkaemper +FROM ubuntu:20.04 +LABEL MAINTAINER "Daniel Klockenkaemper" ARG RUBY_VERSION @@ -16,7 +16,8 @@ RUN apt-get update && \ # Install rvm, default ruby version and bundler. COPY .gemrc /puppet/module/.gemrc -RUN gpg2 -v --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB +RUN curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - +RUN curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - RUN curl -L https://get.rvm.io | /bin/bash -s stable && \ echo 'source /etc/profile.d/rvm.sh' >> /etc/profile && \ /bin/bash -l -c "rvm requirements;" && \