Skip to content

Commit

Permalink
Ability to specify enabled puppet classes through :classes config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ehelms committed Aug 23, 2021
1 parent 0216c9f commit ba87491
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/kafo/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion lib/kafo/kafo_configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit ba87491

Please sign in to comment.