WIP: Automation for configuring an openQA worker host #1

Draft
raktajino wants to merge 23 commits from worker_host into develop
2 changed files with 25 additions and 65 deletions
Showing only changes of commit c4d9d3ea24 - Show all commits

View File

@ -27,3 +27,10 @@
state: restarted
enabled: true
ignore_errors: "{{ ansible_check_mode }}"
- name: Restart httpd
ansible.builtin.service:
name: httpd
state: restarted
enabled: true
ignore_errors: "{{ ansible_check_mode }}"

View File

@ -11,15 +11,16 @@
remote_src: true
src: /etc/httpd/conf.d/{{ item }}.template
dest: /etc/httpd/conf.d/{{ item }}
mode: '0644'
mode: "0644"
owner: root
group: root
loop:
- openqa.conf
- openqa-ssl.conf
notify: restart_httpd
notify: Restart httpd
tags:
- configure
ignore_errors: "{{ ansible_check_mode }}"
- name: Template OpenQA configuration files
ansible.builtin.template:
@ -33,9 +34,11 @@
- client.conf
tags:
- configure
notify: Restart openQA workers
- name: Get service facts
ansible.builtin.service_facts:
check_mode: false
- name: Check for non-empty postgres data directory
ansible.builtin.stat:
@ -47,6 +50,7 @@
when: not ( ansible_facts.services["postgresql.service"]["state"] == "running" )
and not postgres_data_dir.stat.exists
changed_when: true
ignore_errors: "{{ ansible_check_mode }}"
- name: Enable and start postgresql service
ansible.builtin.systemd:
@ -55,6 +59,7 @@
enabled: true
when: not ( ansible_facts.services["postgresql.service"]["state"] == "running" )
and not postgres_data_dir.stat.exists
ignore_errors: "{{ ansible_check_mode }}"
- name: Configure SELinux to allow httpd connection to network
ansible.posix.seboolean:
@ -72,6 +77,7 @@
loop: "{{ openqa_services }}"
tags:
- configure
ignore_errors: "{{ ansible_check_mode }}"
- name: Create openqa-vnc firewalld service
ansible.builtin.template:
@ -82,13 +88,11 @@
mode: "0644"
tags:
- configure
notify: Reload firewalld
- name: Load openqa-vnc firewalld service
- name: Systemctl daemon-reload
ansible.builtin.systemd:
name: firewalld
state: reloaded
tags:
- configure
daemon_reload: true
- name: Permit traffic for http and openqa-vnc services
ansible.posix.firewalld:
@ -100,13 +104,7 @@
- openqa-vnc
tags:
- configure
- name: Reload FirewallD
ansible.builtin.systemd:
name: firewalld
state: reloaded
tags:
- configure
notify: Reload firewalld
- name: Check for existing repository
ansible.builtin.stat:
@ -131,63 +129,18 @@
recurse: true
owner: "{{ openqa_user }}"
group: "{{ openqa_group }}"
mode: "u+rwX,g+rwX,o+rX,o-w"
mode: "0775"
tags:
- configure
# fifloader.py will fail if the Demo user is not logged in
- name: Authenticate to web UI the first time
ansible.builtin.uri:
url: "http://{{ openqa_host }}/login"
- name: Run fifloader.py
ansible.builtin.command: ./fifloader.py -l -c templates.fif.json templates-updates.fif.json
changed_when: "1 != 1"
args:
chdir: "{{ openqa_homedir }}/share/tests/rocky"
- name: Create ISO directory
- name: Create asset directories
ansible.builtin.file:
path: "{{ openqa_homedir }}/share/factory/iso/fixed"
path: "{{ openqa_homedir }}/share/factory/{{ item }}/fixed"
state: directory
owner: "{{ openqa_user }}"
group: "{{ openqa_group }}"
mode: "0775"
tags:
- download_isos
- name: Download ISOs
ansible.builtin.get_url:
dest: "{{ openqa_homedir }}/share/factory/iso/fixed/{{ item.name }}"
url: "{{ rocky_iso_download_url }}/{{ item.name }}"
checksum: "{{ item.checksum }}"
owner: "{{ openqa_user }}"
group: "{{ openqa_group }}"
tmp_dest: "/var/tmp"
mode: "0644"
loop: "{{ openqa_isos }}"
tags:
- download_isos
- name: Start OpenQA workers
ansible.builtin.systemd:
name: "openqa-worker@{{ item }}"
state: started
enabled: true
# range 'end' parameter is exclusive, so add 1
loop: "{{ range(1, (openqa_worker_count | int + 1)) | list }}"
tags:
- start_workers
- configure
- name: POST a job
ansible.builtin.command: |
openqa-cli api -X POST isos \
ISO=Rocky-{{ rocky_version }}-{{ rocky_arch }}-minimal.iso \
ARCH={{ rocky_arch }} \
DISTRI=rocky \
FLAVOR=minimal-iso \
VERSION={{ rocky_version }} \
BUILD="{{ '%Y%m%d.%H%M%S' | strftime }}.0"
changed_when: "1 != 1"
loop:
- iso
- hdd
...