From ed04d64048a3d9e7899581e2fbf30f9ef8ba6c9a Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sat, 3 Aug 2024 10:11:31 -0700 Subject: [PATCH] Add none as an option to service_manager to allow using the system defaults (#1283) * Add none as an option to service_manager to allow using the system defaults This is needed if you're trying to use the system packages and not the upstream repository. This is useful for non-standard CPU architectures which might not have upstream support. Signed-off-by: Lance Albertson * Fix CI Signed-off-by: Lance Albertson * CI Fixes Signed-off-by: Lance Albertson * Update spec tests Signed-off-by: Lance Albertson * Update platforms for vagrant smoke tests Signed-off-by: Lance Albertson * Update kitchen.yml Co-authored-by: Corey Hemminger --------- Signed-off-by: Lance Albertson Co-authored-by: Corey Hemminger --- .github/workflows/ci.yml | 15 ++++++++---- CHANGELOG.md | 4 ++++ kitchen.yml | 21 ++++++----------- resources/service.rb | 5 +++- spec/docker_test/installation_package_spec.rb | 14 +++++------ .../recipes/installation_package.rb | 12 ---------- .../inspec/assert_functioning_spec.rb | 23 +++---------------- .../inspec/assert_functioning_spec.rb | 13 +++-------- 8 files changed, 38 insertions(+), 69 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4eedbb0d0..611665b10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,17 +100,16 @@ jobs: integration-smoke: needs: lint-unit - runs-on: macos-latest + runs-on: ubuntu-latest strategy: matrix: os: - "almalinux-8" - - "centos-7" - - "centos-stream-8" - - "debian-10" + - "almalinux-9" - "debian-11" + - "debian-12" - "rockylinux-8" - - "ubuntu-1804" + - "rockylinux-9" - "ubuntu-2004" - "ubuntu-2204" - "ubuntu-2404" @@ -121,6 +120,12 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + - name: Install VirtualBox & Vagrant + run: | + sudo apt update && sudo apt install virtualbox + wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + sudo apt update && sudo apt install vagrant - name: Install Chef uses: actionshub/chef-install@3.0.0 - name: Dokken diff --git a/CHANGELOG.md b/CHANGELOG.md index 649c31ba9..df6ebbe2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Add `none` as an option to `service_manager` to allow using the system defaults +- Switch to running vagrant+virtualbox on Ubuntu via nested virtualization for smoke tests +- Fix package installation tests + ## 11.4.2 - *2024-07-16* ## 11.4.1 - *2024-07-16* diff --git a/kitchen.yml b/kitchen.yml index ccf96395b..9c82c7648 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -8,32 +8,25 @@ driver: provisioner: name: chef_infra product_name: <%= ENV['CHEF_PRODUCT_NAME'] || 'chef' %> - product_version: <%= ENV['CHEF_VERSION'] || '17' %> + product_version: <%= ENV['CHEF_VERSION'] || 'latest' %> enforce_idempotency: true multiple_converge: 2 deprecations_as_errors: true + chef_license: accept-no-persist verifier: name: inspec platforms: - name: almalinux-8 - - name: amazonlinux-2 - - name: centos-7 - - name: debian-10 - # docker post-install script misbehaves on Debian 10 if systemd isn't completely started - # https://forums.docker.com/t/failed-to-load-listeners-no-sockets-found-via-socket-activation-make-sure-the-service-was-started-by-systemd/62505/11 - lifecycle: - pre_converge: - - remote: 'until systemctl --quiet is-active multi-user.target; do sleep 2; done' + - name: almalinux-9 - name: debian-11 - - name: fedora-latest + - name: debian-12 - name: rockylinux-8 - - name: ubuntu-18.04 - lifecycle: - pre_converge: - - remote: sudo apt update + - name: rockylinux-9 - name: ubuntu-20.04 + - name: ubuntu-22.04 + - name: ubuntu-24.04 suites: diff --git a/resources/service.rb b/resources/service.rb index 561b9cf1c..e81d3f900 100644 --- a/resources/service.rb +++ b/resources/service.rb @@ -9,7 +9,7 @@ # installation type and service_manager property :install_method, %w(script package tarball none auto), default: lazy { docker_install_method }, desired_state: false -property :service_manager, %w(execute systemd auto), default: 'auto', desired_state: false +property :service_manager, %w(execute systemd none auto), default: 'auto', desired_state: false # docker_installation_script property :repo, String, desired_state: false @@ -78,6 +78,9 @@ def svc_manager(&block) svc = docker_service_manager_execute(new_resource.name, &b) when 'systemd' svc = docker_service_manager_systemd(new_resource.name, &b) + when 'none' + Chef::Log.info('Skipping Docker Server Manager. Assuming it was handled previously.') + return end svc end diff --git a/spec/docker_test/installation_package_spec.rb b/spec/docker_test/installation_package_spec.rb index ac76900dc..aa9b6df68 100644 --- a/spec/docker_test/installation_package_spec.rb +++ b/spec/docker_test/installation_package_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe 'docker_test::installation_package' do - platform 'ubuntu', '18.04' + platform 'ubuntu' step_into :docker_installation_package cached(:subject) { chef_run } context 'Ubuntu: testing default action, default properties' do it 'installs docker' do - expect(chef_run).to create_docker_installation_package('default').with(version: '20.10.11') + expect(chef_run).to create_docker_installation_package('default') end it do @@ -23,7 +23,7 @@ context 'Ubuntu (aarch64): testing default action, default properties' do automatic_attributes['kernel']['machine'] = 'aarch64' it 'installs docker' do - expect(chef_run).to create_docker_installation_package('default').with(version: '20.10.11') + expect(chef_run).to create_docker_installation_package('default') end it do @@ -39,7 +39,7 @@ context 'Ubuntu (ppc64le): testing default action, default properties' do automatic_attributes['kernel']['machine'] = 'ppc64le' it 'installs docker' do - expect(chef_run).to create_docker_installation_package('default').with(version: '20.10.11') + expect(chef_run).to create_docker_installation_package('default') end it do @@ -53,10 +53,10 @@ end context 'CentOS: testing default action, default properties' do - platform 'centos', '8' + platform 'centos' cached(:subject) { chef_run } it 'installs docker' do - expect(chef_run).to create_docker_installation_package('default').with(version: '3:20.10.11') + expect(chef_run).to create_docker_installation_package('default') end it do expect(chef_run).to create_yum_repository('Docker').with( @@ -75,7 +75,7 @@ automatic_attributes['kernel']['machine'] = 's390x' it 'installs docker' do - expect(chef_run).to create_docker_installation_package('default').with(version: '3:20.10.11') + expect(chef_run).to create_docker_installation_package('default') end it do expect(chef_run).to create_yum_repository('Docker').with( diff --git a/test/cookbooks/docker_test/recipes/installation_package.rb b/test/cookbooks/docker_test/recipes/installation_package.rb index 7207c8e36..68483642b 100644 --- a/test/cookbooks/docker_test/recipes/installation_package.rb +++ b/test/cookbooks/docker_test/recipes/installation_package.rb @@ -1,15 +1,3 @@ -docker_ver = - # Include epoch on RHEL to fix idempotency issues - if platform_family?('rhel', 'fedora') - '3:20.10.11' - # Debian 9 does not include 20.10 - elsif platform?('debian') && node['platform_version'].to_i == 9 - '19.03.14' - else - '20.10.11' - end - docker_installation_package 'default' do - version docker_ver action :create end diff --git a/test/integration/install_and_stop/inspec/assert_functioning_spec.rb b/test/integration/install_and_stop/inspec/assert_functioning_spec.rb index 0088abdea..0ed68528d 100644 --- a/test/integration/install_and_stop/inspec/assert_functioning_spec.rb +++ b/test/integration/install_and_stop/inspec/assert_functioning_spec.rb @@ -1,23 +1,6 @@ -if os.name == 'debian' - describe command('/usr/bin/docker --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/27\.0\./) } - end -elsif os.name == 'amazon' && %w(2 2023).include?(os.release) - describe command('/usr/bin/docker --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/20\.10\./) } - end -elsif os.family == 'redhat' && os.release.to_i == 8 - describe command('/usr/bin/docker --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/26\.1\./) } - end -else - describe command('/usr/bin/docker --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/27\.0\./) } - end +describe command('/usr/bin/docker --version') do + its(:exit_status) { should eq 0 } + its('stdout') { should match(/2[0-9].[0-9]/) } end # NOTE: See https://github.com/sous-chefs/docker/pull/1194 diff --git a/test/integration/installation_package/inspec/assert_functioning_spec.rb b/test/integration/installation_package/inspec/assert_functioning_spec.rb index 337d8a715..1e9b8a828 100644 --- a/test/integration/installation_package/inspec/assert_functioning_spec.rb +++ b/test/integration/installation_package/inspec/assert_functioning_spec.rb @@ -1,11 +1,4 @@ -if os.family == 'redhat' && os.release.to_i == 8 - describe command('/usr/bin/docker --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/26\.1\./) } - end -else - describe command('/usr/bin/docker --version') do - its(:exit_status) { should eq 0 } - its(:stdout) { should match(/27\.1\./) } - end +describe command('/usr/bin/docker --version') do + its(:exit_status) { should eq 0 } + its(:stdout) { should match(/2[0-9]\.[0-9]+\./) } end