From: Peter Palfrader Date: Tue, 10 Sep 2019 20:33:55 +0000 (+0200) Subject: get list of mirrors from puppet X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=58f010ef882cbfec56daeafd4b993b40d7eca508;p=mirror%2Fdsa-puppet.git get list of mirrors from puppet --- diff --git a/modules/roles/manifests/static/base.pp b/modules/roles/manifests/static/base.pp index 8c66303ee..1de7054a1 100644 --- a/modules/roles/manifests/static/base.pp +++ b/modules/roles/manifests/static/base.pp @@ -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'), } diff --git a/modules/roles/templates/static-mirroring/static-components.conf.erb b/modules/roles/templates/static-mirroring/static-components.conf.erb index a7234f981..c04a3a56d 100644 --- a/modules/roles/templates/static-mirroring/static-components.conf.erb +++ b/modules/roles/templates/static-mirroring/static-components.conf.erb @@ -10,9 +10,14 @@ lines = [] lines << "# This file has been autogenerated and pushed by puppet. Edit static-components.yaml in puppet." lines << "# " +# 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)