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