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>"
14 config = YAML.load(File.open('/etc/puppet/modules/roles/misc/static-components.yaml').read)
15 mirrors = scope.lookupvar('site::roles')['static_mirror']
17 config['mirrors'].each do |mirror, mc|
18 if not mirrors.include?(mirror)
19 fail("static-components.yaml defines mirror #{mirror} but we do not know of it")
23 config['components'].each_pair do |component_name, component_conf|
24 %w{exclude-mirrors extra-push limit-mirrors}.each do |key|
25 component_conf[key] = [] unless component_conf.has_key?(key)
28 srchost, srcpath = component_conf['source'].split(':', 2)
30 if not component_conf['exclude-mirrors'].empty? and \
31 not component_conf['limit-mirrors'].empty? then
32 fail("Component #{component_name} specifies both exclude-mirrors and limit-mirrors.")
35 # In the end, we care about an exclude list, so let's invert limit-mirror and turn it into an exclude list
36 if not component_conf['limit-mirrors'].empty? then
37 component_conf['exclude-mirrors'] = mirrors.select do |m|
38 not component_conf['limit-mirrors'].include?(m)
42 # mirrors may also specify limits as components-include (thus excluding all others). Apply this
43 config['mirrors'].each do |mirror, mc|
44 mirror_components_include = mc.fetch('components-include', [])
45 next if mirror_components_include.empty?
47 if not mirror_components_include.include?(component_name)
48 next if component_conf['exclude-mirrors'].include?(mirror) # do not exclude twice
49 component_conf['exclude-mirrors'] << mirror
53 exclude = component_conf['exclude-mirrors'].sort().join(',')
54 exclude = '-' if exclude == ""
55 extrapush = component_conf['extra-push'].sort().join(',')
56 extrapush = '-' if extrapush == ""
58 lines << "#{component_conf['master']} #{component_name} #{srchost} #{srcpath} #{extrapush} #{exclude}"