From 82c966e6dafc624325a5963736c3890ceb350f2d Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 9 Jul 2021 18:39:59 -0700 Subject: [PATCH] Run matrix-eavesdrop on eavesdrop Thin runs the new matrix-eavesdrop bot on the eavesdrop server. It will write logs out to the limnoria logs directory, which is mounted inside the container. Change-Id: I867eec692f63099b295a37a028ee096c24109a2e --- playbooks/roles/matrix-eavesdrop/README.rst | 1 + .../files/docker-compose.yaml | 17 +++++++ .../roles/matrix-eavesdrop/tasks/main.yaml | 44 +++++++++++++++++++ .../matrix-eavesdrop/templates/config.yaml | 13 ++++++ playbooks/service-eavesdrop.yaml | 1 + .../templates/group_vars/eavesdrop.yaml.j2 | 1 + zuul.d/infra-prod.yaml | 3 ++ zuul.d/project.yaml | 6 ++- zuul.d/system-config-run.yaml | 4 ++ 9 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 playbooks/roles/matrix-eavesdrop/README.rst create mode 100644 playbooks/roles/matrix-eavesdrop/files/docker-compose.yaml create mode 100644 playbooks/roles/matrix-eavesdrop/tasks/main.yaml create mode 100644 playbooks/roles/matrix-eavesdrop/templates/config.yaml diff --git a/playbooks/roles/matrix-eavesdrop/README.rst b/playbooks/roles/matrix-eavesdrop/README.rst new file mode 100644 index 0000000000..5d6895c97c --- /dev/null +++ b/playbooks/roles/matrix-eavesdrop/README.rst @@ -0,0 +1 @@ +Run a matrix-eavesdrop bot diff --git a/playbooks/roles/matrix-eavesdrop/files/docker-compose.yaml b/playbooks/roles/matrix-eavesdrop/files/docker-compose.yaml new file mode 100644 index 0000000000..d352e2e50e --- /dev/null +++ b/playbooks/roles/matrix-eavesdrop/files/docker-compose.yaml @@ -0,0 +1,17 @@ +# Version 2 is the latest that is supported by docker-compose in +# Ubuntu Xenial. +version: '2' + +services: + eavesdrop: + image: docker.io/opendevorg/matrix-eavesdrop:latest + network_mode: host + restart: always + logging: + driver: syslog + options: + tag: "docker-matrix-eavesdrop" + volumes: + - /var/lib/matrix-eavesdrop/data:/data + - /var/lib/matrix-eavesdrop/config:/config + - /var/lib/limnoria/opendev/logs/ChannelLogger/oftc:/logs diff --git a/playbooks/roles/matrix-eavesdrop/tasks/main.yaml b/playbooks/roles/matrix-eavesdrop/tasks/main.yaml new file mode 100644 index 0000000000..6e00fea949 --- /dev/null +++ b/playbooks/roles/matrix-eavesdrop/tasks/main.yaml @@ -0,0 +1,44 @@ +- name: Ensure bot directories + file: + state: directory + path: '/var/lib/matrix-eavesdrop/{{ item }}' + mode: 0755 + loop: + - data + - config + +- name: Install eavesdrop config + template: + src: config.yaml + dest: /var/lib/matrix-eavesdrop/config/config.yaml + owner: root + group: root + mode: 0644 + +- name: Ensure /etc/matrix-eavesdrop-docker directory + file: + state: directory + path: /etc/matrix-eavesdrop-docker + mode: 0755 + +- name: Put docker-compose file in place + copy: + src: docker-compose.yaml + dest: /etc/matrix-eavesdrop-docker/docker-compose.yaml + owner: root + group: root + mode: 0644 + +- name: Run docker-compose pull + shell: + cmd: docker-compose pull + chdir: /etc/matrix-eavesdrop-docker/ + +- name: Run docker-compose up + shell: + cmd: "docker-compose up -d" + chdir: /etc/matrix-eavesdrop-docker/ + +- name: Run docker prune to cleanup unneeded images + shell: + cmd: docker image prune -f diff --git a/playbooks/roles/matrix-eavesdrop/templates/config.yaml b/playbooks/roles/matrix-eavesdrop/templates/config.yaml new file mode 100644 index 0000000000..51884815b4 --- /dev/null +++ b/playbooks/roles/matrix-eavesdrop/templates/config.yaml @@ -0,0 +1,13 @@ +config: + data_dir: /data + homeserver: https://opendev.ems.host + user_id: "@logs:opendev.org" + password: "{{ matrix_logs_password }}" + log_dir: /logs + +# For each room, add the following: +# id: The full Matrix ID of the room +# path: A relative path to log_dir, or begin with '/' for an absolute path. +rooms: + - id: "#test:opendev.org" + path: "#test" diff --git a/playbooks/service-eavesdrop.yaml b/playbooks/service-eavesdrop.yaml index 517a6d3f82..0331f4a333 100644 --- a/playbooks/service-eavesdrop.yaml +++ b/playbooks/service-eavesdrop.yaml @@ -9,3 +9,4 @@ - gerritbot - statusbot - limnoria + - matrix-eavesdrop diff --git a/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 b/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 index 1d98e6f18b..978a051d37 100644 --- a/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 +++ b/playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 @@ -53,3 +53,4 @@ limnoria_oftc_channels: - '#opendev-sandbox' statusbot_channels: - 'opendev-sandbox' +matrix_logs_password: password diff --git a/zuul.d/infra-prod.yaml b/zuul.d/infra-prod.yaml index c68c5f65de..600072d227 100644 --- a/zuul.d/infra-prod.yaml +++ b/zuul.d/infra-prod.yaml @@ -473,8 +473,11 @@ - playbooks/roles/limnoria - playbooks/roles/statusbot - playbooks/roles/logrotate + - playbooks/roles/matrix-eavesdrop + - playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 - docker/accessbot/ - docker/ircbot + - docker/matrix-eavesdrop - job: name: infra-prod-run-accessbot diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 13988c548f..87b10545de 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -21,6 +21,8 @@ soft: true - name: system-config-build-image-ircbot soft: true + - name: system-config-build-image-matrix-eavesdrop + soft: true - system-config-run-codesearch: dependencies: - name: opendev-buildset-registry @@ -155,6 +157,8 @@ soft: true - name: system-config-upload-image-ircbot soft: true + - name: system-config-upload-image-matrix-eavesdrop + soft: true - system-config-run-codesearch: dependencies: - name: opendev-buildset-registry @@ -252,7 +256,7 @@ - name: opendev-buildset-registry - name: system-config-build-image-python-builder-3.9 soft: true - - system-config-build-image-matrix-eavesdrop: + - system-config-upload-image-matrix-eavesdrop: dependencies: - name: opendev-buildset-registry - name: system-config-build-image-python-builder-3.9 diff --git a/zuul.d/system-config-run.yaml b/zuul.d/system-config-run.yaml index 5240255426..c6e0763fee 100644 --- a/zuul.d/system-config-run.yaml +++ b/zuul.d/system-config-run.yaml @@ -131,6 +131,7 @@ - gerritbot-container-image - statusbot-container-image - ircbot-container-image + - matrix-eavesdrop-container-image nodeset: nodes: - name: bridge.openstack.org @@ -158,9 +159,12 @@ - playbooks/roles/accessbot - playbooks/roles/limnoria - playbooks/roles/logrotate + - playbooks/roles/matrix-eavesdrop - playbooks/roles/statusbot - playbooks/zuul/templates/group_vars/eavesdrop.yaml.j2 - docker/accessbot/ + - docker/ircbot + - docker/matrix-eavesdrop - testinfra/test_eavesdrop.py - job: