Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F31953281
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
CDanis
Jul 29 2020, 3:47 PM
2020-07-29 15:47:17 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
#!/bin/bash
set -e
set -u
set -o pipefail
yaml2json() {
ruby -rjson -ryaml -e 'puts YAML.safe_load(File.open("'"$1"'").read, [], [], true).to_json'
}
# Conftool's node YAMLs are structured like:
# datacentername: # e.g. eqsin
# clustername: # e.g. cache_text
# hostname: [servicenames] # e.g. cp5007.eqsin.wmnet: [varnish-fe, ats-be, ats-tls]
# This constructs a JSON map that looks like:
# "cp5007.eqsin.wmnet": ["cache_text.ats-be","cache_text.ats-tls","cache_text.varnish-fe"]
conftool_nodes() {
(for FILE in /var/lib/git/operations/puppet/conftool-data/node/*.yaml ; do
yaml2json "$FILE" | jq '.[] | to_entries[] | .key as $cluster | .value | map_values(map($cluster + "." + .) | unique)'
done) | jq -Ss add
}
# Construct a map that maps from top-level service names (e.g. 'text') to conftool cluster.service names (e.g. 'cache_text.varnish-fe')
# Intended for use as a jq --slurpfile.
lvspools_to_conftool_clusterservices() {
yaml2json /var/lib/git/operations/puppet/hieradata/common/service.yaml \
| jq '.["service::catalog"] | to_entries[] | {(.key): (.value.lvs.conftool.cluster + "." + .value.lvs.conftool.service)}'\
| jq -Ss add
}
# Fetches from puppetdb all the profile::lvs::realserver resources.
realserver_resources() {
curl -sG https://puppetdb1002.eqiad.wmnet/pdb/query/v4/resources \
--data-urlencode query='["=", "title", "Profile::Lvs::Realserver"]'
}
# Constructs a map of FQDN --> conftool cluster.service names.
realservers() {
realserver_resources \
| jq -S '[.[] | {(.certname): (.parameters.pools | keys)}] | add | map_values(sort)' \
| jq -S --slurpfile conftoolname <( lvspools_to_conftool_clusterservices ) \
'map_values(map($conftoolname[0][.]) | unique)'
}
diff -u <(realservers | tr -d ,) <(conftool_nodes | tr -d ,)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8484649
Default Alt Text
raw.txt (1 KB)
Attached To
Mode
P12125 check_realserver_vs_conftool.sh
Attached
Detach File
Event Timeline
Log In to Comment