Skip to content

Commit

Permalink
merged issue 89
Browse files Browse the repository at this point in the history
  • Loading branch information
southalc committed Nov 25, 2024
2 parents be8edeb + 4867bf7 commit bc1bc03
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Release 0.7.1
- Include inifiles in module fixtures as required by unit tests
- Explicit lookup for defaults when calling the quadlet defined type from the main class
- Add management of /etc/containers/containers.conf #89. Contributed by fasrc

## Release 0.7.0
- Added the quadlet defined type
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,22 @@ systemctl --user status podman-<container_name>
### containerd configuration

This module also contains minimal support for editing the `containerd` configuration files that control some of the lower level
settings for how containers are created. Currently, the only supported configuration file is `/etc/containers/storage.conf`. You
should be able to set any of the settings with that file using the `$podman::storage_options` parameter. For example (if using Hiera):
settings for how containers are created. Currently, the only supported configuration files are `/etc/containers/storage.conf` and `/etc/containers/containers.conf`. You
should be able to set any of the settings with those files using the `$podman::storage_options` and `$podman::containers_options` parameters respectively. For example (if using Hiera):

```yaml
podman::storage_options:
storage:
rootless_storage_path: '"/tmp/containers-user-$UID/storage"'
```
```yaml
podman::containers_options:
engine:
cgroup_manager: '"cgroupfs"'
```
**Note the use of double quotes inside single quotes above.** This is due to the way the [puppetlabs/inifile](https://github.com/puppetlabs/puppetlabs-inifile/) module works currently.
## Examples
Expand Down
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The following parameters are available in the `podman` class:
* [`machinectl_pkg_ensure`](#-podman--machinectl_pkg_ensure)
* [`nodocker`](#-podman--nodocker)
* [`storage_options`](#-podman--storage_options)
* [`containers_options`](#-podman--containers_options)
* [`rootless_users`](#-podman--rootless_users)
* [`enable_api_socket`](#-podman--enable_api_socket)
* [`manage_subuid`](#-podman--manage_subuid)
Expand Down Expand Up @@ -196,6 +197,14 @@ A hash containing any storage options you wish to set in /etc/containers/storage

Default value: `{}`

##### <a name="-podman--containers_options"></a>`containers_options`

Data type: `Hash`

A hash containing any containers options you wish to set in /etc/containers/containers.conf

Default value: `{}`

##### <a name="-podman--rootless_users"></a>`rootless_users`

Data type: `Array`
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
# @param storage_options
# A hash containing any storage options you wish to set in /etc/containers/storage.conf
#
# @param containers_options
# A hash containing any containers options you wish to set in /etc/containers/containers.conf
#
# @param rootless_users
# An array of users to manage using [`podman::rootless`](#podmanrootless)
#
Expand Down Expand Up @@ -121,6 +124,7 @@
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,
Expand Down
8 changes: 8 additions & 0 deletions manifests/options.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
}
inifile::create_ini_settings($podman::storage_options, $storage_defaults)
}

unless $podman::containers_options.empty {
$containers_defaults = {
'ensure' => present,
'path' => '/etc/containers/containers.conf',
}
inifile::create_ini_settings($podman::containers_options, $containers_defaults)
}
}
40 changes: 40 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,46 @@
end
end

context 'with containers_options set to valid hash' do
let(:params) { { containers_options: { testing1: { option1: 'value1', option2: 'value2' }, testing2: { option3: 'value3' } } } }

it do
is_expected.to contain_ini_setting('/etc/containers/containers.conf [testing1] option1').only_with(
{
'section' => 'testing1',
'setting' => 'option1',
'value' => 'value1',
'ensure' => 'present',
'path' => '/etc/containers/containers.conf',
},
)
end

it do
is_expected.to contain_ini_setting('/etc/containers/containers.conf [testing1] option2').only_with(
{
'section' => 'testing1',
'setting' => 'option2',
'value' => 'value2',
'ensure' => 'present',
'path' => '/etc/containers/containers.conf',
},
)
end

it do
is_expected.to contain_ini_setting('/etc/containers/containers.conf [testing2] option3').only_with(
{
'section' => 'testing2',
'setting' => 'option3',
'value' => 'value3',
'ensure' => 'present',
'path' => '/etc/containers/containers.conf',
},
)
end
end

context 'with rootless_users set to valid [test, ing]' do
let(:params) { { rootless_users: ['test', 'ing'] } }
let(:pre_condition) do
Expand Down
40 changes: 40 additions & 0 deletions spec/classes/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,45 @@
)
end
end

context 'when podman::containers_options is set to valid hash' do
let(:pre_condition) { 'class { "podman": containers_options => { testing1 => { option1 => "value1", option2 => "value2" }, testing2 => { option3 => "value3" } } }' }

it do
is_expected.to contain_ini_setting('/etc/containers/containers.conf [testing1] option1').only_with(
{
'section' => 'testing1',
'setting' => 'option1',
'value' => 'value1',
'ensure' => 'present',
'path' => '/etc/containers/containers.conf',
},
)
end

it do
is_expected.to contain_ini_setting('/etc/containers/containers.conf [testing1] option2').only_with(
{
'section' => 'testing1',
'setting' => 'option2',
'value' => 'value2',
'ensure' => 'present',
'path' => '/etc/containers/containers.conf',
},
)
end

it do
is_expected.to contain_ini_setting('/etc/containers/containers.conf [testing2] option3').only_with(
{
'section' => 'testing2',
'setting' => 'option3',
'value' => 'value3',
'ensure' => 'present',
'path' => '/etc/containers/containers.conf',
},
)
end
end
end
end

0 comments on commit bc1bc03

Please sign in to comment.