2 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
10 lines << "# This file has been autogenerated and pushed by puppet. Edit static-components.yaml in puppet."
11 lines << "# <master> <service> <source host> <directory> <extra push hosts, comma separated> <hosts to not mirror this component to>"
13 # this is the list of static mirrors, or, technically, the list of
14 # nodes with the roles::static_mirror class applied to it. this should
15 # be populated from outside the template from PuppetDB, see:
16 # modules/roles/manifests/static_base.pp
17 mirrors = @static_mirrors
19 config = YAML.load(File.open('/etc/puppet/modules/roles/misc/static-components.yaml').read)
22 config['mirrors'].each do |mirror, mc|
23 if not mirrors.include?(mirror)
24 fail("static-components.yaml defines mirror #{mirror} but we do not know of it")
28 config['components'].each_pair do |component_name, component_conf|
29 %w{exclude-mirrors extra-push limit-mirrors}.each do |key|
30 component_conf[key] = [] unless component_conf.has_key?(key)
33 srchost, srcpath = component_conf['source'].split(':', 2)
35 if not component_conf['exclude-mirrors'].empty? and \
36 not component_conf['limit-mirrors'].empty? then
37 fail("Component #{component_name} specifies both exclude-mirrors and limit-mirrors.")
40 # In the end, we care about an exclude list, so let's invert limit-mirror and turn it into an exclude list
41 if not component_conf['limit-mirrors'].empty? then
42 component_conf['exclude-mirrors'] = mirrors.select do |m|
43 not component_conf['limit-mirrors'].include?(m)
47 # mirrors may also specify limits as components-include (thus excluding all others). Apply this
48 config['mirrors'].each do |mirror, mc|
49 mirror_components_include = mc.fetch('components-include', [])
50 next if mirror_components_include.empty?
52 if not mirror_components_include.include?(component_name)
53 next if component_conf['exclude-mirrors'].include?(mirror) # do not exclude twice
54 component_conf['exclude-mirrors'] << mirror
58 exclude = component_conf['exclude-mirrors'].sort().join(',')
59 exclude = '-' if exclude == ""
60 extrapush = component_conf['extra-push'].sort().join(',')
61 extrapush = '-' if extrapush == ""
63 lines << "#{component_conf['master']} #{component_name} #{srchost} #{srcpath} #{extrapush} #{exclude}"