ansible-openqa-management/tasks/openqa.yml

147 lines
3.5 KiB
YAML
Raw Permalink Normal View History

2023-02-18 18:45:36 +00:00
---
- name: Install OpenQA packages
2023-02-18 20:35:36 +00:00
ansible.builtin.yum:
2023-02-18 18:45:36 +00:00
name: "{{ openqa_packages }}"
state: present
tags:
- packages
- name: Copy httpd configuration files
2023-02-18 20:35:36 +00:00
ansible.builtin.copy:
2023-02-18 18:45:36 +00:00
remote_src: true
src: /etc/httpd/conf.d/{{ item }}.template
dest: /etc/httpd/conf.d/{{ item }}
2023-03-17 06:05:00 +00:00
mode: "0644"
2023-02-18 18:45:36 +00:00
owner: root
group: root
loop:
- openqa.conf
- openqa-ssl.conf
2023-03-17 06:05:00 +00:00
notify: Restart httpd
2023-02-18 18:45:36 +00:00
tags:
- configure
2023-03-17 06:05:00 +00:00
ignore_errors: "{{ ansible_check_mode }}"
2023-02-18 18:45:36 +00:00
- name: Template OpenQA configuration files
2023-02-18 20:35:36 +00:00
ansible.builtin.template:
2023-02-18 18:45:36 +00:00
src: etc/openqa/{{ item }}.j2
dest: /etc/openqa/{{ item }}
owner: "{{ openqa_user }}"
group: "{{ openqa_group }}"
mode: "0444"
loop:
- openqa.ini
- client.conf
tags:
- configure
2023-03-17 06:05:00 +00:00
notify: Restart openQA workers
2023-02-18 18:45:36 +00:00
- name: Get service facts
2023-02-18 20:35:36 +00:00
ansible.builtin.service_facts:
2023-03-17 06:05:00 +00:00
check_mode: false
2023-02-18 18:45:36 +00:00
- name: Check for non-empty postgres data directory
2023-02-18 20:35:36 +00:00
ansible.builtin.stat:
2023-02-18 18:45:36 +00:00
path: /var/lib/pgsql/data/base
register: postgres_data_dir
- name: If postgresql is not already running, initialize database
2023-02-18 20:35:36 +00:00
ansible.builtin.command: postgresql-setup --initdb
2023-02-18 18:45:36 +00:00
when: not ( ansible_facts.services["postgresql.service"]["state"] == "running" )
and not postgres_data_dir.stat.exists
2023-02-18 20:35:36 +00:00
changed_when: true
2023-03-17 06:05:00 +00:00
ignore_errors: "{{ ansible_check_mode }}"
2023-02-18 18:45:36 +00:00
- name: Enable and start postgresql service
2023-02-18 20:35:36 +00:00
ansible.builtin.systemd:
2023-02-18 18:45:36 +00:00
name: postgresql
state: started
enabled: true
when: not ( ansible_facts.services["postgresql.service"]["state"] == "running" )
and not postgres_data_dir.stat.exists
2023-03-17 06:05:00 +00:00
ignore_errors: "{{ ansible_check_mode }}"
2023-02-18 18:45:36 +00:00
- name: Configure SELinux to allow httpd connection to network
2023-02-18 20:35:36 +00:00
ansible.posix.seboolean:
2023-02-18 18:45:36 +00:00
name: httpd_can_network_connect
state: true
persistent: true
tags:
- configure
- name: Enable and start OpenQA services
2023-02-18 20:35:36 +00:00
ansible.builtin.systemd:
2023-02-18 18:45:36 +00:00
name: "{{ item }}"
state: started
enabled: true
loop: "{{ openqa_services }}"
tags:
- configure
2023-03-17 06:05:00 +00:00
ignore_errors: "{{ ansible_check_mode }}"
2023-02-18 18:45:36 +00:00
- name: Create openqa-vnc firewalld service
2023-02-18 20:35:36 +00:00
ansible.builtin.template:
2023-02-18 18:45:36 +00:00
src: etc/firewalld/services/openqa-vnc.xml.j2
dest: /etc/firewalld/services/openqa-vnc.xml
owner: root
group: root
mode: "0644"
tags:
- configure
2023-03-17 06:05:00 +00:00
notify: Reload firewalld
2023-02-18 18:45:36 +00:00
2023-03-17 06:05:00 +00:00
- name: Systemctl daemon-reload
2023-02-18 20:35:36 +00:00
ansible.builtin.systemd:
2023-03-17 06:05:00 +00:00
daemon_reload: true
2023-02-18 18:45:36 +00:00
2023-02-18 20:35:36 +00:00
- name: Permit traffic for http and openqa-vnc services
2023-02-18 18:45:36 +00:00
ansible.posix.firewalld:
service: "{{ item }}"
permanent: true
state: enabled
loop:
- http
- openqa-vnc
tags:
- configure
2023-03-17 06:05:00 +00:00
notify: Reload firewalld
2023-02-18 18:45:36 +00:00
- name: Check for existing repository
2023-02-18 20:35:36 +00:00
ansible.builtin.stat:
2023-02-18 18:45:36 +00:00
path: "{{ openqa_homedir }}/share/tests/rocky"
register: rocky_testing_repo
tags:
- configure
- name: Clone repository if it does not already exist
2023-02-18 20:35:36 +00:00
ansible.builtin.git:
2023-02-18 18:45:36 +00:00
accept_hostkey: true
dest: "{{ openqa_homedir }}/share/tests/rocky"
repo: "{{ openqa_rocky_testing_repo }}"
version: develop
when: not rocky_testing_repo.stat.exists
tags:
- configure
- name: Set owner/group/permissions on repo contents
2023-02-18 20:35:36 +00:00
ansible.builtin.file:
2023-02-18 18:45:36 +00:00
path: "{{ openqa_homedir }}/share/tests/rocky"
recurse: true
owner: "{{ openqa_user }}"
group: "{{ openqa_group }}"
2023-03-17 06:05:00 +00:00
mode: "0775"
2023-02-18 18:45:36 +00:00
tags:
- configure
2023-03-17 06:05:00 +00:00
- name: Create asset directories
2023-02-18 20:35:36 +00:00
ansible.builtin.file:
2023-03-17 06:05:00 +00:00
path: "{{ openqa_homedir }}/share/factory/{{ item }}/fixed"
2023-02-18 18:45:36 +00:00
state: directory
owner: "{{ openqa_user }}"
group: "{{ openqa_group }}"
mode: "0775"
2023-03-17 06:05:00 +00:00
loop:
- iso
- hdd
2023-02-18 18:45:36 +00:00
...