Skip to content

Commit

Permalink
Allow version setting on podman and podman-compose packages
Browse files Browse the repository at this point in the history
  • Loading branch information
coreone committed Dec 4, 2023
1 parent fb3ce01 commit f3d55f9
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 47 deletions.
53 changes: 31 additions & 22 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following parameters are available in the `podman` class:
* [`podman_docker_pkg`](#podman_docker_pkg)
* [`compose_pkg`](#compose_pkg)
* [`machinectl_pkg`](#machinectl_pkg)
* [`podman_pkg_ensure`](#podman_pkg_ensure)
* [`buildah_pkg_ensure`](#buildah_pkg_ensure)
* [`podman_docker_pkg_ensure`](#podman_docker_pkg_ensure)
* [`compose_pkg_ensure`](#compose_pkg_ensure)
Expand Down Expand Up @@ -145,6 +146,14 @@ The name of the machinectl package (default 'systemd-container').

Default value: `'systemd-container'`

##### <a name="podman_pkg_ensure"></a>`podman_pkg_ensure`

Data type: `Pattern[/^(\d+\.){2}\d+$/, /absent/, /installed/]`

The ensure value for the podman package (default 'installed')

Default value: `'absent'`

##### <a name="buildah_pkg_ensure"></a>`buildah_pkg_ensure`

Data type: `Enum['absent', 'installed']`
Expand All @@ -163,7 +172,7 @@ Default value: `'installed'`

##### <a name="compose_pkg_ensure"></a>`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')

Expand Down Expand Up @@ -331,22 +340,22 @@ The following parameters are available in the `podman::container` defined type:

##### <a name="image"></a>`image`

Data type: `String`
Data type: `Optional[String]`

Container registry source of the image being deployed. Required when
`ensure` is `present` but optional when `ensure` is set to `absent`.

Default value: `''`
Default value: ``undef``

##### <a name="user"></a>`user`

Data type: `String`
Data type: `Optional[String]`

Optional user for running rootless containers. For rootless containers,
the user must also be defined as a puppet resource that includes at least
'uid', 'gid', and 'home' attributes.

Default value: `''`
Default value: ``undef``

##### <a name="flags"></a>`flags`

Expand All @@ -372,22 +381,22 @@ Data type: `Hash`

When a container is created, a systemd unit file for the container service
is generated using the 'podman generate systemd' command. All flags for the
command are supported using the 'service_flags" hash parameter, again using
command are supported using the 'service_flags' hash parameter, again using
only the long form of the flag names.

Default value: `{}`

##### <a name="command"></a>`command`

Data type: `String`
Data type: `Optional[String]`

Optional command to be used as the container entry point.

Default value: `''`
Default value: ``undef``

##### <a name="ensure"></a>`ensure`

Data type: `String`
Data type: `Enum['present', 'absent']`

Valid values are 'present' or 'absent'

Expand Down Expand Up @@ -416,13 +425,13 @@ Default value: ``true``

##### <a name="ruby"></a>`ruby`

Data type: `Stdlib::Unixpath`
Data type: `Optional[Stdlib::Unixpath]`

The absolute path to the ruby binary to use in scripts. The default path is
'/opt/puppetlabs/puppet/bin/ruby' for Puppetlabs packaged puppet, and
'/usr/bin/ruby' for all others.

Default value: `$facts['ruby']['sitedir']`
Default value: ``undef``

### <a name="podmanimage"></a>`podman::image`

Expand Down Expand Up @@ -460,7 +469,7 @@ configured container registry.

##### <a name="ensure"></a>`ensure`

Data type: `String`
Data type: `Enum['present', 'absent']`

State of the resource must be either `present` or `absent`.

Expand All @@ -477,13 +486,13 @@ Default value: `{}`

##### <a name="user"></a>`user`

Data type: `String`
Data type: `Optional[String]`

Optional user for running rootless containers. When using this parameter,
the user must also be defined as a Puppet resource and must include the
'uid', 'gid', and 'home'

Default value: `''`
Default value: ``undef``

##### <a name="exec_env"></a>`exec_env`

Expand Down Expand Up @@ -610,13 +619,13 @@ Default value: ``false``

##### <a name="user"></a>`user`

Data type: `String`
Data type: `Optional[String]`

Optional user for creating rootless container networks. For rootless containers,
the user must also be defined as a puppet resource that includes at least
'uid', 'gid', and 'home' attributes.

Default value: `''`
Default value: ``undef``

### <a name="podmanpod"></a>`podman::pod`

Expand Down Expand Up @@ -644,7 +653,7 @@ The following parameters are available in the `podman::pod` defined type:

##### <a name="ensure"></a>`ensure`

Data type: `String`
Data type: `Enum['present', 'absent']`

State of the resource, which must be either 'present' or 'absent'.

Expand All @@ -662,13 +671,13 @@ Default value: `{}`

##### <a name="user"></a>`user`

Data type: `String`
Data type: `Optional[String]`

Optional user for running rootless containers. When using this parameter,
the user must also be defined as a Puppet resource and must include the
'uid', 'gid', and 'home'

Default value: `''`
Default value: ``undef``

### <a name="podmanrootless"></a>`podman::rootless`

Expand Down Expand Up @@ -884,7 +893,7 @@ The following parameters are available in the `podman::volume` defined type:

##### <a name="ensure"></a>`ensure`

Data type: `String`
Data type: `Enum['present', 'absent']`

State of the resource must be either 'present' or 'absent'.

Expand All @@ -903,11 +912,11 @@ Default value: `{}`

##### <a name="user"></a>`user`

Data type: `String`
Data type: `Optional[String]`

Optional user for running rootless containers. When using this parameter,
the user must also be defined as a Puppet resource and must include the
'uid', 'gid', and 'home'

Default value: `''`
Default value: ``undef``

1 change: 0 additions & 1 deletion data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ lookup_options:
merge: deep
podman::rootless_users:
merge: unique

50 changes: 27 additions & 23 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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')
#
Expand Down Expand Up @@ -106,29 +109,30 @@
# - 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 = {},
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 = {},
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 = {},
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 = {},
) {
include podman::install
include podman::options
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit f3d55f9

Please sign in to comment.