From: Peter Palfrader Date: Tue, 10 Sep 2019 20:30:31 +0000 (+0200) Subject: Make static-components.conf.erb more readable, maybe X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=23a6880aa601023e20c26f4db60862aa820db206;p=mirror%2Fdsa-puppet.git Make static-components.conf.erb more readable, maybe --- diff --git a/modules/roles/misc/static-components.yaml b/modules/roles/misc/static-components.yaml index 78bf0317d..16aee4f4c 100644 --- a/modules/roles/misc/static-components.yaml +++ b/modules/roles/misc/static-components.yaml @@ -13,6 +13,8 @@ # whitelist of mirrors ('limit-mirrors') that they should # be synced to, thus excluding all others. # +# Empty lists do not count. +# # A mirrorrun for a component can only be triggered by its source # host and any hosts listed in that components "extra-push" list. diff --git a/modules/roles/templates/static-mirroring/static-components.conf.erb b/modules/roles/templates/static-mirroring/static-components.conf.erb index fb89f4634..a7234f981 100644 --- a/modules/roles/templates/static-mirroring/static-components.conf.erb +++ b/modules/roles/templates/static-mirroring/static-components.conf.erb @@ -14,6 +14,12 @@ lines << "# 0 - mirrors.each do |mirror| - if not component_conf['limit-mirrors'].include?(mirror) - next if component_conf['exclude-mirrors'].include?(mirror) # if it's already excluded, do not add it again - component_conf['exclude-mirrors'] << mirror - end + + # mirrors may also specify limits as components-include (thus excluding all others). Apply this + config['mirrors'].each do |mirror, mc| + mirror_components_include = mc.fetch('components-include', []) + next if mirror_components_include.empty? + + if not mirror_components_include.include?(component_name) + next if component_conf['exclude-mirrors'].include?(mirror) # do not exclude twice + component_conf['exclude-mirrors'] << mirror end end - exclude = component_conf['exclude-mirrors'].sort().join(',') - exclude = '-' unless exclude != "" + exclude = '-' if exclude == "" extrapush = component_conf['extra-push'].sort().join(',') - extrapush = '-' unless extrapush != "" + extrapush = '-' if extrapush == "" lines << "#{component_conf['master']} #{component_name} #{srchost} #{srcpath} #{extrapush} #{exclude}" end