From 1737d89f2deaf1c38bb0e7272fa3e473c1a13c83 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Tue, 2 Apr 2024 17:54:01 +0100 Subject: [PATCH 1/1] podman: add volume support --- cookbooks/podman/recipes/default.rb | 1 + cookbooks/podman/resources/service.rb | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cookbooks/podman/recipes/default.rb b/cookbooks/podman/recipes/default.rb index 4c8257350..b29769c1f 100644 --- a/cookbooks/podman/recipes/default.rb +++ b/cookbooks/podman/recipes/default.rb @@ -21,6 +21,7 @@ package %w[ podman slirp4netns uidmap + fuse-overlayfs ] ruby_block "subuid-containers" do diff --git a/cookbooks/podman/resources/service.rb b/cookbooks/podman/resources/service.rb index dac8ee1c4..5b64f7806 100644 --- a/cookbooks/podman/resources/service.rb +++ b/cookbooks/podman/resources/service.rb @@ -26,6 +26,7 @@ property :description, String, :required => true property :image, String, :required => true property :ports, Hash property :environment, Hash, :default => {} +property :volume, Hash, :default => {} action :create do systemd_service new_resource.service do @@ -34,7 +35,7 @@ action :create do notify_access "all" environment "PODMAN_SYSTEMD_UNIT" => "%n" exec_start_pre "/bin/rm --force %t/%n.ctr-id" - exec_start "/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --userns=auto --label=io.containers.autoupdate=registry --pids-limit=-1 #{publish_options} #{environment_options} --rm --sdnotify=conmon --detach --replace --name=%N #{new_resource.image}" + exec_start "/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --userns=auto --label=io.containers.autoupdate=registry --pids-limit=-1 #{publish_options} #{environment_options} #{volume_options} --rm --sdnotify=conmon --detach --replace --name=%N #{new_resource.image}" exec_stop "/usr/bin/podman stop --ignore --time=10 --cidfile=%t/%n.ctr-id" exec_stop_post "/usr/bin/podman rm --force --ignore --cidfile=%t/%n.ctr-id" timeout_start_sec 180 @@ -80,4 +81,10 @@ action_class do "-e '#{key}=#{value}'" end.join(" ") end + + def volume_options + new_resource.volume.collect do |key, value| + "-v '#{key}:#{value}'" + end.join(" ") + end end -- 2.39.5