diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2017-10-20 16:09:19 +0100 |
---|---|---|
committer | Ben Brown <ben.brown@codethink.co.uk> | 2017-10-23 11:11:13 +0000 |
commit | d28577c8f0f602e92e722ac0d2561b86bf618484 (patch) | |
tree | e05a6abf1944032e510da5a3ec5997cf449f5ed0 /baserock_webserver | |
parent | b4c27d66732db3851726e6ae4b0dce77c3275731 (diff) | |
download | infrastructure-d28577c8f0f602e92e722ac0d2561b86bf618484.tar.gz |
Move the Gitlab bot into the baserock_webserver machine
A few changes required to get it running on Fedora, but nothing major.
Diffstat (limited to 'baserock_webserver')
-rw-r--r-- | baserock_webserver/gitlab-bot/config.js | 66 | ||||
-rw-r--r-- | baserock_webserver/gitlab-bot/gitlab-bst-bot.conf | 19 | ||||
-rw-r--r-- | baserock_webserver/gitlab-bot/gitlab-bst-bot.service.in | 12 | ||||
-rw-r--r-- | baserock_webserver/gitlab-bot/gitlab_buildstream_secret.yml | 8 | ||||
-rw-r--r-- | baserock_webserver/instance-gitlab-bot-config.yml | 44 |
5 files changed, 149 insertions, 0 deletions
diff --git a/baserock_webserver/gitlab-bot/config.js b/baserock_webserver/gitlab-bot/config.js new file mode 100644 index 00000000..13b66e13 --- /dev/null +++ b/baserock_webserver/gitlab-bot/config.js @@ -0,0 +1,66 @@ +module.exports = { + // IRC server to connect to. + servers: { + gimp: 'irc.gimp.org', + freenode: 'irc.freenode.net' + }, + + // List of channels / people to report to. + triggers: [ + { + project: 'baserock/definitions', + network: 'freenode', + reports: { + '#baserock': ['merge_request', 'issue'] + } + }, + { + project: 'baserock/infrastructure', + network: 'freenode', + reports: { + '#baserock': ['merge_request', 'issue'] + } + }, + { + project: 'baserock/lorries', + network: 'freenode', + reports: { + '#baserock': ['merge_request', 'issue'] + } + }, + { + project: 'baserock/ybd', + network: 'freenode', + reports: { + '#baserock': ['merge_request', 'issue'] + } + }, + { + project: 'BuildStream/buildstream', + network: 'gimp', + reports: { + '#buildstream': ['push', 'merge_request', 'issue'] + } + }, + ], + + // IRC nick/names for the bot + nick: 'gitlab-br-bot', + userName: 'gitlab-br-bot', + realName: 'Gitlab Bot provided by Baserock', + + // Secret as entered in the Gitlab Webhook instance. + secret: '{{ gitlab_buildstream_secret }}', + + // Port on which to run. + port: 1337, + + // Network interface on which to run the webhook server. + hostname: '0.0.0.0', + + // Instance of lstu to shorten links -- keep empty to not use. + //lstu: 'https://lstu.fr', + + // Whether the irc client debug messages should be printed. + debug: true +} diff --git a/baserock_webserver/gitlab-bot/gitlab-bst-bot.conf b/baserock_webserver/gitlab-bot/gitlab-bst-bot.conf new file mode 100644 index 00000000..b34026a8 --- /dev/null +++ b/baserock_webserver/gitlab-bot/gitlab-bst-bot.conf @@ -0,0 +1,19 @@ +# /etc/init/gitlab-bst-bot.conf + +description "Gitlab irc notifications server" + +start on startup +stop on shutdown + + +# Automatically Respawn: +respawn +respawn limit 99 5 + +setuid ubuntu +setgid ubuntu + +script + cd {{ gitlab_to_irc_install_location }} + exec sudo node index.js +end script diff --git a/baserock_webserver/gitlab-bot/gitlab-bst-bot.service.in b/baserock_webserver/gitlab-bot/gitlab-bst-bot.service.in new file mode 100644 index 00000000..cc3f5af4 --- /dev/null +++ b/baserock_webserver/gitlab-bot/gitlab-bst-bot.service.in @@ -0,0 +1,12 @@ +[Unit] +Description = Gitlab irc notifications server + +[Service] +Type = simple +ExecStart = /usr/bin/node {{ gitlab_to_irc_install_location }}/index.js +User = fedora +Group = fedora +Restart = on-failure + +[Install] +WantedBy=default.target diff --git a/baserock_webserver/gitlab-bot/gitlab_buildstream_secret.yml b/baserock_webserver/gitlab-bot/gitlab_buildstream_secret.yml new file mode 100644 index 00000000..53ae22e0 --- /dev/null +++ b/baserock_webserver/gitlab-bot/gitlab_buildstream_secret.yml @@ -0,0 +1,8 @@ +$ANSIBLE_VAULT;1.1;AES256 +35376536656664653761336331643738343738643365623832626464313335383439623761313434 +3634373330363634666566353766373862643266373431380a396566356261653937343131666338 +36356133636465323135643264306461386437613064636164656361656264616239333236353430 +3734343639313337620a396431356335376638316339646362633436613065646366326134363032 +61613132383832346637396666373761363230666234303530646533336363653139643264623862 +39616663643138623538383336323538313963396463653563643134326664643930303135383039 +623636663031333934633261663436303735 diff --git a/baserock_webserver/instance-gitlab-bot-config.yml b/baserock_webserver/instance-gitlab-bot-config.yml new file mode 100644 index 00000000..4fb7710e --- /dev/null +++ b/baserock_webserver/instance-gitlab-bot-config.yml @@ -0,0 +1,44 @@ +# Instance-specific configuration for the BuildStream Gitlab IRC bot +--- +- hosts: webserver + vars_files: + - gitlab-bot/gitlab_buildstream_secret.yml + vars: + - gitlab_to_irc_url: https://gitlab.com/palvarez89/gitlab-to-irc + - gitlab_to_irc_branch: master + - gitlab_to_irc_install_location: /home/fedora/gitlab-to-irc + tasks: + - name: Install Git + dnf: name=git state=latest + become: yes + + - name: Install Node.js + dnf: name=nodejs state=latest + become: yes + + - name: Download gitlab-to-irc sources + git: + repo: "{{ gitlab_to_irc_url }}" + version: "{{ gitlab_to_irc_branch }}" + dest: "{{ gitlab_to_irc_install_location }}" + + - name: Update packages based on package.json to their latest version. + npm: + path: "{{ gitlab_to_irc_install_location }}" + state: latest + + - name: Install bot configuration file + template: + src: gitlab-bot/config.js + dest: "{{ gitlab_to_irc_install_location }}/config.js" + + - name: Install service for the bot + template: src=gitlab-bot/gitlab-bst-bot.service.in dest=/etc/systemd/system/gitlab-bst-bot.service + become: yes + + - name: Restart bot service + service: + name: gitlab-bst-bot + enabled: yes + state: restarted + become: yes |