From cc95c6482b74fbdbe9469b359ce642df67c10c8c Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Tue, 14 Feb 2017 16:57:23 -0800
Subject: [PATCH] openqa: update roles for openqa_fedora_tools repo split

We split fedora_openqa and createhdds out into their own repos,
this should adapt to the change (I hope).
---
 roles/openqa/dispatcher/tasks/main.yml        | 30 +++++++++++--------
 .../templates/openqa_consumer.py.j2           |  9 +++---
 .../dispatcher/templates/schedule.conf.j2     | 20 ++++++++-----
 roles/openqa/server/files/createhdds          |  2 +-
 roles/openqa/server/tasks/main.yml            | 12 ++++----
 5 files changed, 43 insertions(+), 30 deletions(-)

diff --git a/roles/openqa/dispatcher/tasks/main.yml b/roles/openqa/dispatcher/tasks/main.yml
index da87403149..1a3fc0de22 100644
--- a/roles/openqa/dispatcher/tasks/main.yml
+++ b/roles/openqa/dispatcher/tasks/main.yml
@@ -16,8 +16,10 @@
 # - wikitcms_password
 ##      string - password for relval_user
 # - deployment_type
-##      string - Fedora Infrastructure thing; for this role, decides
-##               whether and where to submit wiki results
+##      string - Fedora Infrastructure thing; for this role, the
+##               fedora_openqa config file will be set appropriately
+##               for infra deployments if this is set, so don't set
+##               it for private deployments
 #
 # When all of the above are set, a wikitcms 'credentials' file will
 # be created and result submission to the wiki will be enabled. If
@@ -75,25 +77,29 @@
     chdir: /root/openQA-python-client
   when: "gitclient|changed or instclient.rc > 0"
 
-# We check this out to a different place from the 'server' task, because
-# otherwise it's hard to make sure we install each time it changes.
-- name: Check out openqa_fedora_tools
+- name: Remove old openqa_fedora_tools checkout
+  file: path=/root/openqa_fedora_tools-dispatcher state=absent
+
+- name: Remove old fedora-openqa-schedule script
+  file: path=/usr/bin/fedora-openqa-schedule state=absent
+
+- name: Check out fedora_openqa (scheduler / reporter tool)
   git:
-    repo: https://bitbucket.org/rajcze/openqa_fedora_tools
-    dest: /root/openqa_fedora_tools-dispatcher
+    repo: https://pagure.io/fedora-qa/fedora_openqa.git
+    dest: /root/fedora_openqa
   register: gittools
 
-- name: Check if openqa_fedora_tools has ever been installed
-  stat: path=/usr/bin/fedora-openqa-schedule
+- name: Check if fedora_openqa has ever been installed
+  stat: path=/usr/bin/fedora-openqa
   register: insttools
   changed_when: "1 != 1"
   failed_when: "1 != 1"
   check_mode: no
 
-- name: Install openqa_fedora_tools
+- name: Install fedora_openqa
   command: "python setup.py install"
   args:
-    chdir: /root/openqa_fedora_tools-dispatcher/scheduler
+    chdir: /root/fedora_openqa
   when: "gittools|changed or not insttools.stat.exists"
   notify:
   - restart fedmsg-hub
@@ -103,7 +109,7 @@
   tags:
   - config
 
-- name: Create fedora-openqa-schedule config directory
+- name: Create fedora_openqa config directory
   file: path=/etc/fedora-openqa state=directory owner=root group=root mode=0755
 
 - name: Write schedule.conf
diff --git a/roles/openqa/dispatcher/templates/openqa_consumer.py.j2 b/roles/openqa/dispatcher/templates/openqa_consumer.py.j2
index 33219f72dc..b78e9a180c 100644
--- a/roles/openqa/dispatcher/templates/openqa_consumer.py.j2
+++ b/roles/openqa/dispatcher/templates/openqa_consumer.py.j2
@@ -1,13 +1,14 @@
 config = {
 {% if openqa_consumer %}
-    'fedora_openqa_schedule.consumer.enabled': True,
+    'fedora_openqa.scheduler.prod.enabled': True,
 {% endif %}
 {% if wikitcms_user is defined and wikitcms_password is defined %}
 {% if deployment_type is defined and deployment_type == 'prod' %}
-    'fedora_openqa_schedule.wiki.consumer.prod.enabled': True,
-    'fedora_openqa_schedule.resultsdb.reporter.prod.enabled': True,
+    'fedora_openqa.reporter.wiki.prod.enabled': True,
+    'fedora_openqa.reporter.resultsdb.prod.enabled': True,
 {% elif deployment_type is defined and deployment_type == 'stg' %}
-    'fedora_openqa_schedule.wiki.consumer.stg.enabled': True,
+    'fedora_openqa.reporter.wiki.stg.enabled': True,
+    'fedora_openqa.reporter.resultsdb.stg.enabled': True,
 {% endif %}
 {% endif %}
 }
