From 5527093b8bcecae964708e7c607f2664b1e02876 Mon Sep 17 00:00:00 2001 From: Gordon Bleux <33967640+UiP9AV6Y@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:30:36 +0200 Subject: [PATCH] add support for managing individual plugin versions currently on the remote_execution/cockpit plugin class has support for managing the plugin version. all other plugins are tied to the `foreman::plugin_version`. this change adds the same `ensure` parameter to all plugin classes allowing for granular state management. --- manifests/plugin/acd.pp | 10 +++++++++- manifests/plugin/ansible.pp | 10 +++++++++- manifests/plugin/azure.pp | 10 +++++++++- manifests/plugin/bootdisk.pp | 10 +++++++++- manifests/plugin/datacenter.pp | 13 +++++++++++-- manifests/plugin/default_hostgroup.pp | 3 +++ manifests/plugin/dhcp_browser.pp | 13 +++++++++++-- manifests/plugin/discovery.pp | 10 +++++++++- manifests/plugin/dlm.pp | 10 +++++++++- manifests/plugin/expire_hosts.pp | 10 +++++++++- manifests/plugin/git_templates.pp | 10 +++++++++- manifests/plugin/google.pp | 10 +++++++++- manifests/plugin/hdm.pp | 10 +++++++++- manifests/plugin/host_extra_validator.pp | 10 +++++++++- manifests/plugin/kernel_care.pp | 10 +++++++++- manifests/plugin/kubevirt.pp | 10 +++++++++- manifests/plugin/leapp.pp | 10 +++++++++- manifests/plugin/monitoring.pp | 10 +++++++++- manifests/plugin/netbox.pp | 10 +++++++++- manifests/plugin/omaha.pp | 10 +++++++++- manifests/plugin/openscap.pp | 13 +++++++++++-- manifests/plugin/ovirt_provision.pp | 10 +++++++++- manifests/plugin/proxmox.pp | 10 +++++++++- manifests/plugin/puppet.pp | 10 +++++++++- manifests/plugin/puppetdb.pp | 5 +++++ manifests/plugin/remote_execution.pp | 10 +++++++++- manifests/plugin/rescue.pp | 10 +++++++++- manifests/plugin/rh_cloud.pp | 10 +++++++++- manifests/plugin/salt.pp | 10 +++++++++- manifests/plugin/scc_manager.pp | 10 +++++++++- manifests/plugin/snapshot_management.pp | 10 +++++++++- manifests/plugin/statistics.pp | 10 +++++++++- manifests/plugin/supervisory_authority.pp | 6 +++++- manifests/plugin/tasks.pp | 5 +++++ manifests/plugin/templates.pp | 10 +++++++++- manifests/plugin/vault.pp | 10 +++++++++- manifests/plugin/virt_who_configure.pp | 10 +++++++++- manifests/plugin/webhooks.pp | 10 +++++++++- manifests/plugin/wreckingball.pp | 10 +++++++++- spec/classes/plugin/acd_spec.rb | 1 + spec/classes/plugin/ansible_spec.rb | 1 + spec/classes/plugin/azure_spec.rb | 1 + spec/classes/plugin/bootdisk_spec.rb | 1 + spec/classes/plugin/datacenter.rb | 1 + spec/classes/plugin/default_hostgroup_spec.rb | 1 + spec/classes/plugin/dhcp_browser_spec.rb | 1 + spec/classes/plugin/discovery_spec.rb | 1 + spec/classes/plugin/dlm_spec.rb | 1 + spec/classes/plugin/expire_hosts_spec.rb | 1 + spec/classes/plugin/git_templates_spec.rb | 1 + spec/classes/plugin/google_spec.rb | 1 + spec/classes/plugin/hdm_spec.rb | 1 + spec/classes/plugin/host_extra_validator_spec.rb | 1 + spec/classes/plugin/kernel_care_spec.rb | 1 + spec/classes/plugin/kubevirt_spec.rb | 1 + spec/classes/plugin/leapp_spec.rb | 1 + spec/classes/plugin/monitoring_spec.rb | 1 + spec/classes/plugin/netbox_spec.rb | 1 + spec/classes/plugin/omaha_spec.rb | 1 + spec/classes/plugin/proxmox_spec.rb | 1 + spec/classes/plugin/puppet_spec.rb | 1 + spec/classes/plugin/rescue_spec.rb | 1 + spec/classes/plugin/rh_cloud_spec.rb | 1 + spec/classes/plugin/salt_spec.rb | 1 + spec/classes/plugin/scc_manager_spec.rb | 1 + spec/classes/plugin/snapshot_management_spec.rb | 1 + spec/classes/plugin/statistics_spec.rb | 1 + spec/classes/plugin/templates_spec.rb | 1 + spec/classes/plugin/vault_spec.rb | 1 + spec/classes/plugin/virt_who_configure_spec.rb | 1 + spec/classes/plugin/webhooks_spec.rb | 1 + spec/classes/plugin/wreckingball_spec.rb | 1 + spec/support/plugin.rb | 11 +++++++++++ 73 files changed, 383 insertions(+), 39 deletions(-) diff --git a/manifests/plugin/acd.pp b/manifests/plugin/acd.pp index 17611b66d..360da9c30 100644 --- a/manifests/plugin/acd.pp +++ b/manifests/plugin/acd.pp @@ -1,8 +1,16 @@ # Installs foreman_acd plugin -class foreman::plugin::acd { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::acd ( + Optional[String[1]] $ensure = undef, +) { include foreman::plugin::tasks include foreman::plugin::remote_execution foreman::plugin { 'acd': + version => $ensure, } } diff --git a/manifests/plugin/ansible.pp b/manifests/plugin/ansible.pp index 28b0b9f9a..3a80fb408 100644 --- a/manifests/plugin/ansible.pp +++ b/manifests/plugin/ansible.pp @@ -1,7 +1,15 @@ # Installs foreman_ansible plugin -class foreman::plugin::ansible { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::ansible ( + Optional[String[1]] $ensure = undef, +) { include foreman::plugin::tasks foreman::plugin { 'ansible': + version => $ensure, } } diff --git a/manifests/plugin/azure.pp b/manifests/plugin/azure.pp index 36506175e..ed0ab157e 100644 --- a/manifests/plugin/azure.pp +++ b/manifests/plugin/azure.pp @@ -1,5 +1,13 @@ # Installs foreman_azure_rm plugin -class foreman::plugin::azure { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::azure ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'azure_rm': + version => $ensure, } } diff --git a/manifests/plugin/bootdisk.pp b/manifests/plugin/bootdisk.pp index 098e82079..663a5ab0a 100644 --- a/manifests/plugin/bootdisk.pp +++ b/manifests/plugin/bootdisk.pp @@ -1,5 +1,13 @@ # Installs foreman_bootdisk plugin -class foreman::plugin::bootdisk { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::bootdisk ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'bootdisk': + version => $ensure, } } diff --git a/manifests/plugin/datacenter.pp b/manifests/plugin/datacenter.pp index 5009e809d..b0c7e891a 100644 --- a/manifests/plugin/datacenter.pp +++ b/manifests/plugin/datacenter.pp @@ -1,4 +1,13 @@ # Installs foreman_datacenter plugin -class foreman::plugin::datacenter { - foreman::plugin { 'datacenter': } +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::datacenter ( + Optional[String[1]] $ensure = undef, +) { + foreman::plugin { 'datacenter': + version => $ensure, + } } diff --git a/manifests/plugin/default_hostgroup.pp b/manifests/plugin/default_hostgroup.pp index 01ffc66b9..e9a093c08 100644 --- a/manifests/plugin/default_hostgroup.pp +++ b/manifests/plugin/default_hostgroup.pp @@ -1,8 +1,10 @@ # @summary This class installs the default_hostgroup plugin and optionally manages the configuration file # # @param hostgroups An array of hashes of hostgroup names and facts to add to the configuration +# @param ensure Specify the package state, or absent/purged to remove it # class foreman::plugin::default_hostgroup ( + Optional[String[1]] $ensure = undef, Array[Hash[String, Hash]] $hostgroups = [], ) { if empty($hostgroups) { @@ -12,6 +14,7 @@ } foreman::plugin { 'default_hostgroup': + version => $ensure, config => $config, config_file => "${foreman::plugin_config_dir}/default_hostgroup.yaml", } diff --git a/manifests/plugin/dhcp_browser.pp b/manifests/plugin/dhcp_browser.pp index 4d1c2d55e..34d7d03f2 100644 --- a/manifests/plugin/dhcp_browser.pp +++ b/manifests/plugin/dhcp_browser.pp @@ -1,4 +1,13 @@ # Installs foreman_dhcp_browser plugin -class foreman::plugin::dhcp_browser { - foreman::plugin { 'dhcp_browser': } +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::dhcp_browser ( + Optional[String[1]] $ensure = undef, +) { + foreman::plugin { 'dhcp_browser': + version => $ensure, + } } diff --git a/manifests/plugin/discovery.pp b/manifests/plugin/discovery.pp index 78c627d60..a98fdead5 100644 --- a/manifests/plugin/discovery.pp +++ b/manifests/plugin/discovery.pp @@ -2,7 +2,15 @@ # # This class installs discovery plugin and images # -class foreman::plugin::discovery { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::discovery ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'discovery': + version => $ensure, } } diff --git a/manifests/plugin/dlm.pp b/manifests/plugin/dlm.pp index 8f60d5d55..06ab47686 100644 --- a/manifests/plugin/dlm.pp +++ b/manifests/plugin/dlm.pp @@ -1,5 +1,13 @@ # Installs foreman_dlm plugin -class foreman::plugin::dlm { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::dlm ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'dlm': + version => $ensure, } } diff --git a/manifests/plugin/expire_hosts.pp b/manifests/plugin/expire_hosts.pp index dafd9992d..c7bf7ade5 100644 --- a/manifests/plugin/expire_hosts.pp +++ b/manifests/plugin/expire_hosts.pp @@ -1,5 +1,13 @@ # Installs foreman_expire_hosts plugin -class foreman::plugin::expire_hosts { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::expire_hosts ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'expire_hosts': + version => $ensure, } } diff --git a/manifests/plugin/git_templates.pp b/manifests/plugin/git_templates.pp index 6de89feb1..406f9015a 100644 --- a/manifests/plugin/git_templates.pp +++ b/manifests/plugin/git_templates.pp @@ -2,7 +2,15 @@ # # This class installs git_templates plugin # -class foreman::plugin::git_templates { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::git_templates ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'git_templates': + version => $ensure, } } diff --git a/manifests/plugin/google.pp b/manifests/plugin/google.pp index b7e2e0676..67b740a17 100644 --- a/manifests/plugin/google.pp +++ b/manifests/plugin/google.pp @@ -1,5 +1,13 @@ # Installs foreman_google plugin -class foreman::plugin::google { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::google ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'google': + version => $ensure, } } diff --git a/manifests/plugin/hdm.pp b/manifests/plugin/hdm.pp index eadb20576..95cb1604c 100644 --- a/manifests/plugin/hdm.pp +++ b/manifests/plugin/hdm.pp @@ -1,6 +1,14 @@ # @summary Install the Hiera Data Manager (HDM) plugin # -class foreman::plugin::hdm { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::hdm ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'hdm': + version => $ensure, } } diff --git a/manifests/plugin/host_extra_validator.pp b/manifests/plugin/host_extra_validator.pp index 6949ae245..d7396a080 100644 --- a/manifests/plugin/host_extra_validator.pp +++ b/manifests/plugin/host_extra_validator.pp @@ -1,5 +1,13 @@ # Installs foreman_host_extra_validator plugin -class foreman::plugin::host_extra_validator { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::host_extra_validator ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'host_extra_validator': + version => $ensure, } } diff --git a/manifests/plugin/kernel_care.pp b/manifests/plugin/kernel_care.pp index 8fbebcea8..d46dda29e 100644 --- a/manifests/plugin/kernel_care.pp +++ b/manifests/plugin/kernel_care.pp @@ -1,5 +1,13 @@ # Installs foreman_kernel_care plugin -class foreman::plugin::kernel_care { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::kernel_care ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'kernel_care': + version => $ensure, } } diff --git a/manifests/plugin/kubevirt.pp b/manifests/plugin/kubevirt.pp index 7efed74b9..32e8c1116 100644 --- a/manifests/plugin/kubevirt.pp +++ b/manifests/plugin/kubevirt.pp @@ -1,5 +1,13 @@ # Installs foreman_kubevirt plugin -class foreman::plugin::kubevirt { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::kubevirt ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'kubevirt': + version => $ensure, } } diff --git a/manifests/plugin/leapp.pp b/manifests/plugin/leapp.pp index 8b9d239fa..5911c80e5 100644 --- a/manifests/plugin/leapp.pp +++ b/manifests/plugin/leapp.pp @@ -1,8 +1,16 @@ # Installs foreman_leapp plugin -class foreman::plugin::leapp { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::leapp ( + Optional[String[1]] $ensure = undef, +) { include foreman::plugin::remote_execution include foreman::plugin::ansible foreman::plugin { 'leapp': + version => $ensure, } } diff --git a/manifests/plugin/monitoring.pp b/manifests/plugin/monitoring.pp index 1162e5948..c4f11d708 100644 --- a/manifests/plugin/monitoring.pp +++ b/manifests/plugin/monitoring.pp @@ -1,5 +1,13 @@ # Installs foreman_monitoring plugin -class foreman::plugin::monitoring { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::monitoring ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'monitoring': + version => $ensure, } } diff --git a/manifests/plugin/netbox.pp b/manifests/plugin/netbox.pp index 0789ca7f3..cefcdd499 100644 --- a/manifests/plugin/netbox.pp +++ b/manifests/plugin/netbox.pp @@ -2,7 +2,15 @@ # # This class installs netbox plugin # -class foreman::plugin::netbox { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::netbox ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'netbox': + version => $ensure, } } diff --git a/manifests/plugin/omaha.pp b/manifests/plugin/omaha.pp index 9d45e047a..3d079da0c 100644 --- a/manifests/plugin/omaha.pp +++ b/manifests/plugin/omaha.pp @@ -1,5 +1,13 @@ # Installs foreman_omaha plugin -class foreman::plugin::omaha { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::omaha ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'omaha': + version => $ensure, } } diff --git a/manifests/plugin/openscap.pp b/manifests/plugin/openscap.pp index 2257edb33..2ca3f6896 100644 --- a/manifests/plugin/openscap.pp +++ b/manifests/plugin/openscap.pp @@ -4,6 +4,15 @@ # # === Parameters: # -class foreman::plugin::openscap { - foreman::plugin { 'openscap': } +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::openscap ( + Optional[String[1]] $ensure = undef, +) { + foreman::plugin { 'openscap': + version => $ensure, + } } diff --git a/manifests/plugin/ovirt_provision.pp b/manifests/plugin/ovirt_provision.pp index eb12308f6..9ccef9f8f 100644 --- a/manifests/plugin/ovirt_provision.pp +++ b/manifests/plugin/ovirt_provision.pp @@ -1,6 +1,14 @@ # @summary install the ovirt_provision plugin -class foreman::plugin::ovirt_provision { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::ovirt_provision ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'ovirt_provision': + version => $ensure, package => $foreman::params::plugin_prefix.regsubst(/foreman[_-]/, 'ovirt_provision_plugin'), } } diff --git a/manifests/plugin/proxmox.pp b/manifests/plugin/proxmox.pp index be9883645..fa174557b 100644 --- a/manifests/plugin/proxmox.pp +++ b/manifests/plugin/proxmox.pp @@ -1,5 +1,13 @@ # = Foreman Proxmox plugin -class foreman::plugin::proxmox { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::proxmox ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'fog_proxmox': + version => $ensure, } } diff --git a/manifests/plugin/puppet.pp b/manifests/plugin/puppet.pp index a46fec408..06672ed06 100644 --- a/manifests/plugin/puppet.pp +++ b/manifests/plugin/puppet.pp @@ -2,7 +2,15 @@ # # This class installs puppet plugin # -class foreman::plugin::puppet { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::puppet ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'puppet': + version => $ensure, } } diff --git a/manifests/plugin/puppetdb.pp b/manifests/plugin/puppetdb.pp index df40da7f9..6105853d8 100644 --- a/manifests/plugin/puppetdb.pp +++ b/manifests/plugin/puppetdb.pp @@ -15,7 +15,11 @@ # @param api_version # PuppetDB API version. # +# @param ensure +# Specify the package state, or absent/purged to remove it +# class foreman::plugin::puppetdb ( + Optional[String[1]] $ensure = undef, Stdlib::HTTPUrl $address = 'https://localhost:8081/pdb/cmd/v1', String $ssl_ca_file = $foreman::params::client_ssl_ca, String $ssl_certificate = $foreman::params::client_ssl_cert, @@ -23,6 +27,7 @@ Enum['1', '3', '4'] $api_version = '4', ) inherits foreman::params { foreman::plugin { 'puppetdb': + version => $ensure, package => $foreman::params::plugin_prefix.regsubst(/foreman[_-]/, 'puppetdb_foreman'), } diff --git a/manifests/plugin/remote_execution.pp b/manifests/plugin/remote_execution.pp index f82d12ede..d1589e17f 100644 --- a/manifests/plugin/remote_execution.pp +++ b/manifests/plugin/remote_execution.pp @@ -1,7 +1,15 @@ # Installs foreman_remote_execution plugin -class foreman::plugin::remote_execution { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::remote_execution ( + Optional[String[1]] $ensure = undef, +) { include foreman::plugin::tasks foreman::plugin { 'remote_execution': + version => $ensure, } } diff --git a/manifests/plugin/rescue.pp b/manifests/plugin/rescue.pp index 8dc5c017f..ab0741b77 100644 --- a/manifests/plugin/rescue.pp +++ b/manifests/plugin/rescue.pp @@ -1,5 +1,13 @@ # Installs foreman_rescue plugin -class foreman::plugin::rescue { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::rescue ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'rescue': + version => $ensure, } } diff --git a/manifests/plugin/rh_cloud.pp b/manifests/plugin/rh_cloud.pp index 08f6d5da6..0daa8db3b 100644 --- a/manifests/plugin/rh_cloud.pp +++ b/manifests/plugin/rh_cloud.pp @@ -1,5 +1,13 @@ # Installs rh_cloud plugin -class foreman::plugin::rh_cloud { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::rh_cloud ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'rh_cloud': + version => $ensure, } } diff --git a/manifests/plugin/salt.pp b/manifests/plugin/salt.pp index 3a76cd93d..48a857ddf 100644 --- a/manifests/plugin/salt.pp +++ b/manifests/plugin/salt.pp @@ -1,7 +1,15 @@ # Installs foreman_salt plugin -class foreman::plugin::salt { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::salt ( + Optional[String[1]] $ensure = undef, +) { include foreman::plugin::tasks foreman::plugin { 'salt': + version => $ensure, } } diff --git a/manifests/plugin/scc_manager.pp b/manifests/plugin/scc_manager.pp index 8a5d007a5..e84c941e3 100644 --- a/manifests/plugin/scc_manager.pp +++ b/manifests/plugin/scc_manager.pp @@ -2,7 +2,15 @@ # # This class installs scc_manager plugin # -class foreman::plugin::scc_manager { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::scc_manager ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'scc_manager': + version => $ensure, } } diff --git a/manifests/plugin/snapshot_management.pp b/manifests/plugin/snapshot_management.pp index b836eb654..4c336fcc8 100644 --- a/manifests/plugin/snapshot_management.pp +++ b/manifests/plugin/snapshot_management.pp @@ -1,5 +1,13 @@ # Installs foreman_snapshot_management plugin -class foreman::plugin::snapshot_management { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::snapshot_management ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'snapshot_management': + version => $ensure, } } diff --git a/manifests/plugin/statistics.pp b/manifests/plugin/statistics.pp index d38310372..87edb0754 100644 --- a/manifests/plugin/statistics.pp +++ b/manifests/plugin/statistics.pp @@ -2,7 +2,15 @@ # # This class installs trends and statistics plugin # -class foreman::plugin::statistics { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::statistics ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'statistics': + version => $ensure, } } diff --git a/manifests/plugin/supervisory_authority.pp b/manifests/plugin/supervisory_authority.pp index 562e56a53..9ee5b1b8b 100644 --- a/manifests/plugin/supervisory_authority.pp +++ b/manifests/plugin/supervisory_authority.pp @@ -28,6 +28,8 @@ # # $metrics_interval:: Specify the interval for reporting metrics to APM Server. # +# $ensure:: Specify the package state, or absent/purged to remove it +# class foreman::plugin::supervisory_authority ( Stdlib::HTTPUrl $server_url, String $secret_token, @@ -40,6 +42,7 @@ Integer[0] $transaction_max_spans = 500, Boolean $http_compression = false, String $metrics_interval = '30s', + Optional[String[1]] $ensure = undef, ) { $config = { foreman_supervisory_authority => { @@ -58,6 +61,7 @@ } foreman::plugin { 'supervisory_authority': - config => foreman::to_symbolized_yaml($config), + version => $ensure, + config => foreman::to_symbolized_yaml($config), } } diff --git a/manifests/plugin/tasks.pp b/manifests/plugin/tasks.pp index 8a9e06330..b6db829ce 100644 --- a/manifests/plugin/tasks.pp +++ b/manifests/plugin/tasks.pp @@ -9,12 +9,17 @@ # @param backup # Enable creating a backup of cleaned up tasks in CSV format when automatic_cleanup is enabled # +# @param ensure +# Specify the package state, or absent/purged to remove it +# class foreman::plugin::tasks ( + Optional[String[1]] $ensure = undef, Boolean $automatic_cleanup = false, String $cron_line = '45 19 * * *', Boolean $backup = false, ) { foreman::plugin { 'tasks': + version => $ensure, package => $foreman::params::plugin_prefix.regsubst(/foreman[_-]/, 'foreman-tasks'), } $cron_state = $automatic_cleanup ? { diff --git a/manifests/plugin/templates.pp b/manifests/plugin/templates.pp index 8c8f5433d..3e89f049f 100644 --- a/manifests/plugin/templates.pp +++ b/manifests/plugin/templates.pp @@ -1,5 +1,13 @@ # Installs foreman_templates plugin -class foreman::plugin::templates { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::templates ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'templates': + version => $ensure, } } diff --git a/manifests/plugin/vault.pp b/manifests/plugin/vault.pp index 956bebd6c..31a4dc52b 100644 --- a/manifests/plugin/vault.pp +++ b/manifests/plugin/vault.pp @@ -2,7 +2,15 @@ # # This class installs vault plugin # -class foreman::plugin::vault { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::vault ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'vault': + version => $ensure, } } diff --git a/manifests/plugin/virt_who_configure.pp b/manifests/plugin/virt_who_configure.pp index f7e0b5648..bd29927cf 100644 --- a/manifests/plugin/virt_who_configure.pp +++ b/manifests/plugin/virt_who_configure.pp @@ -1,5 +1,13 @@ # Installs foreman_virt_who_configure plugin -class foreman::plugin::virt_who_configure { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::virt_who_configure ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'virt_who_configure': + version => $ensure, } } diff --git a/manifests/plugin/webhooks.pp b/manifests/plugin/webhooks.pp index a3c1cd818..43dd7b67b 100644 --- a/manifests/plugin/webhooks.pp +++ b/manifests/plugin/webhooks.pp @@ -2,7 +2,15 @@ # # This class installs webhooks plugin # -class foreman::plugin::webhooks { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::webhooks ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'webhooks': + version => $ensure, } } diff --git a/manifests/plugin/wreckingball.pp b/manifests/plugin/wreckingball.pp index 5e21b38cf..83058d530 100644 --- a/manifests/plugin/wreckingball.pp +++ b/manifests/plugin/wreckingball.pp @@ -1,5 +1,13 @@ # Installs foreman_wreckingball plugin -class foreman::plugin::wreckingball { +# +# === Advanced parameters: +# +# $ensure:: Specify the package state, or absent/purged to remove it +# +class foreman::plugin::wreckingball ( + Optional[String[1]] $ensure = undef, +) { foreman::plugin { 'wreckingball': + version => $ensure, } } diff --git a/spec/classes/plugin/acd_spec.rb b/spec/classes/plugin/acd_spec.rb index 07351d2a6..69d62ae00 100644 --- a/spec/classes/plugin/acd_spec.rb +++ b/spec/classes/plugin/acd_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'foreman::plugin::acd' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'acd' it { should contain_foreman__plugin('tasks') } it { should contain_foreman__plugin('remote_execution') } diff --git a/spec/classes/plugin/ansible_spec.rb b/spec/classes/plugin/ansible_spec.rb index ac18e221a..d8a5006cd 100644 --- a/spec/classes/plugin/ansible_spec.rb +++ b/spec/classes/plugin/ansible_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'foreman::plugin::ansible' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'ansible' it { should contain_foreman__plugin('tasks') } end diff --git a/spec/classes/plugin/azure_spec.rb b/spec/classes/plugin/azure_spec.rb index ee6050f81..235b81c29 100644 --- a/spec/classes/plugin/azure_spec.rb +++ b/spec/classes/plugin/azure_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::azure' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'azure_rm' end diff --git a/spec/classes/plugin/bootdisk_spec.rb b/spec/classes/plugin/bootdisk_spec.rb index 9492430f8..9ea394f4d 100644 --- a/spec/classes/plugin/bootdisk_spec.rb +++ b/spec/classes/plugin/bootdisk_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::bootdisk' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'bootdisk' end diff --git a/spec/classes/plugin/datacenter.rb b/spec/classes/plugin/datacenter.rb index f20acfb1f..b939479c0 100644 --- a/spec/classes/plugin/datacenter.rb +++ b/spec/classes/plugin/datacenter.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::datacenter' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'datacenter' end diff --git a/spec/classes/plugin/default_hostgroup_spec.rb b/spec/classes/plugin/default_hostgroup_spec.rb index f08d829f1..332183cc1 100644 --- a/spec/classes/plugin/default_hostgroup_spec.rb +++ b/spec/classes/plugin/default_hostgroup_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'foreman::plugin::default_hostgroup' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'default_hostgroup' context 'with user provided config hash' do diff --git a/spec/classes/plugin/dhcp_browser_spec.rb b/spec/classes/plugin/dhcp_browser_spec.rb index b7e5e011f..e96b5a5e2 100644 --- a/spec/classes/plugin/dhcp_browser_spec.rb +++ b/spec/classes/plugin/dhcp_browser_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::dhcp_browser' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'dhcp_browser' end diff --git a/spec/classes/plugin/discovery_spec.rb b/spec/classes/plugin/discovery_spec.rb index 1b8eeac30..6ebb539dd 100644 --- a/spec/classes/plugin/discovery_spec.rb +++ b/spec/classes/plugin/discovery_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::discovery' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'discovery' end diff --git a/spec/classes/plugin/dlm_spec.rb b/spec/classes/plugin/dlm_spec.rb index d65deb6e4..dcb917af1 100644 --- a/spec/classes/plugin/dlm_spec.rb +++ b/spec/classes/plugin/dlm_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::dlm' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'dlm' end diff --git a/spec/classes/plugin/expire_hosts_spec.rb b/spec/classes/plugin/expire_hosts_spec.rb index 6e83ef40b..72263a48c 100644 --- a/spec/classes/plugin/expire_hosts_spec.rb +++ b/spec/classes/plugin/expire_hosts_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::expire_hosts' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'expire_hosts' end diff --git a/spec/classes/plugin/git_templates_spec.rb b/spec/classes/plugin/git_templates_spec.rb index b674ca223..b03839332 100644 --- a/spec/classes/plugin/git_templates_spec.rb +++ b/spec/classes/plugin/git_templates_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::git_templates' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'git_templates' end diff --git a/spec/classes/plugin/google_spec.rb b/spec/classes/plugin/google_spec.rb index df9ba9b53..a012c1742 100644 --- a/spec/classes/plugin/google_spec.rb +++ b/spec/classes/plugin/google_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::google' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'google' end diff --git a/spec/classes/plugin/hdm_spec.rb b/spec/classes/plugin/hdm_spec.rb index c70ab3481..1b9bcf6b5 100644 --- a/spec/classes/plugin/hdm_spec.rb +++ b/spec/classes/plugin/hdm_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::hdm' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'hdm' end diff --git a/spec/classes/plugin/host_extra_validator_spec.rb b/spec/classes/plugin/host_extra_validator_spec.rb index 0a171b505..60e66c18f 100644 --- a/spec/classes/plugin/host_extra_validator_spec.rb +++ b/spec/classes/plugin/host_extra_validator_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::host_extra_validator' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'host_extra_validator' end diff --git a/spec/classes/plugin/kernel_care_spec.rb b/spec/classes/plugin/kernel_care_spec.rb index d0426cbba..9fea97181 100644 --- a/spec/classes/plugin/kernel_care_spec.rb +++ b/spec/classes/plugin/kernel_care_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::kernel_care' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'kernel_care' end diff --git a/spec/classes/plugin/kubevirt_spec.rb b/spec/classes/plugin/kubevirt_spec.rb index 30685e2d3..dedcb3ebf 100644 --- a/spec/classes/plugin/kubevirt_spec.rb +++ b/spec/classes/plugin/kubevirt_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::kubevirt' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'kubevirt' end diff --git a/spec/classes/plugin/leapp_spec.rb b/spec/classes/plugin/leapp_spec.rb index 93c115a36..465547570 100644 --- a/spec/classes/plugin/leapp_spec.rb +++ b/spec/classes/plugin/leapp_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'foreman::plugin::leapp' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'leapp' it { should contain_foreman__plugin('remote_execution') } it { should contain_foreman__plugin('ansible') } diff --git a/spec/classes/plugin/monitoring_spec.rb b/spec/classes/plugin/monitoring_spec.rb index a7ca720f0..3d8115e90 100644 --- a/spec/classes/plugin/monitoring_spec.rb +++ b/spec/classes/plugin/monitoring_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::monitoring' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'monitoring' end diff --git a/spec/classes/plugin/netbox_spec.rb b/spec/classes/plugin/netbox_spec.rb index 9f1293023..423bf16ad 100644 --- a/spec/classes/plugin/netbox_spec.rb +++ b/spec/classes/plugin/netbox_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::netbox' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'netbox' end diff --git a/spec/classes/plugin/omaha_spec.rb b/spec/classes/plugin/omaha_spec.rb index a18d63c8e..c642b5479 100644 --- a/spec/classes/plugin/omaha_spec.rb +++ b/spec/classes/plugin/omaha_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::omaha' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'omaha' end diff --git a/spec/classes/plugin/proxmox_spec.rb b/spec/classes/plugin/proxmox_spec.rb index 7a43616f9..325ea2157 100644 --- a/spec/classes/plugin/proxmox_spec.rb +++ b/spec/classes/plugin/proxmox_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::proxmox' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'fog_proxmox' end diff --git a/spec/classes/plugin/puppet_spec.rb b/spec/classes/plugin/puppet_spec.rb index c9f35e386..151adb0f6 100644 --- a/spec/classes/plugin/puppet_spec.rb +++ b/spec/classes/plugin/puppet_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::puppet' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'puppet' end diff --git a/spec/classes/plugin/rescue_spec.rb b/spec/classes/plugin/rescue_spec.rb index 9d99852ee..805635b26 100644 --- a/spec/classes/plugin/rescue_spec.rb +++ b/spec/classes/plugin/rescue_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::rescue' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'rescue' end diff --git a/spec/classes/plugin/rh_cloud_spec.rb b/spec/classes/plugin/rh_cloud_spec.rb index d843536ba..cb5daf67a 100644 --- a/spec/classes/plugin/rh_cloud_spec.rb +++ b/spec/classes/plugin/rh_cloud_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::rh_cloud' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'rh_cloud' end diff --git a/spec/classes/plugin/salt_spec.rb b/spec/classes/plugin/salt_spec.rb index ab5ca3762..714e90fee 100644 --- a/spec/classes/plugin/salt_spec.rb +++ b/spec/classes/plugin/salt_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe 'foreman::plugin::salt' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'salt' it { should contain_foreman__plugin('tasks') } end diff --git a/spec/classes/plugin/scc_manager_spec.rb b/spec/classes/plugin/scc_manager_spec.rb index fba13dfd5..9a255feb3 100644 --- a/spec/classes/plugin/scc_manager_spec.rb +++ b/spec/classes/plugin/scc_manager_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::scc_manager' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'scc_manager' end diff --git a/spec/classes/plugin/snapshot_management_spec.rb b/spec/classes/plugin/snapshot_management_spec.rb index fc9cd3d97..0abc750d3 100644 --- a/spec/classes/plugin/snapshot_management_spec.rb +++ b/spec/classes/plugin/snapshot_management_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::snapshot_management' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'snapshot_management' end diff --git a/spec/classes/plugin/statistics_spec.rb b/spec/classes/plugin/statistics_spec.rb index 9d66d5c36..e2e1abf97 100644 --- a/spec/classes/plugin/statistics_spec.rb +++ b/spec/classes/plugin/statistics_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::statistics' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'statistics' end diff --git a/spec/classes/plugin/templates_spec.rb b/spec/classes/plugin/templates_spec.rb index 6e08279fc..ebeb5e600 100644 --- a/spec/classes/plugin/templates_spec.rb +++ b/spec/classes/plugin/templates_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::templates' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'templates' end diff --git a/spec/classes/plugin/vault_spec.rb b/spec/classes/plugin/vault_spec.rb index 0632fe4a1..3701aa362 100644 --- a/spec/classes/plugin/vault_spec.rb +++ b/spec/classes/plugin/vault_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::vault' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'vault' end diff --git a/spec/classes/plugin/virt_who_configure_spec.rb b/spec/classes/plugin/virt_who_configure_spec.rb index a30fa03e1..ca4c3d59c 100644 --- a/spec/classes/plugin/virt_who_configure_spec.rb +++ b/spec/classes/plugin/virt_who_configure_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::virt_who_configure' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'virt_who_configure' end diff --git a/spec/classes/plugin/webhooks_spec.rb b/spec/classes/plugin/webhooks_spec.rb index 41780770e..28b716ff2 100644 --- a/spec/classes/plugin/webhooks_spec.rb +++ b/spec/classes/plugin/webhooks_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::webhooks' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'webhooks' end diff --git a/spec/classes/plugin/wreckingball_spec.rb b/spec/classes/plugin/wreckingball_spec.rb index 03d81765e..4b137156d 100644 --- a/spec/classes/plugin/wreckingball_spec.rb +++ b/spec/classes/plugin/wreckingball_spec.rb @@ -1,5 +1,6 @@ require 'spec_helper' describe 'foreman::plugin::wreckingball' do + let(:params) { {} } include_examples 'basic foreman plugin tests', 'wreckingball' end diff --git a/spec/support/plugin.rb b/spec/support/plugin.rb index f53144f3c..f1fa974ee 100644 --- a/spec/support/plugin.rb +++ b/spec/support/plugin.rb @@ -5,4 +5,15 @@ let(:pre_condition) { 'include foreman' } it { should compile.with_all_deps } it { should contain_foreman__plugin(name) } + + context 'with ensure = 1.2.3-4' do + let(:params) do + super().merge(ensure: '1.2.3-4') + end + + it do + should contain_foreman__plugin(name) + .with_version('1.2.3-4') + end + end end