diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78fd6d52e..ed2985662 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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" @@ -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: @@ -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 }} @@ -94,8 +108,6 @@ jobs: - "almalinux-9" - "debian-11" - "debian-12" - - "rockylinux-8" - - "rockylinux-9" - "ubuntu-2004" - "ubuntu-2204" - "ubuntu-2404" @@ -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 diff --git a/kitchen.yml b/kitchen.yml index e91e54e22..da4f85026 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -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] @@ -72,7 +54,6 @@ suites: ################## # resource testing ################## - - name: resources provisioner: enforce_idempotency: false diff --git a/resources/installation_package.rb b/resources/installation_package.rb index c6c640375..d95fc4e19 100644 --- a/resources/installation_package.rb +++ b/resources/installation_package.rb @@ -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 @@ -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? @@ -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 diff --git a/resources/installation_script.rb b/resources/installation_script.rb index e564485e7..63ff4a11b 100644 --- a/resources/installation_script.rb +++ b/resources/installation_script.rb @@ -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 diff --git a/resources/swarm_service.rb b/resources/swarm_service.rb index 9c8935cd3..c27305828 100644 --- a/resources/swarm_service.rb +++ b/resources/swarm_service.rb @@ -74,12 +74,6 @@ end action_class do - def service_exists?(new_resource) - cmd = Mixlib::ShellOut.new("docker service inspect #{new_resource.service_name}") - cmd.run_command - !cmd.error? - end - def create_service_cmd(new_resource) cmd = %w(docker service create) cmd << "--name #{new_resource.service_name}" diff --git a/resources/swarm_token.rb b/resources/swarm_token.rb index 89ef50f74..5cbb08871 100644 --- a/resources/swarm_token.rb +++ b/resources/swarm_token.rb @@ -8,9 +8,9 @@ property :token_type, String, name_property: true, equal_to: %w(worker manager) property :rotate, [true, false], default: false -load_current_value do |_new_resource| +load_current_value do |new_resource| if swarm_manager? - cmd = Mixlib::ShellOut.new("docker swarm join-token -q #{new_resourcetoken_type}") + cmd = Mixlib::ShellOut.new("docker swarm join-token -q #{new_resource.token_type}") cmd.run_command current_value_does_not_exist! if cmd.error? else