2015-11-13 09:49:00 -08:00
# Required vars
# - openqa_email
## string - Email address of admin user
# - openqa_nickname
## string - Short name of admin user (shown in the web UI for e.g.)
# - openqa_fullname
## string - Full name of admin user
# - openqa_key
# - openqa_secret
## string - MUST be 16-character hexadecimals, and are secrets
# openqa_userid
## string - User ID of admin user: for Fedora should be a Fedora openID URL,
## http://fasname.id.fedoraproject.org
# Required vars with defaults
# - external_hostname
## string - The public hostname for the server (will be used as ServerName)
## default - ansible_nodename
# Optional vars
2016-03-19 16:28:09 -07:00
# - openqa_static_uid
## int - a static ID for the geekotest user and group if desired
## this is useful for NFS mounting openQA data files
2015-11-13 09:49:00 -08:00
# - openqa_dbname
## string - The name of the database to use
# - openqa_dbhost
## string - The hostname of the database server
# - openqa_dbuser
## string - The database username
# - openqa_dbpassword
## string - The database password
2016-03-19 16:08:15 -07:00
# - openqa_assetsize
## int - the asset size limit to set in GB (upstream default is 100GB)
## higher is recommended for normal Fedora testing, 300GB is good
2016-03-30 17:13:57 -07:00
## FIXME: this only works for pgsql ATM
2017-11-30 11:45:49 -08:00
# - openqa_assetsize_updates
## int - the asset size limit to set for update job groups in GB
## (upstream default is 100GB). Lower is recommended for normal
## Fedora testing, 50GB is good
## FIXME: this only works for pgsql ATM
2016-03-30 17:13:57 -07:00
# - deployment_type
## string - Fedora Infrastructure thing; for this role, decides
2017-03-14 12:55:51 -07:00
## whether to enable some openQA plugins that should be
## enabled only in Fedora infra. Don't set it outside
## Fedora infra.
2015-11-13 09:49:00 -08:00
#
# If openqa_dbhost is set, the others must be too, and the server will be
# configured to use a pgsql database accordingly. If openqa_dbhost is not
# set, the server will use a local SQLite database and the other values
# are ignored.
2016-03-19 16:28:09 -07:00
- name : Create geekotest group with static GID
group : "name=geekotest gid={{ openqa_static_uid }} system=yes"
when : "openqa_static_uid is defined"
2016-03-08 12:16:00 -08:00
2016-03-19 16:28:09 -07:00
- name : Create geekotest user with static UID
2016-03-08 12:16:00 -08:00
user :
name : geekotest
comment : "openQA user"
2016-03-19 16:28:09 -07:00
uid : "{{ openqa_static_uid }}"
2016-03-08 13:58:48 -08:00
group : geekotest
2016-03-08 12:16:00 -08:00
home : "/var/lib/openqa"
createhome : no
system : yes
shell : /sbin/nologin
2016-03-19 16:28:09 -07:00
when : "openqa_static_uid is defined"
2016-03-08 12:16:00 -08:00
2017-01-31 17:27:44 +01:00
# this is separate from the step below so we can easily flip it between
# stable and testing
2018-11-26 10:52:31 -08:00
- name : Install openQA packages (Python 2)
2018-10-09 13:50:39 -07:00
dnf :
name : [ 'openqa' , 'openqa-httpd' , 'openqa-plugin-fedmsg' , 'openqa-plugin-fedoraupdaterestart' ,
'python2-fedfind' , 'python3-fedfind' ]
state : present
enablerepo : "updates-testing"
2018-11-26 10:52:31 -08:00
when : "'python34-fedmsg' not in group_names"
tags :
- packages
- name : Install openQA packages (Python 3)
dnf :
name : [ 'openqa' , 'openqa-httpd' , 'openqa-plugin-fedmsg' , 'openqa-plugin-fedoraupdaterestart' ,
'python3-fedfind' ]
state : present
enablerepo : "updates-testing"
when : "'python34-fedmsg' in group_names"
2016-07-05 12:09:01 -07:00
tags :
- packages
2016-03-08 14:09:01 -08:00
2017-01-31 17:27:44 +01:00
- name : Install various other required packages
2018-10-09 13:50:39 -07:00
dnf :
name : [ 'libselinux-python' , 'git' , 'json_diff' , 'libselinux-utils' , 'libsemanage-python' ,
'nfs-utils' , 'perl(Class::DBI::Pg)' , 'expect' , 'libguestfs-tools-c' , 'libguestfs-xfs' ,
'libvirt-daemon-config-network' , 'libvirt-python3' , 'python3-libguestfs' ,
'virt-install' , 'withlock' ]
state : present
2015-11-13 09:49:00 -08:00
tags :
- packages
2016-09-06 12:30:26 -07:00
- name : Check test directory exists with correct ownership
file : path=/var/lib/openqa/share/tests/fedora state=directory owner=geekotest group=geekotest recurse=yes
# we don't want to run the checkout if the tests are on a non-standard
# branch, as that usually means we're messing around on staging and
# don't want the checkout reset to HEAD.
- name : Check if tests are checked out and on a non-standard branch
command : "git status"
args :
chdir : /var/lib/openqa/share/tests/fedora
register : testsbranch
failed_when : "1 != 1"
changed_when : "1 != 1"
2016-11-01 16:29:49 +00:00
check_mode : no
2016-09-06 12:30:26 -07:00
2015-11-13 09:49:00 -08:00
- name : Check out the tests
git :
2017-01-12 14:35:59 -08:00
repo : https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
2015-11-13 09:49:00 -08:00
dest : /var/lib/openqa/share/tests/fedora
2015-12-07 15:04:27 -08:00
register : gittests
2016-02-02 21:24:45 +00:00
become : true
become_user : geekotest
2017-09-07 10:39:57 -07:00
when : "(testsbranch.stderr.find('Not a git repository') != -1) or (testsbranch.stdout.find('On branch master') != -1 and testsbranch.stdout.find('Changes not staged') == -1)"
2015-11-13 09:49:00 -08:00
2017-02-14 16:57:23 -08:00
- name : Remove old openqa_fedora_tools checkout
file : path=/root/openqa_fedora_tools state=absent
- name : Check out createhdds
2015-11-13 09:49:00 -08:00
git :
2017-02-14 16:57:23 -08:00
repo : https://pagure.io/fedora-qa/createhdds.git
dest : /root/createhdds
2015-11-13 09:49:00 -08:00
- name : Create asset directories
file : path={{ item }} state=directory owner=geekotest group=root mode=0755
with_items :
- /var/lib/openqa/share/factory/iso
- /var/lib/openqa/share/factory/hdd
2016-10-19 11:17:58 -07:00
- /var/lib/openqa/share/factory/hdd/fixed
2015-11-13 09:49:00 -08:00
- /var/lib/openqa/share/factory/repo
2016-05-24 10:14:02 -07:00
- /var/lib/openqa/share/factory/other
2015-11-13 09:49:00 -08:00
2018-01-28 01:08:44 +01:00
#- name: Set up createhdds cron job
# copy: src=createhdds dest=/etc/cron.daily/createhdds owner=root group=root mode=0755
# While #1539330 is a thing, we probably don't want the servers
# crashing every day...
- name : Remove createhdds cron job (#1539330)
file : path=/etc/cron.daily/createhdds state=absent
2016-05-24 11:38:46 -07:00
2015-12-17 13:29:16 -08:00
- name : Check if any hard disk images need (re)building
2017-02-14 16:57:23 -08:00
command : "/root/createhdds/createhdds.py check"
2015-12-07 15:12:04 -08:00
args :
2016-10-24 17:15:20 -07:00
chdir : /var/lib/openqa/share/factory/hdd/fixed
2015-12-17 13:29:16 -08:00
register : diskcheck
failed_when : "1 != 1"
2016-01-12 17:21:36 -08:00
changed_when : "1 != 1"
2016-11-01 16:29:49 +00:00
check_mode : no
2015-12-07 15:12:04 -08:00
2016-07-04 09:37:05 -07:00
- name : Ensure libvirt is running if needed to create images
service : name=libvirtd enabled=yes state=started
2016-10-17 11:39:14 -07:00
when : "diskcheck.rc > 1"
2016-07-04 09:37:05 -07:00
2016-10-17 11:39:14 -07:00
# > 1 is not a typo; check exits with 1 if all images are present but some
# are outdated, and 2 if any images are missing. We only want to handle
# outright *missing* images here in the playbook (to handle the case of
# first deployment). Outdated images are handled by the daily cron run.
2018-02-23 17:13:25 -08:00
# disabled due to #1539330
#- name: Create hard disk images (this may take a long time!)
# command: "/etc/cron.daily/createhdds"
# when: "diskcheck.rc > 1"
# ignore_errors: yes
2015-11-17 14:16:25 -08:00
2015-11-13 09:49:00 -08:00
- name : Create exports file
2017-08-17 14:15:03 -07:00
template : src=exports.j2 dest=/etc/exports.d/openqa.exports owner=root group=root mode=0644
2015-11-13 09:49:00 -08:00
tags :
- config
- name : Enable and start NFS server
service : name=nfs-server enabled=yes state=started
- name : Set up Apache config
template : src=openqa.conf.httpd.j2 dest=/etc/httpd/conf.d/openqa.conf owner=root group=root mode=0644
2015-11-17 19:24:16 -08:00
notify :
- reload httpd
2015-11-13 09:49:00 -08:00
tags :
- config
- name : OpenQA config
2015-12-05 11:29:28 -08:00
template : src=openqa.ini.j2 dest=/etc/openqa/openqa.ini owner=geekotest group=root mode=0644
2015-11-13 09:49:00 -08:00
tags :
- config
- name : Create database
delegate_to : "{{ openqa_dbhost }}"
2016-02-02 21:24:45 +00:00
become_user : postgres
become : true
2016-01-06 21:58:31 +00:00
postgresql_db : db={{ openqa_dbname }}
2015-11-13 09:49:00 -08:00
when : "openqa_dbhost is defined"
- name : Ensure db user has access to database
delegate_to : "{{ openqa_dbhost }}"
2016-02-02 21:24:45 +00:00
become_user : postgres
become : true
2016-01-06 21:58:31 +00:00
postgresql_user : db={{ openqa_dbname }} user={{ openqa_dbuser }} password={{ openqa_dbpassword }} role_attr_flags=NOSUPERUSER
2015-11-13 09:49:00 -08:00
when : "openqa_dbhost is defined"
- name : Database config
template : src=database.ini.pgsql.j2 dest=/etc/openqa/database.ini owner=geekotest group=root mode=0640
when : "openqa_dbhost is defined"
tags :
- config
- name : Initialize database
2017-03-07 11:31:40 -08:00
shell : "/usr/share/openqa/script/initdb --user geekotest --init_database"
2015-11-13 09:49:00 -08:00
register : initdb
changed_when : "initdb.rc == 0"
2017-03-07 23:23:08 -08:00
failed_when : "(initdb.rc > 0) and (initdb.stdout is not defined or initdb.stdout.find('already exists') == -1)"
2015-11-13 09:49:00 -08:00
- name : Enable and start services
service : name={{ item }} enabled=yes state=started
register : services
with_items :
- openqa-scheduler
- openqa-webui
- openqa-websockets
- openqa-gru
2018-11-19 15:30:26 -08:00
- name : Enable and start openqa-livehandler.service (separate while stg is newer than prod)
service : name=openqa-livehandler enabled=yes state=started
when : (deployment_type is defined) and (deployment_type == 'stg')
2015-11-13 09:49:00 -08:00
# This is using a big hammer until #1277312 is resolved
- name : Allow Apache to connect to openQA
seboolean : name=httpd_can_network_connect state=yes persistent=yes
2016-03-08 14:26:28 -08:00
- name : Allow Apache to read from NFS (as we store test data files there now)
seboolean : name=httpd_use_nfs state=yes persistent=yes
2016-01-04 17:01:12 -08:00
# services is undefined in check mode
2015-11-13 09:49:00 -08:00
- name : Wait for openQA to be fully started
pause : seconds=5
2018-05-07 23:51:48 +00:00
when : "services is defined and services is changed"
2015-11-13 09:49:00 -08:00
2016-03-07 11:26:16 -08:00
# the 'dispatcher' role requires this to be root.fedmsg 0640. so we
# don't enforce ownership here and set mode to 0640 so we don't wind
# up ping-ponging it between server and dispatcher roles.
2015-11-13 09:49:00 -08:00
- name : openQA client config
2016-03-07 11:26:16 -08:00
template : src=client.conf.j2 dest=/etc/openqa/client.conf mode=0640
2015-11-13 09:49:00 -08:00
tags :
- config
- name : Create admin user
2018-07-11 22:10:01 +00:00
command : "/var/lib/openqa/script/create_admin --email {{ openqa_email }} --nickname {{ openqa_nickname }} --fullname '{{ openqa_fullname }}' --key {{ openqa_key }} --secret {{ openqa_secret }} {{ openqa_userid }}"
2015-11-13 09:49:00 -08:00
register : admin
changed_when : "admin.rc == 0"
failed_when : "(admin.rc > 0) and (admin.stderr is not defined or admin.stderr.find('already exists') == -1)"
2015-12-15 14:14:54 -08:00
- name : Dump existing config for checking changes
shell : "/usr/share/openqa/script/dump_templates --json > /tmp/tmpl-old.json"
2018-05-07 23:51:48 +00:00
when : "(gittests is defined) and (gittests is changed)"
2015-12-15 14:14:54 -08:00
changed_when : "1 != 1"
# Because of the boring details of how template loading works, getting
# a correct 'changed' for this step is too difficult. Instead we have
# the prior and following steps; when the templates actually changed,
# the *following* step will register as changed.
2017-02-28 09:41:32 -08:00
- name : Load main tests
2016-12-20 18:52:52 -08:00
command : "/var/lib/openqa/share/tests/fedora/templates --clean"
2018-05-07 23:51:48 +00:00
when : "(gittests is defined) and (gittests is changed)"
2016-04-08 16:38:54 -07:00
changed_when : "1 != 1"
2016-04-08 08:02:02 -07:00
2017-02-28 09:41:32 -08:00
- name : Load update tests
command : "/var/lib/openqa/share/tests/fedora/templates-updates --update"
2018-05-07 23:51:48 +00:00
when : "(gittests is defined) and (gittests is changed)"
2017-02-28 09:41:32 -08:00
changed_when : "1 != 1"
2015-12-15 14:14:54 -08:00
- name : Check if the tests changed in previous step
2016-01-04 17:10:19 -08:00
shell : "/usr/share/openqa/script/dump_templates --json > /tmp/tmpl-new.json && json_diff /tmp/tmpl-old.json /tmp/tmpl-new.json"
2018-05-07 23:51:48 +00:00
when : "(gittests is defined) and (gittests is changed)"
2015-12-15 14:14:54 -08:00
register : testsdiff
changed_when : "testsdiff.rc > 0"
failed_when : "1 != 1"
2016-03-19 16:08:15 -07:00
2018-03-22 16:06:42 -07:00
- name : Set 'fedora' asset size limit (if specified) (pgsql)
2016-03-19 16:08:15 -07:00
delegate_to : "{{ openqa_dbhost }}"
become_user : postgres
become : true
2018-03-22 16:11:12 -07:00
command : "psql -d {{ openqa_dbname }} -c \"UPDATE job_groups SET size_limit_gb = {{ openqa_assetsize }} WHERE name = 'fedora' AND (size_limit_gb != {{ openqa_assetsize }} OR size_limit_gb IS NULL);\""
2018-03-22 16:06:42 -07:00
when : "openqa_dbhost is defined and openqa_assetsize is defined"
register : pgsqlsize
changed_when : "pgsqlsize.stdout.find('UPDATE 0') == -1"
- name : Set 'Fedora PowerPC' asset size limit (if specified) (pgsql)
delegate_to : "{{ openqa_dbhost }}"
become_user : postgres
become : true
2018-03-22 16:11:12 -07:00
command : "psql -d {{ openqa_dbname }} -c \"UPDATE job_groups SET size_limit_gb = {{ openqa_assetsize_ppc }} WHERE name = 'Fedora PowerPC' AND (size_limit_gb != {{ openqa_assetsize_ppc }} OR size_limit_gb IS NULL);\""
2018-03-22 16:14:10 -07:00
when : "openqa_dbhost is defined and openqa_assetsize_ppc is defined"
2018-03-22 16:06:42 -07:00
register : pgsqlsize
changed_when : "pgsqlsize.stdout.find('UPDATE 0') == -1"
- name : Set 'Fedora AArch64' asset size limit (if specified) (pgsql)
delegate_to : "{{ openqa_dbhost }}"
become_user : postgres
become : true
2018-03-22 16:11:12 -07:00
command : "psql -d {{ openqa_dbname }} -c \"UPDATE job_groups SET size_limit_gb = {{ openqa_assetsize_aarch64 }} WHERE name = 'Fedora AArch64' AND (size_limit_gb != {{ openqa_assetsize_aarch64 }} OR size_limit_gb IS NULL);\""
2018-03-22 16:14:10 -07:00
when : "openqa_dbhost is defined and openqa_assetsize_aarch64 is defined"
2016-03-19 16:08:15 -07:00
register : pgsqlsize
2016-03-19 16:14:03 -07:00
changed_when : "pgsqlsize.stdout.find('UPDATE 0') == -1"
2017-11-30 11:45:49 -08:00
- name : Set update job group asset size limit (if specified) (pgsql)
delegate_to : "{{ openqa_dbhost }}"
become_user : postgres
become : true
command : "psql -d {{ openqa_dbname }} -c \"UPDATE job_groups SET size_limit_gb = {{ openqa_assetsize_updates }} WHERE name LIKE '%Updates%' AND (size_limit_gb != {{ openqa_assetsize_updates }} OR size_limit_gb IS NULL);\""
when : "openqa_dbhost is defined and openqa_assetsize_updates is defined"
register : pgsqlupdatesize
changed_when : "pgsqlupdatesize.stdout.find('UPDATE 0') == -1"