]> git.openstreetmap.org Git - chef.git/commitdiff
Get docker working in the test-kitchen environment
authorTom Hughes <tom@compton.nu>
Thu, 14 Jul 2022 11:38:22 +0000 (11:38 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 14 Jul 2022 11:39:34 +0000 (11:39 +0000)
cookbooks/docker/recipes/default.rb
cookbooks/docker/templates/default/daemon.json.erb
test/integration/docker/serverspec/docker_spec.rb [new file with mode: 0644]

index 80fd15b3f6be34ac90b8a3776f50df9d1f984b2b..bfdc88a09c8ec018272b2bee0fef0b1d1f0f9a72 100644 (file)
@@ -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
index 5d18abccd26e6c68d9ad619c0f7d14b26a94bdd0..15f9d2eb2cfc81b747385e041c70b37a2530c96d 100644 (file)
@@ -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 (file)
index 0000000..de7c426
--- /dev/null
@@ -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