Files
fedora-infra_ansible/roles/openqa/worker/tasks/createhdds.yml
Ryan Lerch 25391e95b7 ansiblelint fixes - fqcn[action-core] - package to ansible.builtin.package
Replaces many references to  package: with ansible.builtin.package

Signed-off-by: Ryan Lerch <rlerch@redhat.com>
2025-01-15 11:28:00 +10:00

85 lines
3.0 KiB
YAML

# Required vars with defaults
# - openqa_createhdds_branch
## string - The git branch of createhdds to check out
## default - main
---
- name: Install required packages
ansible.builtin.package:
name: ['python3-libsemanage', 'libvirt-daemon-kvm', 'libvirt-python3', 'python3-libguestfs',
'python3-fedfind', 'qemu-kvm', 'virt-install', 'withlock']
state: present
tags:
- packages
- name: Install PowerPC-specific packages
ansible.builtin.package: name=powerpc-utils state=present
when: ansible_architecture == 'ppc64' or ansible_architecture == 'ppc64le'
tags:
- packages
- name: Allow libvirt to read/write to NFS
seboolean: name=virt_use_nfs state=yes persistent=yes
- name: Check if SMT setting needs changing
ansible.builtin.command: "ppc64_cpu --smt"
register: smtcheck
failed_when: "1 != 1"
changed_when: "1 != 1"
check_mode: no
when: ansible_architecture == 'ppc64' or ansible_architecture == 'ppc64le'
- name: Change SMT setting if necessary
ansible.builtin.command: "ppc64_cpu --smt=off"
when: "smtcheck.stdout is defined and smtcheck.stdout.find('is off') == -1"
- name: Check createhdds directory exists with correct ownership
ansible.builtin.file: path=/root/createhdds state=directory owner=root group=root
# we don't want to run the checkout if createhdds is 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
ansible.builtin.command: "git status" # noqa 303
args:
chdir: /root/createhdds
register: createhddsbranch
failed_when: "1 != 1"
changed_when: "1 != 1"
check_mode: no
- name: Check out createhdds
git:
repo: https://pagure.io/fedora-qa/createhdds.git
dest: /root/createhdds
version: "{{ openqa_createhdds_branch }}"
when: >
(createhddsbranch.stderr.find('ot a git repository') != -1) or
(createhddsbranch.stdout.find('On branch main') != -1 and
createhddsbranch.stdout.find('Changes not staged') == -1)
- name: Set up createhdds cron job
ansible.builtin.copy: src=createhdds dest=/etc/cron.daily/createhdds owner=root group=root mode=0755
- name: Check if any hard disk images need (re)building
ansible.builtin.command: "/root/createhdds/createhdds.py check"
args:
chdir: /var/lib/openqa/share/factory/hdd/fixed
register: diskcheck
failed_when: "1 != 1"
changed_when: "1 != 1"
check_mode: no
- name: Ensure libvirt is running if needed to create images
service: name=libvirtd enabled=yes state=started
when: "diskcheck.rc > 1"
# > 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.
- name: Create hard disk images (this may take a long time!)
ansible.builtin.command: "/etc/cron.daily/createhdds"
when: "diskcheck.rc > 1"
ignore_errors: yes