Merge pull request #92 from corvus-migratorius/role-singularity-deb

Implement Singularity deployment from a DEB package
This commit is contained in:
Alexander Gorelyshev
2026-05-14 17:06:28 +04:00
committed by GitHub
9 changed files with 167 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
singularity
=========
Install Singularity from a DEB file hosted on the official Github repo.
Requirements
------------
Role Variables
--------------
- `singularity_deb_os_name`: Ubuntu codename, default: `jammy`
- `singularity_deb_version`: Singularity version, default: `3.9.9`
Both variables are used in building a Github release URL.
Example Playbook
----------------
See: [converge.yml](molecule/default/converge.yml)
License
-------
MIT
Author Information
------------------
corvus-migratorius@proton.me

View File

@@ -0,0 +1,3 @@
---
singularity_deb_os_name: "jammy"
singularity_deb_version: "3.9.9"

View File

@@ -0,0 +1 @@
---

View File

@@ -0,0 +1,17 @@
---
galaxy_info:
role_name: singularity
namespace: genlab
author: Alexander Gorelyshev
company: "Genlab, LLC"
description: ""
license: "MIT"
min_ansible_version: "2.1"
platforms:
- name: "Ubuntu"
versions: ["jammy", "noble"]
galaxy_tags: []
dependencies: []

View File

@@ -0,0 +1,12 @@
---
- name: Converge
hosts: all
pre_tasks:
- name: "Update apt cache"
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
roles:
- role: "genlab.common.singularity_deb"

View File

@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: ubuntu
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2404}-ansible:latest
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .

View File

@@ -0,0 +1,33 @@
---
- name: Verify
hosts: all
gather_facts: false
any_errors_fatal: true
pre_tasks:
- name: "Verify | include default vars"
ansible.builtin.include_vars:
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
extensions: ['yml']
tasks:
- name: "Verify | check the installed Singularity version"
register: singularity_deb_installed_version
changed_when: false
ansible.builtin.command:
cmd: singularity --version
- name: "Verify | assert installed version correctness"
tags: singularity
vars:
installed: "{{ singularity_deb_installed_version.stdout }}"
expected: "singularity-ce version {{ singularity_deb_version }}-{{ singularity_deb_os_name }}"
ansible.builtin.assert:
that: installed == expected
success_msg: "OK, expected version present: '{{ installed }}'"
fail_msg: "Unexpected Singularity version: '{{ installed }}'"
- name: "Verify | test Singularity deployment with a 'hello-world' job" # noqa: no-changed-when
changed_when: false
ansible.builtin.command:
cmd: "singularity --debug run shub://GodloveD/lolcow"

View File

@@ -0,0 +1,43 @@
---
- name: "Install | install Singularity"
tags: singularity
block:
- name: "Install | get the installed Singularity version"
tags: singularity
register: singularity_deb_installed_version
changed_when: false
ansible.builtin.command:
cmd: singularity --version
- name: "Install | assert installed version correctness"
tags: singularity
vars:
installed: "{{ singularity_deb_installed_version.stdout }}"
expected: "singularity-ce version {{ singularity_deb_version }}-{{ singularity_deb_os_name }}"
ansible.builtin.assert:
that: installed == expected
success_msg: "Expected version already present: '{{ installed }}'"
fail_msg: "Found unexpected Singularity version: '{{ installed }}'"
rescue:
- name: "Install | download GitHub release .deb"
tags: singularity
vars:
baseurl: "github.com/sylabs/singularity/releases/download"
singver: "{{ singularity_deb_version }}"
osname: "{{ singularity_deb_os_name }}"
ansible.builtin.get_url:
url: "https://{{ baseurl }}/v{{ singver }}/singularity-ce_{{ singver }}-{{ osname }}_amd64.deb"
dest: "/tmp/singularity.deb"
mode: "0644"
- name: "Install | install downloaded package"
tags: singularity
ansible.builtin.apt:
deb: "/tmp/singularity.deb"
- name: "Install | clean up the .deb artifact"
tags: singularity
ansible.builtin.file:
path: "/tmp/singularity.deb"
state: absent

View File

@@ -0,0 +1 @@
---