Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/ansible/roles/packages/tasks/CentOS10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,17 @@

- name: 'Packages are the same as in Fedora'
include_tasks: 'Fedora.yml'

- name: Install packages for usbip needed for virtual passkey testing
dnf:
state: present
name:
- gcc
- make
- automake
- autoconf
- systemd-devel
- libtool
when:
- passkey_support
- "'base_client' in group_names or 'client' in group_names"
21 changes: 20 additions & 1 deletion src/ansible/roles/packages/tasks/Fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,33 @@
when: passkey_support
when: "'base_client' in group_names or 'client' in group_names or 'base_ipa' in group_names or 'ipa' in group_names"

- name: Install packages only needed on client for passkey testing
block:
- name: Install koji on the client
dnf:
state: present
name:
- koji

- name: Install usbip on the client if running Fedora
dnf:
state: present
name:
- usbip
when:
- ansible_distribution == "Fedora"
when:
- passkey_support
- "'base_client' in group_names or 'client' in group_names"

- name: Install packages for Keycloak base image
block:
- name: Install Keycloak dependencies
dnf:
state: present
allowerasing: true
name:
- java-21-openjdk-headless
- java-25-openjdk-headless
- openssl
- unzip
- curl
Expand Down
23 changes: 23 additions & 0 deletions src/ansible/roles/packages/tasks/RedHat10.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- name: Install EPEL repository
dnf:
state: present
name: 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm'
disable_gpg_check: yes
when: extended_packageset

- name: Install packages for usbip needed for virtual passkey testing
dnf:
state: present
name:
- gcc
- make
- automake
- autoconf
- systemd-devel
- libtool
when:
- passkey_support
- "'base_client' in group_names or 'client' in group_names"

- name: 'Packages are the same as in Fedora'
include_tasks: 'Fedora.yml'
2 changes: 2 additions & 0 deletions src/ansible/roles/passkey/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
test_venv: /opt/test_venv
#kver: "{{ ansible_kernel | regex_replace('\\.[^.]*$', '') }}"
kver: "{{ ansible_kernel | regex_replace('\\.' + ansible_architecture + '$', '') }}"
51 changes: 51 additions & 0 deletions src/ansible/roles/passkey/tasks/CentOS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
- name: Create temporary build directory
tempfile:
state: directory
suffix: usbip_build
register: build_dir

- name: Ensure Koji config directory exists
file:
path: "~/.koji/config.d"
state: directory
mode: '0755'

- name: Configure CentOS Stream Koji profile
copy:
dest: "~/.koji/config.d/centos-stream.conf"
content: |
[centos-stream]
server = https://kojihub.stream.centos.org/kojihub
topurl = https://kojihub.stream.centos.org/kojifiles

- name: Download Kernel Source RPM via Koji
command:
cmd: "koji --profile centos-stream download-build --arch=src kernel-{{ kver }}"
chdir: "{{ build_dir.path }}"
args:
creates: "{{ build_dir.path }}/kernel-{{ kver }}.src.rpm"

- name: Extract Source RPM and Kernel Tarball
shell: |
set -ex
rpm2cpio kernel-{{ kver }}.src.rpm | cpio -id
xz -dc linux-{{ kver }}.tar.xz | tar xf -
args:
chdir: "{{ build_dir.path }}"
creates: "{{ build_dir.path }}/linux-{{ kver }}/tools/usb/usbip/configure"

- name: Build and Install USBIP tools
shell: |
set -ex
./autogen.sh
./configure
make install
args:
chdir: "{{ build_dir.path }}/linux-{{ kver }}/tools/usb/usbip/"
creates: "/usr/local/sbin/usbip"

- name: Create symlink for usbip
file:
src: /usr/local/sbin/usbip
dest: /usr/sbin/usbip
state: link
1 change: 1 addition & 0 deletions src/ansible/roles/passkey/tasks/Fedora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Placeholder for Fedora specific passkey test deps
51 changes: 51 additions & 0 deletions src/ansible/roles/passkey/tasks/RedHat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
- name: Create temporary build directory
tempfile:
state: directory
suffix: usbip_build
register: build_dir

- name: Ensure Koji config directory exists
file:
path: "~/.koji/config.d"
state: directory
mode: '0755'

- name: Configure CentOS Stream Koji profile
copy:
dest: "~/.koji/config.d/centos-stream.conf"
content: |
[centos-stream]
server = https://kojihub.stream.centos.org/kojihub
topurl = https://kojihub.stream.centos.org/kojifiles

- name: Download Kernel Source RPM via Koji
command:
cmd: "koji --profile centos-stream download-build --arch=src kernel-{{ kver }}"
chdir: "{{ build_dir.path }}"
args:
creates: "{{ build_dir.path }}/kernel-{{ kver }}.src.rpm"

- name: Extract Source RPM and Kernel Tarball
shell: |
set -ex
rpm2cpio kernel-{{ kver }}.src.rpm | cpio -id
xz -dc linux-{{ kver }}.tar.xz | tar xf -
args:
chdir: "{{ build_dir.path }}"
creates: "{{ build_dir.path }}/linux-{{ kver }}/tools/usb/usbip/configure"

- name: Build and Install USBIP tools
shell: |
set -ex
./autogen.sh
./configure
make install
args:
chdir: "{{ build_dir.path }}/linux-{{ kver }}/tools/usb/usbip/"
creates: "/usr/local/sbin/usbip"

- name: Create symlink for usbip
file:
src: /usr/local/sbin/usbip
dest: /usr/sbin/usbip
state: link
Comment on lines +1 to +51

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The temporary build directory created by tempfile is not cleaned up after the playbook runs, which can leave artifacts on the system. It's a good practice to use a block with an always section to ensure the temporary directory is removed, even if tasks fail.

- name: Build and install usbip from source
  block:
  - name: Create temporary build directory
    tempfile:
      state: directory
      suffix: usbip_build
    register: build_dir

  - name: Ensure Koji config directory exists
    file:
      path: "~/.koji/config.d"
      state: directory
      mode: '0755'

  - name: Configure CentOS Stream Koji profile
    copy:
      dest: "~/.koji/config.d/centos-stream.conf"
      content: |
        [centos-stream]
        server = https://kojihub.stream.centos.org/kojihub
        topurl = https://kojihub.stream.centos.org/kojifiles

  - name: Download Kernel Source RPM via Koji
    command:
      cmd: "koji --profile centos-stream download-build --arch=src kernel-{{ kver }}"
      chdir: "{{ build_dir.path }}"
    args:
      creates: "{{ build_dir.path }}/kernel-{{ kver }}.src.rpm"

  - name: Extract Source RPM and Kernel Tarball
    shell: |
      set -ex
      rpm2cpio kernel-{{ kver }}.src.rpm | cpio -id
      xz -dc linux-{{ kver }}.tar.xz | tar xf -
    args:
      chdir: "{{ build_dir.path }}"
      creates: "{{ build_dir.path }}/linux-{{ kver }}/tools/usb/usbip/configure"

  - name: Build and Install USBIP tools
    shell: |
      set -ex
      ./autogen.sh
      ./configure
      make install
    args:
      chdir: "{{ build_dir.path }}/linux-{{ kver }}/tools/usb/usbip/"
      creates: "/usr/local/sbin/usbip"

  - name: Create symlink for usbip
    file:
      src: /usr/local/sbin/usbip
      dest: /usr/sbin/usbip
      state: link

  always:
  - name: Clean up temporary build directory
    file:
      path: "{{ build_dir.path }}"
      state: absent
    when: build_dir.path is defined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be better to leave the directory behind for debugging in the event that something fails. I'll be looking for more input on this one though.

7 changes: 7 additions & 0 deletions src/ansible/roles/passkey/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@
update: yes
depth: 1

- name: 'Include distribution specific tasks [{{ ansible_distribution }} {{ ansible_distribution_major_version }}]'
include_tasks: '{{ include_file }}'
loop_control:
loop_var: include_file
with_first_found:
- files: '{{ ansible_distribution | distro_includes(ansible_distribution_major_version) }}'

when: passkey_support
Loading