From ba87491e3c6e4953cbc99fe10901662bdff31c36 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Mon, 23 Aug 2021 17:31:04 +0000 Subject: [PATCH] Ability to specify enabled puppet classes through :classes config Provide the ability to specify if a class is enabled or disabled through the classes configuration option rather than through the answer file. This is a progressive option, as it takes precedence over values in the answer file but continues to respect answer file if no data is found in the classes option. --- lib/kafo/configuration.rb | 6 +++--- lib/kafo/kafo_configure.rb | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/kafo/configuration.rb b/lib/kafo/configuration.rb index e7e1b598..32854173 100644 --- a/lib/kafo/configuration.rb +++ b/lib/kafo/configuration.rb @@ -134,15 +134,15 @@ def modules @data.map do |name, values| if (class_config = app[:classes][name.to_sym]) - can_disable = class_config[:can_disable] || false + can_disable = class_config[:can_disable] || true excluded_params = class_config[:exclude] || [] + enabled = class_config[:enabled] else can_disable = true excluded_params = [] + enabled = !!values || values.is_a?(Hash) end - enabled = !!values || values.is_a?(Hash) - puppet_mod = PuppetModule.new( name, configuration: self, diff --git a/lib/kafo/kafo_configure.rb b/lib/kafo/kafo_configure.rb index 9fe2fda2..6228646f 100644 --- a/lib/kafo/kafo_configure.rb +++ b/lib/kafo/kafo_configure.rb @@ -446,7 +446,13 @@ def parse_app_arguments def parse_cli_arguments # enable/disable modules according to CLI - config.modules.each { |mod| send("enable_#{mod.name}?") ? mod.enable : mod.disable } + config.modules.each do |mod| + send("enable_#{mod.name}?") ? mod.enable : mod.disable + + if config.app.dig(:classes, mod.identifier.to_sym) + config.app[:classes][mod.identifier.to_sym][:enabled] = true + end + end # set and reset values coming from CLI arguments params.each do |param|