Skip to content

Automatic default value selection for ssh::server::service_ensure not always working #453

Description

@webcompas

With #432 the $ensure parameter's type in ssh::server was changed to String. But this change has not been respected with the latest changes to $service_ensure which came with v15.0.0.
The default value for this parameter is only automatically set if $ensure is set to either "present" or "absent". If you set it to "latest" or a specific package version (which was the reason for allowing any string value), this is not working and leads to the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: No matching entry for selector parameter with value 'latest' (file: /etc/puppetlabs/code/environments/production/modules/ssh/manifests/server.pp, line: 136, column: 60) on node

The automatic default value selection should therefore be changed accordingly. This should be pretty easy since there are still only two different situations regarding the value of $ensure:

  1. It's set to "absent" or "purged". Then $service_ensure should obviously be set to "stopped".
  2. With any other value ("present", "latest", "disabled" or some specific version) the value of $service_ensure should be "running".

So this can be fixed with the following change:

diff --git a/manifests/server.pp b/manifests/server.pp
index 9d68cab..823bc99 100644
--- a/manifests/server.pp
+++ b/manifests/server.pp
@@ -135,3 +135,3 @@ class ssh::server (
   String                         $ensure                 = present,
-  Stdlib::Ensure::Service        $service_ensure         = $ensure ? { 'present' => 'running', 'absent' => 'stopped' },
+  Stdlib::Ensure::Service        $service_ensure         = $ensure ? { /(absent|purged|disabled)/ => 'stopped', default => 'running' },
   Boolean                        $service_enable         = ($service_ensure == 'running'),

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions