From 8c9a7819920d2aa023e36408bdbbbd746f1b5235 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 2 Feb 2017 01:36:55 +0100 Subject: [PATCH] Report Autocloud results to ResultsDB Parking this on openqa01 because I *think* it's authed for RDB and I don't know if Autocloud boxes are. --- inventory/group_vars/autocloudreporter | 2 + inventory/inventory | 6 +++ playbooks/groups/openqa.yml | 10 +++-- roles/autocloudreporter/defaults/main.yml | 1 + roles/autocloudreporter/tasks/main.yml | 43 +++++++++++++++++++ .../templates/autocloudreporter.py.j2 | 9 ++++ 6 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 inventory/group_vars/autocloudreporter create mode 100644 roles/autocloudreporter/defaults/main.yml create mode 100644 roles/autocloudreporter/tasks/main.yml create mode 100644 roles/autocloudreporter/templates/autocloudreporter.py.j2 diff --git a/inventory/group_vars/autocloudreporter b/inventory/group_vars/autocloudreporter new file mode 100644 index 0000000000..18b6db1b2a --- /dev/null +++ b/inventory/group_vars/autocloudreporter @@ -0,0 +1,2 @@ +# This var should never be set for more than one machine +autocloudreporter_prod: true diff --git a/inventory/inventory b/inventory/inventory index 9728d48a00..2fd3854730 100644 --- a/inventory/inventory +++ b/inventory/inventory @@ -637,6 +637,12 @@ openqa01.qa.fedoraproject.org [relvalconsumer-test] openqa-stg01.qa.fedoraproject.org +# This group should only ever contain *ONE* system +# It should probably be autocloud itself, but I dunno if that box +# is authorized for ResultsDB currently +[autocloudreporter] +openqa01.qa.fedoraproject.org + [resultsdb:children] resultsdb-dev resultsdb-stg diff --git a/playbooks/groups/openqa.yml b/playbooks/groups/openqa.yml index 1dcd0084e6..d26e8b1c92 100644 --- a/playbooks/groups/openqa.yml +++ b/playbooks/groups/openqa.yml @@ -40,16 +40,18 @@ - "/srv/private/ansible/vars.yml" - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml -# relvalconsumer isn't particularly related to openQA in any way, -# we just put that role on these boxes as they're handy and there's -# nowhere more obviously correct. +# relvalconsumer and autocloudreporter aren't particularly related +# to openQA in any way, we just put those role on these boxes. There's +# nowhere more obviously correct for rvc and acr should be on an +# Autocloud box but I don't know if they're authed for RDB. roles: - { role: openqa/server, tags: ['openqa_server'] } - { role: openqa/dispatcher, tags: ['openqa_dispatcher'] } - { role: check-compose, tags: ['check-compose'] } - - { role: relvalconsumer, tags: ['relvalconsumer'] } - { role: fedmsg/base, tags: ['fedmsg_base', 'fedmsg'] } - { role: fedmsg/hub, tags: ['fedmsg_hub', 'fedmsg'] } + - { role: relvalconsumer, tags: ['relvalconsumer'] } + - { role: autocloudreporter, tags: ['autocloudreporter'] } handlers: - include: "{{ handlers }}/restart_services.yml" diff --git a/roles/autocloudreporter/defaults/main.yml b/roles/autocloudreporter/defaults/main.yml new file mode 100644 index 0000000000..e7cad51483 --- /dev/null +++ b/roles/autocloudreporter/defaults/main.yml @@ -0,0 +1 @@ +autocloudreporter_prod: false diff --git a/roles/autocloudreporter/tasks/main.yml b/roles/autocloudreporter/tasks/main.yml new file mode 100644 index 0000000000..5157845651 --- /dev/null +++ b/roles/autocloudreporter/tasks/main.yml @@ -0,0 +1,43 @@ +# This role reports Autocloud results to ResultsDB. There should +# always be exactly one host in infra with this role set up and +# autocloudreporter_prod set to True, so all results are reported +# once. +# +# Required vars +# +# Required vars with defaults +# - autocloudreporter_prod +## bool - whether this is the production instance. **SHOULD ONLY +## EVER BE TRUE ON ONE SYSTEM IN THE WORLD** +## default - False + +- name: Install required packages + dnf: name={{ item }} state=present + with_items: + - python2-fedfind + - python2-fedmsg-consumers + - python2-resultsdb_api + - python-setuptools + tags: + - packages + +- name: Check out autocloudreporter + git: + repo: https://pagure.io/fedora-qa/autocloudreporter.git + dest: /root/autocloudreporter + register: gitacr + +- name: Install autocloudreporter + command: "python setup.py install" + args: + chdir: /root/autocloudreporter + when: "gitacr|changed" + notify: + - restart fedmsg-hub + +- name: Enable fedmsg consumer + template: src=autocloudreporter.py.j2 dest=/etc/fedmsg.d/autocloudreporter.py owner=root group=root mode=0644 + notify: + - restart fedmsg-hub + tags: + - config diff --git a/roles/autocloudreporter/templates/autocloudreporter.py.j2 b/roles/autocloudreporter/templates/autocloudreporter.py.j2 new file mode 100644 index 0000000000..c7d38adba2 --- /dev/null +++ b/roles/autocloudreporter/templates/autocloudreporter.py.j2 @@ -0,0 +1,9 @@ +config = { +{% if autocloudreporter_prod %} + 'autocloudreporter.prod.enabled': True, + 'autocloudreporter.test.enabled': False, +{% else %} + 'autocloudreporter.prod.enabled': False, + 'autocloudreporter.test.enabled': False, +{% endif %} +}