From d28577c8f0f602e92e722ac0d2561b86bf618484 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 20 Oct 2017 16:09:19 +0100 Subject: Move the Gitlab bot into the baserock_webserver machine A few changes required to get it running on Fedora, but nothing major. --- README.md | 2 + baserock_bots/config.js | 66 ---------------------- baserock_bots/gitlab-bot.yml | 41 -------------- baserock_bots/gitlab-bst-bot.conf | 19 ------- baserock_bots/gitlab_buildstream_secret.yml | 8 --- baserock_webserver/gitlab-bot/config.js | 66 ++++++++++++++++++++++ baserock_webserver/gitlab-bot/gitlab-bst-bot.conf | 19 +++++++ .../gitlab-bot/gitlab-bst-bot.service.in | 12 ++++ .../gitlab-bot/gitlab_buildstream_secret.yml | 8 +++ baserock_webserver/instance-gitlab-bot-config.yml | 44 +++++++++++++++ 10 files changed, 151 insertions(+), 134 deletions(-) delete mode 100644 baserock_bots/config.js delete mode 100644 baserock_bots/gitlab-bot.yml delete mode 100644 baserock_bots/gitlab-bst-bot.conf delete mode 100644 baserock_bots/gitlab_buildstream_secret.yml create mode 100644 baserock_webserver/gitlab-bot/config.js create mode 100644 baserock_webserver/gitlab-bot/gitlab-bst-bot.conf create mode 100644 baserock_webserver/gitlab-bot/gitlab-bst-bot.service.in create mode 100644 baserock_webserver/gitlab-bot/gitlab_buildstream_secret.yml create mode 100644 baserock_webserver/instance-gitlab-bot-config.yml diff --git a/README.md b/README.md index 0e327230..b4dc1892 100644 --- a/README.md +++ b/README.md @@ -400,6 +400,8 @@ To deploy to production: ansible-playbook -i hosts baserock_webserver/image-config.yml ansible-playbook -i hosts baserock_webserver/instance-config.yml + ansible-playbook -i hosts baserock_webserver/instance-gitlab-bot-config.yml \ + --vault-password-file ~/vault-infra-pass The webserver machine runs [Cherokee](http://cherokee-project.com/). You can use the `cherokee-admin` configuration UI, by connecting to the webserver diff --git a/baserock_bots/config.js b/baserock_bots/config.js deleted file mode 100644 index 13b66e13..00000000 --- a/baserock_bots/config.js +++ /dev/null @@ -1,66 +0,0 @@ -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_bots/gitlab-bot.yml b/baserock_bots/gitlab-bot.yml deleted file mode 100644 index 396ac8a7..00000000 --- a/baserock_bots/gitlab-bot.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Instance-specific configuration for the BuildStream Gitlab IRC bot ---- -- hosts: paste - vars_files: - - 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/ubuntu/gitlab-to-irc - tasks: - - 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: config.js - dest: "{{ gitlab_to_irc_install_location }}/config.js" - - - - name: Install service for the bot - template: - src: gitlab-bst-bot.conf - dest: /etc/init/gitlab-bst-bot.conf - become: yes - - - - name: Restart bot service - service: - name: gitlab-bst-bot - enabled: yes - state: restarted - become: yes - diff --git a/baserock_bots/gitlab-bst-bot.conf b/baserock_bots/gitlab-bst-bot.conf deleted file mode 100644 index b34026a8..00000000 --- a/baserock_bots/gitlab-bst-bot.conf +++ /dev/null @@ -1,19 +0,0 @@ -# /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_bots/gitlab_buildstream_secret.yml b/baserock_bots/gitlab_buildstream_secret.yml deleted file mode 100644 index 53ae22e0..00000000 --- a/baserock_bots/gitlab_buildstream_secret.yml +++ /dev/null @@ -1,8 +0,0 @@ -$ANSIBLE_VAULT;1.1;AES256 -35376536656664653761336331643738343738643365623832626464313335383439623761313434 -3634373330363634666566353766373862643266373431380a396566356261653937343131666338 -36356133636465323135643264306461386437613064636164656361656264616239333236353430 -3734343639313337620a396431356335376638316339646362633436613065646366326134363032 -61613132383832346637396666373761363230666234303530646533336363653139643264623862 -39616663643138623538383336323538313963396463653563643134326664643930303135383039 -623636663031333934633261663436303735 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 -- cgit v1.2.1