3 # Resource:: podman_site
5 # Copyright:: 2023, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
24 default_action :create
26 property :site, String, :name_property => true
27 property :image, String, :required => true
28 property :port, Integer, :default => 8080
29 property :aliases, :kind_of => Array, :default => []
32 podman_service new_resource.site do
33 description "Container service for #{new_resource.site}"
34 image new_resource.image
35 ports external_port => new_resource.port
38 ssl_certificate new_resource.site do
39 domains Array(new_resource.site) + new_resource.aliases
42 apache_site new_resource.site do
45 variables :port => external_port, :aliases => new_resource.aliases
50 apache_site new_resource.site do
51 action [:disable, :delete]
54 podman_service new_resource.site do
58 node.rm_normal(:podman, :ports, new_resource.site)
63 "#{Chef::Config[:file_cache_path]}/podman-ports.yml"
67 @ports ||= if ::File.exist?(ports_file)
68 YAML.safe_load(::File.read(ports_file))
75 unless ports.include?(new_resource.site)
78 port += 1 while ports.values.include?(port)
80 ports[new_resource.site] = port
82 ::File.write(ports_file, YAML.dump(ports))
85 ports[new_resource.site]
90 notifies :reload, "service[apache2]"