Implement Singularity deployment from a DEB package
This commit is contained in:
37
roles/singularity_deb/README.md
Normal file
37
roles/singularity_deb/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
singularity
|
||||
=========
|
||||
|
||||
Install singularity
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
- build-essential
|
||||
- cryptsetup-bin
|
||||
- git
|
||||
- libgpgme-dev
|
||||
- libseccomp-dev
|
||||
- pkg-config
|
||||
- squashfs-tools
|
||||
- uuid-dev
|
||||
- wget
|
||||
- golang
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
`singularity_version`
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
See `molecule/default/converge.yml`
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
corvus-migratorius@proton.me
|
||||
3
roles/singularity_deb/defaults/main.yml
Normal file
3
roles/singularity_deb/defaults/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
singularity_deb_os_name: "jammy"
|
||||
singularity_deb_version: "3.9.9"
|
||||
2
roles/singularity_deb/handlers/main.yml
Normal file
2
roles/singularity_deb/handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for playbooks/roles/singularity
|
||||
17
roles/singularity_deb/meta/main.yml
Normal file
17
roles/singularity_deb/meta/main.yml
Normal 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: []
|
||||
12
roles/singularity_deb/molecule/default/converge.yml
Normal file
12
roles/singularity_deb/molecule/default/converge.yml
Normal 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"
|
||||
27
roles/singularity_deb/molecule/default/molecule.yml
Normal file
27
roles/singularity_deb/molecule/default/molecule.yml
Normal 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 .
|
||||
39
roles/singularity_deb/molecule/default/verify.yml
Normal file
39
roles/singularity_deb/molecule/default/verify.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
- 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: "Assert version correctness"
|
||||
# ansible.builtin.assert:
|
||||
# that: singularity_installed_version.stdout == "singularity version " + singularity_deb_version
|
||||
# success_msg: "Found the expected Singularity version: '{{ singularity_version }}'"
|
||||
# fail_msg: "Unexpected Sinagularity version ({{ singularity_installed_version }})"
|
||||
|
||||
- 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"
|
||||
43
roles/singularity_deb/tasks/main.yml
Normal file
43
roles/singularity_deb/tasks/main.yml
Normal 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
|
||||
2
roles/singularity_deb/vars/main.yml
Normal file
2
roles/singularity_deb/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for playbooks/roles/singularity
|
||||
Reference in New Issue
Block a user