get list of mirrors from puppet
authorPeter Palfrader <peter@palfrader.org>
Tue, 10 Sep 2019 20:33:55 +0000 (22:33 +0200)
committerPeter Palfrader <peter@palfrader.org>
Tue, 10 Sep 2019 20:33:55 +0000 (22:33 +0200)
modules/roles/manifests/static/base.pp
modules/roles/templates/static-mirroring/static-components.conf.erb

index 8c66303..1de7054 100644 (file)
@@ -1,5 +1,8 @@
 # the base class defining tings common for all three static classes (master, mirror, source)
 class roles::static::base {
+  $query = 'nodes[certname] { resources { type = "Class" and title = "Roles::Static_mirror" } }'
+  $static_mirrors = sort(puppetdb_query($query).map |$value| { $value["certname"] })
+
   file { '/etc/static-components.conf':
     content => template('roles/static-mirroring/static-components.conf.erb'),
   }
index a7234f9..c04a3a5 100644 (file)
@@ -10,9 +10,14 @@ lines = []
 lines << "# This file has been autogenerated and pushed by puppet.  Edit static-components.yaml in puppet."
 lines << "# <master> <service> <source host> <directory> <extra push hosts, comma separated> <hosts to not mirror this component to>"
 
+# this is the list of static mirrors, or, technically, the list of
+# nodes with the roles::static_mirror class applied to it. this should
+# be populated from outside the template from PuppetDB, see:
+# modules/roles/manifests/static_base.pp
+mirrors = @static_mirrors
 
 config = YAML.load(File.open('/etc/puppet/modules/roles/misc/static-components.yaml').read)
-mirrors = scope.lookupvar('site::roles')['static_mirror']
+
 
 config['mirrors'].each do |mirror, mc|
        if not mirrors.include?(mirror)