diff --git a/docker/ircbot/local-build.sh b/docker/ircbot/local-build.sh index a5bb125d96..8f34da5ff9 100755 --- a/docker/ircbot/local-build.sh +++ b/docker/ircbot/local-build.sh @@ -11,6 +11,8 @@ if [ ! -d .zuul-siblings/opendev.org/opendev/meetbot ]; then fi pushd .zuul-siblings/opendev.org/opendev ln -sf ../../../meetbot meetbot + popd fi -docker build . -f Dockerfile --build-arg "ZUUL_SIBLINGS=opendev.org/opendev/meetbot" +docker build . -f Dockerfile --build-arg \ + ZUUL_SIBLINGS="opendev.org/opendev/meetbot" diff --git a/playbooks/roles/statusbot/README.rst b/playbooks/roles/statusbot/README.rst new file mode 100644 index 0000000000..72e529188a --- /dev/null +++ b/playbooks/roles/statusbot/README.rst @@ -0,0 +1,4 @@ +Deploy statusbot + +.. note:: This should be turned into a Limnoria plugin. Until this + is done, we run it as a separate daemon. diff --git a/playbooks/roles/statusbot/defaults/main.yaml b/playbooks/roles/statusbot/defaults/main.yaml new file mode 100644 index 0000000000..7c9c5a67cc --- /dev/null +++ b/playbooks/roles/statusbot/defaults/main.yaml @@ -0,0 +1,19 @@ +statusbot_nick: opendevstatus +statusbot_pass: '' +statusbot_server: 'irc.oftc.net' + +statusbot_auth_nicks: + - ianw + +statusbot_channels: + - opendev-sandbox + +statusbot_wiki_url: 'https://wiki.openstack.org/w/api.php' +# https://wiki.openstack.org/wiki/Infrastructure_Status +statusbot_wiki_pageid: '1781' +statusbot_wiki_successpageid: '7717' +statusbot_wiki_successpageurl: 'https://wiki.openstack.org/wiki/Successes' +statusbot_wiki_thankspageid: '37700' +statusbot_wiki_thankspageurl: 'https://wiki.openstack.org/wiki/Thanks' +statusbot_irclogs_url : 'http://eavesdrop.openstack.org/irclogs/%(chan)s/%(chan)s.%(date)s.log.html' +statusbot_twitter: True diff --git a/playbooks/roles/statusbot/files/docker-compose.yaml b/playbooks/roles/statusbot/files/docker-compose.yaml new file mode 100644 index 0000000000..4f293fc418 --- /dev/null +++ b/playbooks/roles/statusbot/files/docker-compose.yaml @@ -0,0 +1,18 @@ +# Version 2 is the latest that is supported by docker-compose in +# Ubuntu Xenial. +version: '2' + +services: + statusbot: + image: docker.io/opendevorg/statusbot:latest + network_mode: host + restart: always + logging: + driver: syslog + options: + tag: "docker-statusbot" + volumes: + # This contains the main config, channel config, and ssh key + - /etc/statusbot:/etc/statusbot + - /var/lib/statusbot:/var/lib/statusbot + - /var/log/statusbot:/var/log/statusbot diff --git a/playbooks/roles/statusbot/files/logging.config b/playbooks/roles/statusbot/files/logging.config new file mode 100644 index 0000000000..6676738a36 --- /dev/null +++ b/playbooks/roles/statusbot/files/logging.config @@ -0,0 +1,44 @@ +[loggers] +keys=root,statusbot,irc + +[handlers] +keys=console,debug,normal + +[formatters] +keys=simple + +[logger_root] +level=WARNING +handlers=console + +[logger_statusbot] +level=DEBUG +handlers=debug,normal +qualname=statusbot + +[logger_irc] +level=DEBUG +handlers=debug,normal +qualname=irc + +[handler_console] +level=WARNING +class=StreamHandler +formatter=simple +args=(sys.stdout,) + +[handler_debug] +level=DEBUG +class=logging.handlers.TimedRotatingFileHandler +formatter=simple +args=('/var/log/statusbot/statusbot_debug.log', 'midnight', 1, 30,) + +[handler_normal] +level=INFO +class=logging.handlers.TimedRotatingFileHandler +formatter=simple +args=('/var/log/statusbot/statusbot.log', 'midnight', 1, 30,) + +[formatter_simple] +format=%(asctime)s %(levelname)s %(name)s: %(message)s +datefmt= diff --git a/playbooks/roles/statusbot/tasks/main.yaml b/playbooks/roles/statusbot/tasks/main.yaml new file mode 100644 index 0000000000..d728b5edd7 --- /dev/null +++ b/playbooks/roles/statusbot/tasks/main.yaml @@ -0,0 +1,52 @@ +- name: Ensure statusbot directories + file: + state: directory + path: '{{ item }}' + owner: root + group: root + mode: 0755 + loop: + - /etc/statusbot + - /etc/statusbot-docker + - /var/log/statusbot + - /var/lib/statusbot + - /var/lib/statusbot/www + +- name: Put statusbot config in place + template: + src: statusbot.config.j2 + dest: /etc/statusbot/statusbot.config + owner: root + group: root + mode: 0600 + register: statusbot_config_copied + +- name: Put statusbot logging config in place + copy: + src: logging.config + dest: /etc/statusbot/logging.config + owner: root + group: root + mode: 0644 + +- name: Put docker-compose file in place + copy: + src: docker-compose.yaml + dest: /etc/statusbot-docker/docker-compose.yaml + owner: root + group: root + mode: 0644 + +- name: Run docker-compose pull + shell: + cmd: docker-compose pull + chdir: /etc/statusbot-docker/ + +- name: Run docker-compose up + shell: + cmd: "docker-compose up -d {{ statusbot_config_copied is changed | ternary('--force-recreate', '') }}" + chdir: /etc/statusbot-docker/ + +- name: Run docker prune to cleanup unneeded images + shell: + cmd: docker image prune -f diff --git a/playbooks/roles/statusbot/templates/statusbot.config.j2 b/playbooks/roles/statusbot/templates/statusbot.config.j2 new file mode 100644 index 0000000000..047293413a --- /dev/null +++ b/playbooks/roles/statusbot/templates/statusbot.config.j2 @@ -0,0 +1,46 @@ +[ircbot] +nick={{ statusbot_nick }} +pass={{ statusbot_nick_password }} +server={{ statusbot_server }} +port=6697 + +channels={{ statusbot_channels | join(',') }} + +nicks={{ statusbot_auth_nicks | join(',') }} +lockfile=/var/run/statusbot/statusbot.pid +log_config=/etc/statusbot/logging.config + +[wiki] +username={{ statusbot_wiki_user }} +password={{ statusbot_wiki_password }} +url={{ statusbot_wiki_url }} +pageid={{ statusbot_wiki_pageid }} + +{% if statusbot_wiki_successpageid %} +successpageid={{ statusbot_wiki_successpageid }} +{% endif %} +{% if statusbot_wiki_successpageurl %} +successpageurl={{ statusbot_wiki_successpageurl }} +{% endif %} +{% if statusbot_wiki_thankspageid %} +thankspageid={{ statusbot_wiki_thankspageid }} +{% endif %} +{% if statusbot_wiki_thankspageurl %} +thankspageurl={{ statusbot_wiki_thankspageurl }} +{% endif %} + +{% if statusbot_irclogs_url %} +[irclogs] +url={{ statusbot_irclogs_url }} +{% endif %} + +[alertfile] +dir=/var/lib/statusbot/www + +{% if statusbot_twitter %} +[twitter] +consumer_key={{ statusbot_twitter_key }} +consumer_secret={{ statusbot_twitter_secret }} +access_token_key={{ statusbot_twitter_token_key }} +access_token_secret={{ statusbot_twitter_token_secret }} +{% endif %} diff --git a/playbooks/service-eavesdrop.yaml b/playbooks/service-eavesdrop.yaml index 1aaf44682b..517a6d3f82 100644 --- a/playbooks/service-eavesdrop.yaml +++ b/playbooks/service-eavesdrop.yaml @@ -7,4 +7,5 @@ - sync-project-config - accessbot - gerritbot + - statusbot - limnoria diff --git a/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 b/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 index 47a6bc7226..f313c59388 100644 --- a/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 +++ b/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 @@ -1,5 +1,6 @@ openstack_meetbot_password: password statusbot_nick_password: password +statusbot_wiki_user: username statusbot_wiki_password: password statusbot_twitter_key: twitter_key statusbot_twitter_secret: twitter_secret diff --git a/testinfra/test_eavesdrop.py b/testinfra/test_eavesdrop.py index 312ae7debc..f6f691e1a2 100644 --- a/testinfra/test_eavesdrop.py +++ b/testinfra/test_eavesdrop.py @@ -36,3 +36,9 @@ def test_gerritbot_running(host): cmd = host.run("docker ps -a") assert 'gerritbot-docker_gerritbot_1' in cmd.stdout assert 'Up ' in cmd.stdout + +def test_statusbot_running(host): + # Check that the container hasn't stopped + cmd = host.run("docker ps -a") + assert 'statusbot-docker_statusbot_1' in cmd.stdout + assert 'Up ' in cmd.stdout diff --git a/zuul.d/system-config-run.yaml b/zuul.d/system-config-run.yaml index 4c3416ac05..5240255426 100644 --- a/zuul.d/system-config-run.yaml +++ b/zuul.d/system-config-run.yaml @@ -124,12 +124,12 @@ description: | Run the playbook for an eavesdrop server. required-projects: - - opendev/ansible-role-puppet - opendev/system-config - openstack/project-config requires: - accessbot-container-image - gerritbot-container-image + - statusbot-container-image - ircbot-container-image nodeset: nodes: @@ -148,6 +148,8 @@ '/var/log/apache2': logs '/var/log/acme.sh': logs '/etc/apache2': logs + '/var/log/statusbot': logs + '/etc/statusbot': logs files: - playbooks/service-eavesdrop.yaml - playbooks/run-accessbot.yaml @@ -156,6 +158,7 @@ - playbooks/roles/accessbot - playbooks/roles/limnoria - playbooks/roles/logrotate + - playbooks/roles/statusbot - playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 - docker/accessbot/ - testinfra/test_eavesdrop.py