-
-
Save 20after4/742dba22b6ea5a42072e7933ab055036 to your computer and use it in GitHub Desktop.
beta shell script and bash completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST="$1" | |
shift | |
ssh $@ deployment-$HOST.deployment-prep.eqiad.wmflabs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_beta() | |
{ | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=( $(compgen -W "$(cat ~/bin/beta-instances | grep -oP 'deployment-\K[^.]+' | tr '\n' ' ')" -- $cur) ) | |
} | |
complete -F _beta beta |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deployment-phab02.eqiad.wmflabs | |
deployment-phab01.eqiad.wmflabs | |
deployment-poolcounter04.eqiad.wmflabs | |
deployment-tin.eqiad.wmflabs | |
deployment-mira.eqiad.wmflabs | |
deployment-prometheus01.eqiad.wmflabs | |
deployment-jobrunner02.eqiad.wmflabs | |
deployment-apertium02.eqiad.wmflabs | |
deployment-mediawiki05.eqiad.wmflabs | |
deployment-mediawiki06.eqiad.wmflabs | |
deployment-mediawiki04.eqiad.wmflabs | |
deployment-fluorine02.eqiad.wmflabs | |
deployment-db04.eqiad.wmflabs | |
deployment-db03.eqiad.wmflabs | |
deployment-pdfrender.eqiad.wmflabs | |
deployment-kafka05.eqiad.wmflabs | |
deployment-parsoid09.eqiad.wmflabs | |
deployment-sca03.eqiad.wmflabs | |
deployment-salt02.eqiad.wmflabs | |
deployment-memc05.eqiad.wmflabs | |
deployment-memc04.eqiad.wmflabs | |
deployment-kafka01.eqiad.wmflabs | |
deployment-ircd.eqiad.wmflabs | |
deployment-kafka03.eqiad.wmflabs | |
deployment-changeprop.eqiad.wmflabs | |
deployment-imagescaler01.eqiad.wmflabs | |
deployment-ores-redis.eqiad.wmflabs | |
deployment-mathoid.eqiad.wmflabs | |
deployment-restbase01.eqiad.wmflabs | |
deployment-sca02.eqiad.wmflabs | |
deployment-sca01.eqiad.wmflabs | |
deployment-ms-be02.eqiad.wmflabs | |
deployment-ms-be01.eqiad.wmflabs | |
deployment-ms-fe01.eqiad.wmflabs | |
deployment-sentry01.eqiad.wmflabs | |
deployment-conftool.eqiad.wmflabs | |
deployment-kafka04.eqiad.wmflabs | |
deployment-aqs01.eqiad.wmflabs | |
deployment-eventlogging04.eqiad.wmflabs | |
deployment-conf03.eqiad.wmflabs | |
deployment-eventlogging03.eqiad.wmflabs | |
deployment-tmh01.eqiad.wmflabs | |
deployment-cache-upload04.eqiad.wmflabs | |
deployment-cache-text04.eqiad.wmflabs | |
deployment-puppetmaster.eqiad.wmflabs | |
deployment-logstash2.eqiad.wmflabs | |
deployment-restbase02.eqiad.wmflabs | |
deployment-zookeeper01.eqiad.wmflabs | |
deployment-zotero01.eqiad.wmflabs | |
deployment-urldownloader.eqiad.wmflabs | |
deployment-elastic08.eqiad.wmflabs | |
deployment-elastic07.eqiad.wmflabs | |
deployment-elastic06.eqiad.wmflabs | |
deployment-elastic05.eqiad.wmflabs | |
deployment-apertium01.eqiad.wmflabs | |
deployment-mx.eqiad.wmflabs | |
deployment-redis02.eqiad.wmflabs | |
deployment-redis01.eqiad.wmflabs | |
deployment-pdf02.eqiad.wmflabs | |
deployment-pdf01.eqiad.wmflabs | |
deployment-stream.eqiad.wmflabs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
original: https://github.com/yuvipanda/personal-wiki/blob/master/project-dsh-generator.py | |
Simple script that generates hosts files usable with dsh/pssh | |
for runnign administrative actions on all hosts in a particular | |
labs project. Salt is just way too unreliable to be useful | |
for this purpose. | |
Hits the wikitech API. | |
You can execute commands via pssh like: | |
pssh -t0 -p4 -h <hostgroup> '<command>' | |
This sets parallelism to 4, tweak as necessary. | |
""" | |
import json | |
import sys | |
from urllib.request import urlopen | |
project_spec = sys.argv[1] | |
if project_spec == 'all-instances': | |
projects_url = 'https://wikitech.wikimedia.org/w/api.php?action=query&list=novaprojects&format=json' | |
projects = json.loads(urlopen(projects_url).read().decode('utf-8'))['query']['novaprojects'] | |
else: | |
projects = [project_spec] | |
instances = [] | |
for project_name in projects: | |
api_url = 'https://wikitech.wikimedia.org/w/api.php' \ | |
'?action=query&list=novainstances&niregion=eqiad&format=json' \ | |
'&niproject=%s' % project_name | |
data = json.loads(urlopen(api_url).read().decode('utf-8')) | |
for instance in data['query']['novainstances']: | |
instances.append(instance['name'] + ".eqiad.wmflabs") | |
with open(project_spec, 'w') as f: | |
f.write("\n".join(instances)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment