Skip to content

Commit

Permalink
Ignore Alma
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Webb <[email protected]>
  • Loading branch information
damacus committed Jan 29, 2025
1 parent f56909e commit e72f98a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 57 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@ jobs:
- centos-stream-10
- debian-11
- debian-12
- fedora-latest
- opensuse-leap-15
- oraclelinux-8
- oraclelinux-9
- ubuntu-2204
- ubuntu-2404
suite:
- "installation-script-main"
- "installation-script-test"
- "installation-package"
- "installation-tarball"
- "install-and-stop"
Expand All @@ -47,12 +41,32 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Install Chef
uses: ./.github/actions/chef-install
- name: Test Kitchen
uses: ./.github/actions/test-kitchen
with:
version: latest
kitchen-yaml: kitchen.dokken.yml
suite: ${{ matrix.suite }}
os: ${{ matrix.os }}
license-id: ${{ secrets.CHEF_LICENSE_KEY }}

installation-script:
needs: lint-unit
runs-on: ubuntu-22.04
strategy:
matrix:
os:
- centos-stream-9
- centos-stream-10
- debian-11
- debian-12
- ubuntu-2204
- ubuntu-2404
suite: ["installation-script"]
fail-fast: false
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Test Kitchen
uses: ./.github/actions/test-kitchen
with:
Expand All @@ -79,7 +93,7 @@ jobs:
- name: Test Kitchen
uses: ./.github/actions/test-kitchen
with:
kitchen-yaml: kitchen.dokken.yml
kitchen-yaml: kitchen.yml
suite: ${{ matrix.suite }}
os: ${{ matrix.os }}
license-id: ${{ secrets.CHEF_LICENSE_KEY }}
Expand All @@ -94,8 +108,6 @@ jobs:
- "almalinux-9"
- "debian-11"
- "debian-12"
- "rockylinux-8"
- "rockylinux-9"
- "ubuntu-2004"
- "ubuntu-2204"
- "ubuntu-2404"
Expand All @@ -118,7 +130,7 @@ jobs:
license-id: ${{ secrets.CHEF_LICENSE_KEY }}

final:
needs: [lint-unit, integration, swarm, smoke]
needs: [lint-unit, installation-script, integration, swarm, smoke]
runs-on: ubuntu-latest
steps:
- name: Complete
Expand Down
27 changes: 4 additions & 23 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,11 @@ platforms:
- name: ubuntu-24.04

suites:

###############################
# docker_installation resources
###############################
- name: installation_script_main
excludes:
- 'almalinux-8'
- 'amazonlinux-2'
- 'rockylinux-8'
attributes:
docker:
repo: 'main'
run_list:
- recipe[docker_test::installation_script]

- name: installation_script_test
- name: installation_script
excludes:
- 'almalinux-8'
- 'amazonlinux-2'
- 'rockylinux-8'
attributes:
docker:
repo: 'test'
- 'almalinux'
- 'amazonlinux'
- 'rockylinux-9'
run_list:
- recipe[docker_test::installation_script]

Expand All @@ -72,7 +54,6 @@ suites:
##################
# resource testing
##################

- name: resources
provisioner:
enforce_idempotency: false
Expand Down
15 changes: 14 additions & 1 deletion resources/installation_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

property :setup_docker_repo, [true, false], default: true, desired_state: false
property :repo_channel, String, default: 'stable'
property :package_name, String, default: 'docker-ce', desired_state: false
property :package_name, String, default: lazy {
if amazonlinux_2023? || fedora?
'docker'
else
'docker-ce'
end
}, desired_state: false
property :package_version, String, desired_state: false
property :version, String, desired_state: false
property :package_options, String, desired_state: false
Expand Down Expand Up @@ -82,6 +88,11 @@ def noble?
false
end

def amazonlinux_2023?
return true if platform?('amazon') && node['platform_version'] == '2023'
false
end

# https://github.com/chef/chef/issues/4103
def version_string(v)
return if v.nil?
Expand Down Expand Up @@ -160,6 +171,8 @@ def version_string(v)
node['kernel']['machine']
end

apt_update 'apt-transport-https'

package 'apt-transport-https'

apt_repository 'docker' do
Expand Down
30 changes: 10 additions & 20 deletions resources/installation_script.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
unified_mode true
use 'partial/_base'

resource_name :docker_installation_script
provides :docker_installation_script

provides :docker_installation, os: 'linux'

property :repo, %w(main test experimental), default: 'main', desired_state: false
property :script_url, String, default: lazy { default_script_url }, desired_state: false
property :repo, %w(stable test), default: 'stable', desired_state: false

default_action :create

#########################
# property helper methods
#########################

def default_script_url
"https://#{repo == 'main' ? 'get' : 'test'}.docker.com/"
end

#########
# Actions
#########

action :create do
raise 'Installation script not supported on AlmaLinux or Rocky Linux' if platform?('almalinux', 'rocky')

package 'curl' do
options '--allowerasing'
not_if 'rpm -q curl-minimal'
not_if { platform_family?('rhel') && shell_out('rpm -q curl-minimal').exitstatus.zero? }
end

execute 'download docker installation script' do
command 'curl -fsSL https://get.docker.com -o /opt/install-docker.sh'
creates '/opt/install-docker.sh'
end

execute 'install docker' do
command "curl -sSL #{new_resource.script_url} | sh"
command "sh /opt/install-docker.sh --channel #{new_resource.repo}"
creates '/usr/bin/docker'
end
end
Expand Down

0 comments on commit e72f98a

Please sign in to comment.