summaryrefslogtreecommitdiffstats
path: root/deploy_kgb.py
diff options
context:
space:
mode:
authorMattia Rizzolo <mattia@mapreri.org>2015-04-16 18:28:31 +0200
committerHolger Levsen <holger@layer-acht.org>2015-04-16 18:31:04 +0200
commit59ca867373215c8490ac0af045254926bba0676e (patch)
tree7ea9064d1f952360ba369c98f77646bfb3a6d280 /deploy_kgb.py
parent36798da6b02677f0d8d3808bb0541148d8e1c314 (diff)
downloadjenkins.debian.net-59ca867373215c8490ac0af045254926bba0676e.tar.xz
add deploy_kgb.py to automatically generate kgb confs. also change owner of /srv/jenkins to jenkins-adm instead of root. Another TODO bullet down!
Diffstat (limited to 'deploy_kgb.py')
-rwxr-xr-xdeploy_kgb.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/deploy_kgb.py b/deploy_kgb.py
new file mode 100755
index 00000000..fe4a5d84
--- /dev/null
+++ b/deploy_kgb.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+#
+# Copyright © 2015 Mattia Rizzolo <mattia@mapreri.org>
+# Licensed under GPL-2
+#
+# Depends: python3 python3-yaml
+#
+# Generates the kgb client configuration, using the passwords listed in the
+# file pointed by `secrets`.
+
+import os
+import yaml
+
+secrets = '/srv/jenkins/kgb/secrets.yml'
+outputs = '/srv/jenkins/kgb'
+
+with open(secrets) as fd:
+ passwords = yaml.load(fd)
+
+channels = [
+ {'name': 'debian-boot', 'id': 'jenkins-debian-boot'},
+ {'name': 'debian-bootstrap', 'id': 'jenkins-debian-bootstrap'},
+ {'name': 'debian-cinnamon', 'id': 'jenkins-debian-cinnamon'},
+ {'name': 'debian-edu', 'id': 'jenkins-debian-edu'},
+ {'name': 'debian-haskell', 'id': 'jenkins-debian-haskell'},
+ {'name': 'debian-qa', 'id': 'jenkins-debian-qa'},
+ {'name': 'debian-reproducible', 'id': 'jenkins-debian-reproducible'},
+ {'name': 'debian-ruby', 'id': 'pkg-ruby-extras'},
+ {'name': 'dvswitch', 'id': 'jenkins-dvswitch'},
+]
+
+template = """repo-id: '{repo_id}'
+password: {password}
+use-irc-notices: 1
+servers:
+ # KGB-0, run by dmn@debian.org
+ - uri: http://kgb.ktnx.org:9418/
+ # KGB-1, run by tincho@debian.org
+ - uri: http://kgb.tincho.org:9418/
+ # KGB-2, run by gregoa@debian.org
+ - uri: http://colleen.colgarra.priv.at:8080/
+status-dir: /srv/jenkins/kgb/client-status/
+"""
+
+for chan in channels:
+ print('Producing conf for #' + chan['name'] + '...')
+ conf = template.format(repo_id=chan['id'],
+ password=passwords[chan['name']])
+ if not os.access(outputs, os.R_OK):
+ try:
+ os.makedirs(outputs, exist_ok=True)
+ except OSError as e:
+ if e.errno == 17: # that's "file exists" error
+ print('ERROR: the output directory ' + outputs +
+ ' has bad permissions')
+ raise
+ if not os.access(outputs, os.W_OK):
+ print('ERROR: the output directory ' + outputs +
+ ' has bad permissions')
+ raise OSError
+ filename = outputs + chan['name'] + '.conf'
+ with open(filename, 'w') as fd:
+ fd.write(conf)
+
+print('All kgb configurations generated successfully')