puppet-barbican/manifests/worker.pp
Takashi Kajinami 578e24a0b9 Add strict validation about boolean parameters
This ensures the parameters used by if-else logic accept only boolean
values because non-boolean can result in unexpected behavior.

Change-Id: I963d73e46f82a780486fa282b424151485e43d1e
2023-03-03 04:36:46 +00:00

70 lines
1.8 KiB
Puppet

#
# Copyright (C) 2018 Binero
#
# Author: Tobias Urdin <tobias.urdin@binero.se>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# == Class: barbican::worker
#
# Manage the barbican-worker package and service.
#
# === Parameters
#
# [*package_ensure*]
# (Optional) The state of the barbican-worker package.
# Defaults to 'present'
#
# [*manage_service*]
# (Optional) If we should manage the barbican-worker service.
# Defaults to true
#
# [*enabled*]
# (Optional) Whether to enable the barbican-worker service.
# Defaults to true
#
class barbican::worker (
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
) inherits barbican::params {
include barbican::deps
validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_legacy(Boolean, 'validate_bool', $enabled)
package { 'barbican-worker':
ensure => $package_ensure,
name => $::barbican::params::worker_package_name,
tag => ['openstack', 'barbican-package'],
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
service { 'barbican-worker':
ensure => $service_ensure,
name => $::barbican::params::worker_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => 'barbican-service',
}
}
}