diff --git a/roles/openqa/dispatcher/templates/schedule.conf.j2 b/roles/openqa/dispatcher/templates/schedule.conf.j2
index ab79ae819d..64b5c4bb72 100644
--- a/roles/openqa/dispatcher/templates/schedule.conf.j2
+++ b/roles/openqa/dispatcher/templates/schedule.conf.j2
@@ -1,14 +1,18 @@
 [report]
-openqa_url: https://{{ external_hostname|default(ansible_nodename) }}
-{% if wikitcms_user is defined and wikitcms_password is defined %}
-submit_wiki: true
-submit_resultsdb: true
-{% else %}
-submit_wiki: false
-submit_resultsdb: false
-{% endif %}
 {% if deployment_type is defined and deployment_type == 'prod' %}
 resultsdb_url: http://resultsdb01.qa.fedoraproject.org/resultsdb_api/api/v2.0/
+wiki_hostname: fedoraproject.org
+prod_oqa_baseurl: https://{{ external_hostname|default(ansible_nodename) }}
+prod_wiki_hostname: fedoraproject.org
+prod_wiki_report: true
+prod_rdb_url: http://resultsdb01.qa.fedoraproject.org/resultsdb_api/api/v2.0/
+prod_rdb_report: true
 {% elif deployment_type is defined and deployment_type == 'stg' %}
 resultsdb_url: http://resultsdb-stg01.qa.fedoraproject.org/resultsdb_api/api/v2.0/
+wiki_hostname: stg.fedoraproject.org
+stg_oqa_baseurl: https://{{ external_hostname|default(ansible_nodename) }}
+stg_wiki_hostname: stg.fedoraproject.org
+stg_wiki_report: true
+stg_rdb_url: http://resultsdb-stg01.qa.fedoraproject.org/resultsdb_api/api/v2.0/
+stg_rdb_report: true
 {% endif %}
diff --git a/roles/openqa/server/files/createhdds b/roles/openqa/server/files/createhdds
index c76019d8b6..794d80450e 100644
--- a/roles/openqa/server/files/createhdds
+++ b/roles/openqa/server/files/createhdds
@@ -1,4 +1,4 @@
 #!/bin/sh
 
 cd /var/lib/openqa/share/factory/hdd/fixed
-LIBGUESTFS_BACKEND=direct withlock /var/lock/createhdds.lock /root/openqa_fedora_tools/tools/createhdds.py all --clean
+LIBGUESTFS_BACKEND=direct withlock /var/lock/createhdds.lock /root/createhdds/createhdds.py all --clean
diff --git a/roles/openqa/server/tasks/main.yml b/roles/openqa/server/tasks/main.yml
index 957290b6be..27dbe1a39c 100644
--- a/roles/openqa/server/tasks/main.yml
+++ b/roles/openqa/server/tasks/main.yml
@@ -120,11 +120,13 @@
   become_user: geekotest
   when: "(testsbranch.stdout.find('Not a git repository') != -1) or (testsbranch.stdout.find('On branch master') != -1)"
 
-- name: Check out openqa_fedora_tools
+- name: Remove old openqa_fedora_tools checkout
+  file: path=/root/openqa_fedora_tools state=absent
+
+- name: Check out createhdds
   git:
-    repo: https://bitbucket.org/rajcze/openqa_fedora_tools
-    dest: /root/openqa_fedora_tools
-  register: git_result
+    repo: https://pagure.io/fedora-qa/createhdds.git
+    dest: /root/createhdds
 
 - name: Create asset directories
   file: path={{ item }} state=directory owner=geekotest group=root mode=0755
@@ -139,7 +141,7 @@
   copy: src=createhdds dest=/etc/cron.daily/createhdds owner=root group=root mode=0755
 
 - name: Check if any hard disk images need (re)building
-  command: "/root/openqa_fedora_tools/tools/createhdds.py check"
+  command: "/root/createhdds/createhdds.py check"
   args:
     chdir: /var/lib/openqa/share/factory/hdd/fixed
   register: diskcheck