From: Tom Hughes Date: Thu, 14 Jul 2022 11:38:22 +0000 (+0000) Subject: Get docker working in the test-kitchen environment X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/e261b6f728d5bfceb9a98d5e35b29915afd49035 Get docker working in the test-kitchen environment --- diff --git a/cookbooks/docker/recipes/default.rb b/cookbooks/docker/recipes/default.rb index 80fd15b3f..bfdc88a09 100644 --- a/cookbooks/docker/recipes/default.rb +++ b/cookbooks/docker/recipes/default.rb @@ -31,15 +31,21 @@ directory "/etc/docker" do mode "755" end +storage_driver = if kitchen? + "vfs" + else + "overlay2" + end + template "/etc/docker/daemon.json" do source "daemon.json.erb" owner "root" group "root" mode "644" + variables :storage_driver => storage_driver end service "docker" do action [:enable, :start] subscribes :restart, "template[/etc/docker/daemon.json]" - not_if { kitchen? } end diff --git a/cookbooks/docker/templates/default/daemon.json.erb b/cookbooks/docker/templates/default/daemon.json.erb index 5d18abccd..15f9d2eb2 100644 --- a/cookbooks/docker/templates/default/daemon.json.erb +++ b/cookbooks/docker/templates/default/daemon.json.erb @@ -4,5 +4,5 @@ "log-opts": { "max-size": "100m" }, - "storage-driver": "overlay2" + "storage-driver": "<%= @storage_driver %>" } diff --git a/test/integration/docker/serverspec/docker_spec.rb b/test/integration/docker/serverspec/docker_spec.rb new file mode 100644 index 000000000..de7c426d2 --- /dev/null +++ b/test/integration/docker/serverspec/docker_spec.rb @@ -0,0 +1,13 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("docker-ce") do + it { should be_installed } +end + +describe service("docker") do + it { should be_enabled } + it { should be_running } +end