Skip to content

Commit

Permalink
Merge pull request #46 from stackhpc/packages
Browse files Browse the repository at this point in the history
Handle additional dependencies
  • Loading branch information
cityofships authored Nov 5, 2024
2 parents 583e207 + e23ddf6 commit f53771d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 31 deletions.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: stackhpc
name: openstack
version: 0.2.2
version: 0.2.3
readme: README.md
authors:
- StackHPC Ltd
Expand Down
30 changes: 0 additions & 30 deletions roles/os_images/tasks/images.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
---
- name: Include OS family-specific variables
ansible.builtin.include_vars: "{{ ansible_facts.os_family }}.yml"
- name: Ensure required packages are installed
ansible.builtin.package:
name: "{{ (os_images_package_dependencies + os_images_package_dependencies_extra) | select | list }}"
state: present
become: true

# The rpm-distro element executes 'semanage' during its cleanup phase.
- name: Ensure diskimage-builder SELinux dependencies are installed
vars:
package_name: python3-policycoreutils
ansible.builtin.package:
name: "{{ package_name }}"
state: present
when:
- ansible_facts.selinux
- ansible_facts.selinux.status != 'disabled'
- ansible_facts.os_family == "RedHat"
become: true

- name: Ensure download cache dir exists
ansible.builtin.file:
path: "{{ os_images_cache }}"
owner: "{{ ansible_facts.user_uid }}"
group: "{{ ansible_facts.user_gid }}"
state: directory
mode: "0755"
become: true

- name: Remove old images for force rebuild
ansible.builtin.file:
path: "{{ os_images_cache }}/{{ item.name }}"
Expand Down
6 changes: 6 additions & 0 deletions roles/os_images/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
ansible.builtin.set_fact:
old_ansible_python_interpreter: "{{ ansible_python_interpreter | default('/usr/bin/python3') }}"

- name: Run prechecks
ansible.builtin.import_tasks: prechecks.yml

- name: Prerequisite tasks
ansible.builtin.import_tasks: prereqs.yml

- name: Build or download images
ansible.builtin.import_tasks: images.yml
when: os_images_build | bool
Expand Down
16 changes: 16 additions & 0 deletions roles/os_images/tasks/prechecks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Here a quick check for the presence of Docker (or an alias for Podman)
# Display a warning if not found
- name: Check if container engine is installed
ansible.builtin.command: which docker
changed_when: false
ignore_errors: true
register: result

- name: Display warning message about the container engine
ansible.builtin.assert:
that:
- result.rc = 0
fail_msg: >
Container runtime engine could not be found - make sure it is installed.
Elements that depend on it will likely fail when building.
31 changes: 31 additions & 0 deletions roles/os_images/tasks/prereqs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: Include OS family-specific variables
ansible.builtin.include_vars: "{{ ansible_facts.os_family }}.yml"

- name: Ensure required packages are installed
ansible.builtin.package:
name: "{{ (os_images_package_dependencies + os_images_package_dependencies_extra) | select | list }}"
state: present
become: true

# The rpm-distro element executes 'semanage' during its cleanup phase.
- name: Ensure diskimage-builder SELinux dependencies are installed
vars:
package_name: python3-policycoreutils
ansible.builtin.package:
name: "{{ package_name }}"
state: present
when:
- ansible_facts.selinux
- ansible_facts.selinux.status != 'disabled'
- ansible_facts.os_family == "RedHat"
become: true

- name: Ensure download cache dir exists
ansible.builtin.file:
path: "{{ os_images_cache }}"
owner: "{{ ansible_facts.user_uid }}"
group: "{{ ansible_facts.user_gid }}"
state: directory
mode: "0755"
become: true
2 changes: 2 additions & 0 deletions roles/os_images/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
# List of package dependencies.
os_images_package_dependencies:
- debootstrap
- dosfstools
- gdisk
- "{% if os_images_git_elements | length > 0 %}git{% endif %}"
- kpartx
- lvm2
- python3-venv
- qemu-utils
- squashfs-tools
- xz-utils
2 changes: 2 additions & 0 deletions roles/os_images/vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
# List of package dependencies.
os_images_package_dependencies:
- debootstrap
- dosfstools
- gdisk
- "{% if os_images_git_elements | length > 0 %}git{% endif %}"
- kpartx
- lvm2
- python3-devel
- qemu-img
- squashfs-tools
- xz

0 comments on commit f53771d

Please sign in to comment.