diff --git a/REFERENCE.md b/REFERENCE.md index ccd1e58..0d93f1b 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -80,6 +80,7 @@ The following parameters are available in the `podman` class: * [`podman_docker_pkg`](#-podman--podman_docker_pkg) * [`compose_pkg`](#-podman--compose_pkg) * [`machinectl_pkg`](#-podman--machinectl_pkg) +* [`podman_pkg_ensure`](#-podman--podman_pkg_ensure) * [`buildah_pkg_ensure`](#-podman--buildah_pkg_ensure) * [`podman_docker_pkg_ensure`](#-podman--podman_docker_pkg_ensure) * [`compose_pkg_ensure`](#-podman--compose_pkg_ensure) @@ -148,6 +149,14 @@ The name of the machinectl package (default 'systemd-container'). Default value: `'systemd-container'` +##### `podman_pkg_ensure` + +Data type: `Pattern[/^(\d+\.){2}\d+$/, /absent/, /installed/]` + +The ensure value for the podman package (default 'installed') + +Default value: `'installed'` + ##### `buildah_pkg_ensure` Data type: `Enum['absent', 'installed']` @@ -166,7 +175,7 @@ Default value: `'installed'` ##### `compose_pkg_ensure` -Data type: `Enum['absent', 'installed']` +Data type: `Pattern[/^(\d+\.){2}\d+$/, /absent/, /installed/]` The ensure value for the podman-compose package (default 'absent') diff --git a/data/common.yaml b/data/common.yaml index c56a494..7623299 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -22,4 +22,3 @@ podman::quadlet::defaults: TimeoutStartSec: "180" Install: WantedBy: "multi-user.target default.target" - diff --git a/manifests/init.pp b/manifests/init.pp index 18514e1..2ab83c9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -18,6 +18,9 @@ # @param machinectl_pkg # The name of the machinectl package (default 'systemd-container'). # +# @param podman_pkg_ensure +# The ensure value for the podman package (default 'installed') +# # @param buildah_pkg_ensure # The ensure value for the buildah package (default 'absent') # @@ -112,31 +115,32 @@ # - Podman::Volume[jenkins] # class podman ( - String $podman_pkg = 'podman', - String $skopeo_pkg = 'skopeo', - String $buildah_pkg = 'buildah', - String $podman_docker_pkg = 'podman-docker', - String $compose_pkg = 'podman-compose', - String $machinectl_pkg = 'systemd-container', - Enum['absent', 'installed'] $buildah_pkg_ensure = 'absent', - Enum['absent', 'installed'] $podman_docker_pkg_ensure = 'installed', - Enum['absent', 'installed'] $compose_pkg_ensure = 'absent', - Enum['absent', 'installed'] $machinectl_pkg_ensure = 'installed', - Enum['absent', 'file'] $nodocker = 'absent', - Hash $storage_options = {}, - Hash $containers_options = {}, - Array $rootless_users = [], - Boolean $enable_api_socket = false, - Boolean $manage_subuid = false, - Boolean $match_subuid_subgid = true, - String $file_header = '# FILE MANAGED BY PUPPET', - Hash $subid = {}, - Hash $pods = {}, - Hash $volumes = {}, - Hash $images = {}, - Hash $containers = {}, - Hash $networks = {}, - Hash $quadlets = {}, + String $podman_pkg = 'podman', + String $skopeo_pkg = 'skopeo', + String $buildah_pkg = 'buildah', + String $podman_docker_pkg = 'podman-docker', + String $compose_pkg = 'podman-compose', + String $machinectl_pkg = 'systemd-container', + Pattern[/^(\d+\.){2}\d+$/, /absent/, /installed/] $podman_pkg_ensure = 'installed', + Enum['absent', 'installed'] $buildah_pkg_ensure = 'absent', + Enum['absent', 'installed'] $podman_docker_pkg_ensure = 'installed', + Pattern[/^(\d+\.){2}\d+$/, /absent/, /installed/] $compose_pkg_ensure = 'absent', + Enum['absent', 'installed'] $machinectl_pkg_ensure = 'installed', + Enum['absent', 'file'] $nodocker = 'absent', + Hash $storage_options = {}, + Hash $containers_options = {}, + Array $rootless_users = [], + Boolean $enable_api_socket = false, + Boolean $manage_subuid = false, + Boolean $match_subuid_subgid = true, + String $file_header = '# FILE MANAGED BY PUPPET', + Hash $subid = {}, + Hash $pods = {}, + Hash $volumes = {}, + Hash $images = {}, + Hash $containers = {}, + Hash $networks = {}, + Hash $quadlets = {}, ) { include podman::install include podman::options diff --git a/manifests/install.pp b/manifests/install.pp index 4bd0401..9eb0ae6 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -2,7 +2,7 @@ # @api private # class podman::install { - ensure_resource('Package', $podman::podman_pkg, { 'ensure' => 'installed' }) + ensure_resource('Package', $podman::podman_pkg, { 'ensure' => $podman::podman_pkg_ensure }) ensure_resource('Package', $podman::skopeo_pkg, { 'ensure' => 'installed' }) ensure_resource('Package', $podman::buildah_pkg, { 'ensure' => $podman::buildah_pkg_ensure }) ensure_resource('Package', $podman::podman_docker_pkg, { 'ensure' => $podman::podman_docker_pkg_ensure }) diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 7ec108d..cf665f7 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -85,6 +85,18 @@ it { is_expected.to contain_package('testing') } end + context 'with podman_pkg_ensure set to valid installed' do + let(:params) { { podman_pkg_ensure: 'installed' } } # parameter used in podman::install + + it { is_expected.to contain_package('podman').with_ensure('installed') } + end + + context 'with podman_pkg_ensure set to valid version 1.0.0' do + let(:params) { { podman_pkg_ensure: '1.0.0' } } # parameter used in podman::install + + it { is_expected.to contain_package('podman').with_ensure('1.0.0') } + end + context 'with buildah_pkg_ensure set to valid installed' do let(:params) { { buildah_pkg_ensure: 'installed' } } # parameter used in podman::install @@ -101,6 +113,11 @@ it { is_expected.to contain_package('podman-compose').with_ensure('installed') } end + context 'with compose_pkg_ensure set to valid version 1.0.0' do + let(:params) { { compose_pkg_ensure: '1.0.0' } } # parameter used in podman::install + + it { is_expected.to contain_package('podman-compose').with_ensure('1.0.0') } + end context 'with machinectl_pkg_ensure set to valid absent' do let(:params) { { machinectl_pkg_ensure: 'absent' } } # parameter used in podman::install