Skip to content

Commit

Permalink
Merge pull request #37 from lsst-it/IT-5189/dhcp-service-without-install
Browse files Browse the repository at this point in the history
split cni::plugins::dhcp::service out of ::dhcp class
  • Loading branch information
jhoblitt authored Aug 15, 2024
2 parents 166b269 + ec4dcaa commit b2c8c34
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
16 changes: 14 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

* [`cni`](#cni): Install Container Network Interface software
* [`cni::plugins`](#cni--plugins): Install CNI reference plugins
* [`cni::plugins::dhcp`](#cni--plugins--dhcp): Install the cni-dhcp service
* [`cni::plugins::dhcp`](#cni--plugins--dhcp): Install and enable the cni-dhcp service
* [`cni::plugins::dhcp::service`](#cni--plugins--dhcp--service): Enables the the cni-dhcp service
* [`cni::plugins::install`](#cni--plugins--install): private class

### Defined types
Expand Down Expand Up @@ -82,7 +83,18 @@ Default value: `undef`

### <a name="cni--plugins--dhcp"></a>`cni::plugins::dhcp`

Install the cni-dhcp service
Install and enable the cni-dhcp service

### <a name="cni--plugins--dhcp--service"></a>`cni::plugins::dhcp::service`

Installs the cni-dhcp systemd service and enables it to start on boot.

Explicit inclusion of this class is not necessary when using the
cni::plugins::dhcp class.

This class is intended to be included directly only when it is desirable to enable
the cni-dhcp service without managing the installation of the cni plugin
binaries.

### <a name="cni--plugins--install"></a>`cni::plugins::install`

Expand Down
20 changes: 4 additions & 16 deletions manifests/plugins/dhcp.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
#
# @summary Install the cni-dhcp service
# @summary Install and enable the cni-dhcp service
#
class cni::plugins::dhcp {
include cni::plugins
include cni::plugins::dhcp::service

ensure_resources('cni::plugins::enable', { 'dhcp' => {} })

$epp_vars = {
prog => "${cni::bin_path}/dhcp",
}

systemd::unit_file { 'cni-dhcp.socket':
content => epp("${module_name}/dhcp/cni-dhcp.socket.epp"),
}
-> systemd::unit_file { 'cni-dhcp.service':
content => epp("${module_name}/dhcp/cni-dhcp.service.epp", $epp_vars),
}
~> service { 'cni-dhcp':
ensure => 'running',
enable => true,
subscribe => Cni::Plugins::Enable['dhcp'],
}
# restart the service if the installed binary changes
Cni::Plugins::Enable['dhcp'] ~> Service['cni-dhcp']
}
28 changes: 28 additions & 0 deletions manifests/plugins/dhcp/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# @summary Enables the the cni-dhcp service
#
# Installs the cni-dhcp systemd service and enables it to start on boot.
#
# Explicit inclusion of this class is not necessary when using the
# cni::plugins::dhcp class.
#
# This class is intended to be included directly only when it is desirable to enable
# the cni-dhcp service without managing the installation of the cni plugin
# binaries.
#
class cni::plugins::dhcp::service {
$epp_vars = {
prog => "${cni::bin_path}/dhcp",
}

systemd::unit_file { 'cni-dhcp.socket':
content => epp("${module_name}/dhcp/cni-dhcp.socket.epp"),
}
-> systemd::unit_file { 'cni-dhcp.service':
content => epp("${module_name}/dhcp/cni-dhcp.service.epp", $epp_vars),
}
~> service { 'cni-dhcp':
ensure => 'running',
enable => true,
}
}

0 comments on commit b2c8c34

Please sign in to comment.