Skip to content

Commit

Permalink
Add $package_ensure to package resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Friderici committed Apr 12, 2023
1 parent 9b4f202 commit 1e8e1b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
# @param packages
# Installation package(s) for the SSH client.
#
# @param packages_ensure
# Ensure parameter to SSH client package(s).
#
# @param packages_adminfile
# Path to adminfile for SSH client package(s) installation. Needed for Solaris.
#
Expand Down Expand Up @@ -482,6 +485,7 @@
Boolean $manage_server = true,
Boolean $manage_sshkey = true,
Array[String[1]] $packages = [],
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $packages_ensure = 'installed',
Optional[Stdlib::Absolutepath] $packages_adminfile = undef,
Optional[Stdlib::Absolutepath] $packages_source = undef,
Boolean $purge_keys = true,
Expand Down Expand Up @@ -594,7 +598,7 @@
) {

package { $packages:
ensure => installed,
ensure => $packages_ensure,
source => $packages_source,
adminfile => $packages_adminfile,
before => 'File[ssh_config]',
Expand Down
6 changes: 5 additions & 1 deletion manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
# Installation package(s) for the SSH server. Leave empty if the client package(s) also
# include the server binaries (eg: Suse SLES and SLED).
#
# @param packages_ensure
# Ensure parameter to SSH server package(s).
#
# @param packages_adminfile
# Path to adminfile for SSH server package(s) installation. Needed for Solaris.
#
Expand Down Expand Up @@ -463,6 +466,7 @@
#
class ssh::server (
Array[String[1]] $packages = [],
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $packages_ensure = 'installed',
Optional[Stdlib::Absolutepath] $packages_adminfile = undef,
Optional[Stdlib::Absolutepath] $packages_source = undef,
Stdlib::Absolutepath $config_path = '/etc/ssh/sshd_config',
Expand Down Expand Up @@ -587,7 +591,7 @@
) {

package { $packages:
ensure => installed,
ensure => $packages_ensure,
source => $packages_source,
adminfile => $packages_adminfile,
before => 'File[sshd_config]',
Expand Down
6 changes: 6 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@
it { is_expected.to contain_package('strings') }
end

context "on #{os} with packages_ensure set to valid latest" do
let(:params) { { packages_ensure: 'latest' } }

it { is_expected.to contain_package('openssh-clients').with_ensure('latest') }
end

context "on #{os} with packages_adminfile set to valid /unit/test" do
let(:params) { { packages_adminfile: '/unit/test' } }

Expand Down
6 changes: 6 additions & 0 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@
it { is_expected.to contain_package('strings') }
end

context "on #{os} with packages_ensure set to valid latest" do
let(:params) { { packages_ensure: 'latest' } }

it { is_expected.to contain_package('openssh-server').with_ensure('latest') }
end

context "on #{os} with packages_adminfile set to valid /unit/test" do
let(:params) { { packages_adminfile: '/unit/test' } }

Expand Down

0 comments on commit 1e8e1b6

Please sign in to comment.