Skip to content

Commit

Permalink
Add none as an option to service_manager to allow using the system de…
Browse files Browse the repository at this point in the history
…faults (#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 <lance@osuosl.org>

* Fix CI

Signed-off-by: Lance Albertson <lance@osuosl.org>

* CI Fixes

Signed-off-by: Lance Albertson <lance@osuosl.org>

* Update spec tests

Signed-off-by: Lance Albertson <lance@osuosl.org>

* Update platforms for vagrant smoke tests

Signed-off-by: Lance Albertson <lance@osuosl.org>

* Update kitchen.yml

Co-authored-by: Corey Hemminger <hemminger@hotmail.com>

---------

Signed-off-by: Lance Albertson <lance@osuosl.org>
Co-authored-by: Corey Hemminger <hemminger@hotmail.com>
  • Loading branch information
ramereth and Stromweld committed Aug 3, 2024
1 parent 73f1447 commit ed04d64
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 69 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
21 changes: 7 additions & 14 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 4 additions & 1 deletion resources/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions spec/docker_test/installation_package_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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(
Expand Down
12 changes: 0 additions & 12 deletions test/cookbooks/docker_test/recipes/installation_package.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ed04d64

Please sign in to comment.