Puppet Function: wmflib::resource::ips
- Defined in:
- modules/wmflib/functions/resource/ips.pp
- Function type:
- Puppet Language
Summary
function to return a list of ips running a specific resource This function relies on data being present in puppetdb. This means that new nodes will be returned after their first successful puppet run using the specified resource. It also means that nodes will be removed from the results once they have been purged from puppetdb. This currently happens when a server has failed to run puppet for 14 daysOverview
SPDX-License-Identifier: Apache-2.0
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'modules/wmflib/functions/resource/ips.pp', line 10
function wmflib::resource::ips (
Wmflib::Resource::Type $resource,
Variant[Wmflib::Sites, Array[Wmflib::Sites]] $location = [],
Optional[String[1]] $resource_title = undef,
) >> Array[Stdlib::IP::Address] {
$_resource = wmflib::resource::capitalize($resource)
$_title = $resource_title ? {
undef => '',
default => " and title = \"${resource_title}\"",
}
# TODO: need a better way to determine site
# this doesn't work for wikimedia.org domains
$_location = Array($location, true)
$site_constraint = $_location.empty ? {
true => '',
default => " and certname ~ \"${_location.join('|')}\"",
}
$subquery = @("PQL")
resources {
type = "${_resource}" ${_title}${site_constraint}
}
| PQL
puppetdb::query_facts(['ipaddress', 'ipaddress6'], $subquery).values.map |$_facts| {
[$_facts['ipaddress'], $_facts['ipaddress6']]
}.flatten.sort.unique
}
|