Skip to content

Commit

Permalink
Move subclasses into main class
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Friderici committed Nov 6, 2023
1 parent fb3ce01 commit f7b6b99
Show file tree
Hide file tree
Showing 20 changed files with 321 additions and 699 deletions.
2 changes: 0 additions & 2 deletions manifests/container.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
Boolean $update = true,
Optional[Stdlib::Unixpath] $ruby = undef,
) {
require podman::install

$installed_ruby = $facts['ruby']['sitedir'] ? {
/^\/opt\/puppetlabs\// => '/opt/puppetlabs/puppet/bin/ruby',
default => '/usr/bin/ruby',
Expand Down
2 changes: 0 additions & 2 deletions manifests/image.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
Optional[String] $user = undef,
Array $exec_env = [],
) {
require podman::install

# Convert $flags hash to command arguments
$_flags = $flags.reduce('') |$mem, $flag| {
if $flag[1] =~ String {
Expand Down
75 changes: 71 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,89 @@
Hash $containers = {},
Hash $networks = {},
) {
include podman::install
include podman::options
include podman::service

# Create resources from parameter hashes
$pods.each |$name, $properties| { Resource['Podman::Pod'] { $name: * => $properties, } }
$volumes.each |$name, $properties| { Resource['Podman::Volume'] { $name: * => $properties, } }
$images.each |$name, $properties| { Resource['Podman::Image'] { $name: * => $properties, } }
$containers.each |$name, $properties| { Resource['Podman::Container'] { $name: * => $properties, } }
$networks.each |$name, $properties| { Resource['Podman::Network'] { $name: * => $properties, } }

ensure_resource('Package', $podman_pkg, { 'ensure' => 'installed' })
ensure_resource('Package', $skopeo_pkg, { 'ensure' => 'installed' })
ensure_resource('Package', $buildah_pkg, { 'ensure' => $buildah_pkg_ensure })
ensure_resource('Package', $podman_docker_pkg, { 'ensure' => $podman_docker_pkg_ensure })
ensure_resource('Package', $compose_pkg, { 'ensure' => $compose_pkg_ensure })
ensure_resource('Package', $machinectl_pkg, { 'ensure' => $machinectl_pkg_ensure })

$rootless_users.each |$user| {
unless defined(Podman::Rootless[$user]) {
podman::rootless { $user: }
}

User <| title == $user |> -> Podman::Rootless <| title == $user |>
}

if $manage_subuid {
concat { ['/etc/subuid', '/etc/subgid']:
owner => 'root',
group => 'root',
mode => '0644',
order => 'alpha',
ensure_newline => true,
}

concat_fragment { 'subuid_header':
target => '/etc/subuid',
order => 1,
content => $file_header,
}

concat_fragment { 'subgid_header':
target => '/etc/subgid',
order => 1,
content => $file_header,
}

if $match_subuid_subgid {
$podman::subid.each |$name, $properties| {
Resource['Podman::Subuid'] { $name: * => $properties }
$subgid = { subgid => $properties['subuid'], count => $properties['count'] }
Resource['Podman::Subgid'] { $name: * => $subgid }
}
}
}

if $facts['os']['selinux']['enabled'] == true {
selboolean { 'container_manage_cgroup':
persistent => true,
value => on,
require => Package[$podman_pkg],
}
}

file { '/etc/containers/nodocker':
ensure => $podman::nodocker,
group => 'root',
owner => 'root',
mode => '0644',
require => Package[$podman::podman_pkg],
}

unless $storage_options.empty {
$storage_defaults = {
'ensure' => present,
'path' => '/etc/containers/storage.conf',
}
inifile::create_ini_settings($storage_options, $storage_defaults)
}

$ensure = $enable_api_socket ? {
true => 'running',
default => 'stopped',
}

service { 'podman.socket':
ensure => $ensure,
enable => $enable_api_socket,
}
}
57 changes: 0 additions & 57 deletions manifests/install.pp

This file was deleted.

2 changes: 0 additions & 2 deletions manifests/network.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
Boolean $ipv6 = false,
Optional[String] $user = undef,
) {
require podman::install

# Convert opts list to command arguments
$_opts = $opts.reduce('') |$mem, $opt| {
"${mem} --flag ${opt}"
Expand Down
14 changes: 0 additions & 14 deletions manifests/options.pp

This file was deleted.

2 changes: 0 additions & 2 deletions manifests/pod.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
Hash $flags = {},
Optional[String] $user = undef,
) {
require podman::install

# The resource name will be the pod name by default
$pod_name = $title
$name_flags = merge({ name => $title }, $flags )
Expand Down
3 changes: 3 additions & 0 deletions manifests/rootless.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# @summary Enable a given user to run rootless podman containers as a systemd user service.
#
define podman::rootless {
include podman

exec { "loginctl_linger_${name}":
path => '/sbin:/usr/sbin:/bin:/usr/bin',
command => "loginctl enable-linger ${name}",
Expand All @@ -9,6 +11,7 @@
require => User[$name],
notify => Service['podman systemd-logind'],
}

ensure_resource('Service', 'podman systemd-logind', { name => 'systemd-logind.service', ensure => 'running' })

# Ensure the systemd directory tree exists for user services
Expand Down
16 changes: 0 additions & 16 deletions manifests/service.pp

This file was deleted.

2 changes: 1 addition & 1 deletion manifests/volume.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Hash $flags = {},
Optional[String] $user = undef,
) {
require podman::install
# require podman::install

# Convert $flags hash to command arguments
$_flags = $flags.reduce('') |$mem, $flag| {
Expand Down
Loading

0 comments on commit f7b6b99

Please sign in to comment.