static-components: rename variables
authorPeter Palfrader <peter@palfrader.org>
Tue, 10 Sep 2019 19:58:23 +0000 (21:58 +0200)
committerPeter Palfrader <peter@palfrader.org>
Tue, 10 Sep 2019 19:58:23 +0000 (21:58 +0200)
modules/roles/templates/static-mirroring/static-components.conf.erb

index 117828e..aa43c9a 100644 (file)
@@ -14,35 +14,35 @@ lines << "# <master> <service> <source host> <directory> <extra push hosts, comm
 config = YAML.load(File.open('/etc/puppet/modules/roles/misc/static-components.yaml').read)
 mirrors = scope.lookupvar('site::roles')['static_mirror']
 
-config['components'].each_pair do |componentconf|
+config['components'].each_pair do |component_name, component_conf|
        %w{exclude-mirrors extra-push limit-mirrors}.each do |key|
-               conf[key] = [] unless conf.has_key?(key)
+               component_conf[key] = [] unless component_conf.has_key?(key)
        end
 
-       srchost, srcpath = conf['source'].split(':', 2)
+       srchost, srcpath = component_conf['source'].split(':', 2)
 
        config['mirrors'].each do |mirror, mc|
                next unless mirrors.include?(mirror)
 
-               if mc.has_key?('components-include') and not mc['components-include'].include?(component)
-                       conf['exclude-mirrors'] << mirror
+               if mc.has_key?('components-include') and not mc['components-include'].include?(component_name)
+                       component_conf['exclude-mirrors'] << mirror
                end
        end
-       if conf['limit-mirrors'].size > 0
+       if component_conf['limit-mirrors'].size > 0
                mirrors.each do |mirror|
-                       if not conf['limit-mirrors'].include?(mirror)
-                               next if conf['exclude-mirrors'].include?(mirror) # if it's already excluded, do not add it again
-                               conf['exclude-mirrors'] << 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
                end
        end
 
-       exclude = conf['exclude-mirrors'].join(',')
+       exclude = component_conf['exclude-mirrors'].join(',')
        exclude = '-' unless exclude != ""
-       extrapush = conf['extra-push'].join(',')
+       extrapush = component_conf['extra-push'].join(',')
        extrapush = '-' unless extrapush != ""
 
-       lines << "#{conf['master']} #{component} #{srchost} #{srcpath} #{extrapush} #{exclude}"
+       lines << "#{component_conf['master']} #{component_name} #{srchost} #{srcpath} #{extrapush} #{exclude}"
 end
 lines.join("\n")
 %>