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
|
|
|
|
# - 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
|
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-08 12:16:00 -08:00
|
|
|
# As we want to store some geekotest-owned files in shared storage, we
|
|
|
|
# need to ensure geekotest always has the same uid/gid if we re-deploy
|
|
|
|
# the servers. So we create the account here with uid/gid 601.
|
|
|
|
|
|
|
|
- name: Create geekotest group with static GID 601
|
|
|
|
group: name=geekotest gid=601 system=yes
|
|
|
|
|
|
|
|
- name: Create geekotest user with static UID 601
|
|
|
|
user:
|
|
|
|
name: geekotest
|
|
|
|
comment: "openQA user"
|
|
|
|
uid: 601
|
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-10 20:19:39 -08:00
|
|
|
# note: we need updates-testing until fedfind 2.x and openQA 4.3-21 go stable
|
2016-03-08 14:09:01 -08:00
|
|
|
- name: Install required packages (testing)
|
|
|
|
dnf: name={{ item }} state=present enablerepo="updates-testing"
|
|
|
|
with_items:
|
|
|
|
- python2-fedfind
|
2016-03-18 15:34:23 -07:00
|
|
|
- python3-fedfind
|
2016-03-08 14:09:01 -08:00
|
|
|
- openqa
|
|
|
|
- openqa-httpd
|
2016-03-10 17:07:13 -08:00
|
|
|
- openqa-plugin-fedmsg
|
2016-03-08 14:09:01 -08:00
|
|
|
tags:
|
|
|
|
- packages
|
|
|
|
|
2015-11-13 09:49:00 -08:00
|
|
|
- name: Install required packages
|
|
|
|
dnf: name={{ item }} state=present enablerepo=adamwill-openQA
|
|
|
|
with_items:
|
|
|
|
- libselinux-python
|
|
|
|
- git
|
2015-12-15 14:14:54 -08:00
|
|
|
- json_diff
|
2015-11-13 09:49:00 -08:00
|
|
|
- libselinux-utils
|
|
|
|
- libsemanage-python
|
|
|
|
- nfs-utils
|
|
|
|
- perl(Class::DBI::Pg)
|
|
|
|
- perl(DateTime::Format::Pg)
|
2015-11-17 14:16:25 -08:00
|
|
|
- expect
|
2015-11-13 09:49:00 -08:00
|
|
|
- libguestfs-tools-c
|
2015-12-05 11:43:05 -08:00
|
|
|
- libguestfs-xfs
|
2016-03-18 15:34:23 -07:00
|
|
|
- python3-libguestfs
|
|
|
|
- python3-pexpect
|
2015-11-13 09:49:00 -08:00
|
|
|
tags:
|
|
|
|
- packages
|
|
|
|
|
|
|
|
- name: Check out the tests
|
|
|
|
git:
|
|
|
|
repo: https://bitbucket.org/rajcze/openqa_fedora
|
|
|
|
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
|
2015-11-13 09:49:00 -08:00
|
|
|
|
|
|
|
- name: Check out openqa_fedora_tools
|
|
|
|
git:
|
|
|
|
repo: https://bitbucket.org/rajcze/openqa_fedora_tools
|
|
|
|
dest: /root/openqa_fedora_tools
|
|
|
|
|
|
|
|
- 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
|
|
|
|
- /var/lib/openqa/share/factory/repo
|
|
|
|
|
2015-12-17 13:29:16 -08:00
|
|
|
- name: Check if any hard disk images need (re)building
|
2016-03-18 15:34:23 -07:00
|
|
|
command: "/root/openqa_fedora_tools/tools/createhdds.py check"
|
2015-12-07 15:12:04 -08:00
|
|
|
args:
|
|
|
|
chdir: /var/lib/openqa/share/factory/hdd/
|
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"
|
2015-12-17 13:29:16 -08:00
|
|
|
always_run: true
|
2015-12-07 15:12:04 -08:00
|
|
|
|
2015-12-17 13:29:16 -08:00
|
|
|
- name: Create hard disk images (this may take a long time!)
|
2016-03-18 15:34:23 -07:00
|
|
|
command: "/root/openqa_fedora_tools/tools/createhdds.py all --clean"
|
2015-12-07 15:12:04 -08:00
|
|
|
args:
|
|
|
|
chdir: /var/lib/openqa/share/factory/hdd/
|
2015-12-15 11:30:13 -08:00
|
|
|
environment:
|
|
|
|
LIBGUESTFS_BACKEND: direct
|
2015-12-18 19:43:06 -08:00
|
|
|
when: "diskcheck.rc > 0"
|
2015-11-17 14:16:25 -08:00
|
|
|
|
2015-11-13 09:49:00 -08:00
|
|
|
- name: Create exports file
|
|
|
|
copy: src=exports dest=/etc/exports.d/openqa.exports owner=root group=root mode=0644
|
|
|
|
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
|
|
|
|
command: "/usr/share/openqa/script/initdb --user geekotest --init_database"
|
|
|
|
register: initdb
|
|
|
|
changed_when: "initdb.rc == 0"
|
|
|
|
failed_when: "(initdb.rc > 0) and (initdb.stderr is not defined or initdb.stderr.find('already exists') == -1)"
|
|
|
|
|
|
|
|
- name: Enable and start services
|
|
|
|
service: name={{ item }} enabled=yes state=started
|
|
|
|
register: services
|
|
|
|
with_items:
|
|
|
|
- openqa-scheduler
|
|
|
|
- openqa-webui
|
|
|
|
- openqa-websockets
|
|
|
|
- openqa-gru
|
|
|
|
|
|
|
|
# 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
|
2016-01-04 17:01:12 -08:00
|
|
|
when: "services is defined and services|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
|
|
|
|
command: "/var/lib/openqa/script/create_admin --email {{ openqa_email }} --nickname {{ openqa_nickname }} --fullname '{{ openqa_fullname }}' --key {{ openqa_key }} --secret {{ openqa_secret }} {{ openqa_userid }}"
|
|
|
|
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-03 16:08:13 -08:00
|
|
|
- name: Patch repo URLs in templates
|
|
|
|
shell: "cp /var/lib/openqa/share/tests/fedora/templates /tmp && sed -i -e 's,dl.fedoraproject,dl.phx2.fedoraproject,g' /tmp/templates"
|
2015-12-07 15:04:27 -08:00
|
|
|
when: "gittests|changed"
|
2015-12-03 16:08:13 -08:00
|
|
|
changed_when: "1 != 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"
|
|
|
|
when: "gittests|changed"
|
|
|
|
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.
|
2015-11-13 09:49:00 -08:00
|
|
|
- name: Load tests
|
2015-12-07 15:04:27 -08:00
|
|
|
shell: "/tmp/templates --clean"
|
|
|
|
when: "gittests|changed"
|
2015-12-15 14:14:54 -08:00
|
|
|
changed_when: "1 != 1"
|
|
|
|
|
|
|
|
- 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"
|
2015-12-15 14:14:54 -08:00
|
|
|
when: "gittests|changed"
|
|
|
|
register: testsdiff
|
|
|
|
changed_when: "testsdiff.rc > 0"
|
|
|
|
failed_when: "1 != 1"
|
2016-03-19 16:08:15 -07:00
|
|
|
|
|
|
|
- name: Set asset size limit (if specified) (pgsql)
|
|
|
|
delegate_to: "{{ openqa_dbhost }}"
|
|
|
|
become_user: postgres
|
|
|
|
become: true
|
2016-03-19 16:10:14 -07:00
|
|
|
command: "psql -d {{ openqa_dbname }} -c \"UPDATE job_groups SET size_limit_gb = {{ openqa_assetsize }} WHERE size_limit_gb != {{ openqa_assetsize }};\""
|
2016-03-19 16:08:15 -07:00
|
|
|
when: "openqa_dbhost is defined and openqa_assetsize is defined"
|
|
|
|
register: pgsqlsize
|
2016-03-19 16:14:03 -07:00
|
|
|
changed_when: "pgsqlsize.stdout.find('UPDATE 0') == -1"
|