64 lines
1.6 KiB
Ruby
64 lines
1.6 KiB
Ruby
#
|
|
# Cookbook:: esh_docker
|
|
# Recipe:: service
|
|
#
|
|
# Copyright:: 2022, https://easyself.host
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
apt_package %w(
|
|
apt-transport-https
|
|
ca-certificates
|
|
curl
|
|
gnupg-agent
|
|
software-properties-common
|
|
lsb-release
|
|
)
|
|
|
|
directory '/etc/apt/keyrings' do
|
|
owner 'root'
|
|
group 'root'
|
|
mode '0755'
|
|
action :create
|
|
end
|
|
|
|
execute 'add docker gpg key' do
|
|
command <<~EOT
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
|
|
| gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
EOT
|
|
not_if { ::File.exist?('/etc/apt/keyrings/docker.gpg') }
|
|
action :run
|
|
end
|
|
|
|
execute 'add docker sources.list' do
|
|
command <<~EOT
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
|
> /etc/apt/sources.list.d/docker.list
|
|
EOT
|
|
notifies :update, 'apt_update', :immediately
|
|
not_if { ::File.exist?('/etc/apt/sources.list.d/docker.list') }
|
|
action :run
|
|
end
|
|
|
|
apt_update do
|
|
action :nothing
|
|
end
|
|
|
|
apt_package %w(
|
|
docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
)
|
|
|
|
service 'docker' do
|
|
action [:enable, :start]
|
|
end
|