Migrate the genlab.mkfs role

This commit is contained in:
Alexander Gorelyshev
2025-12-08 12:20:01 +04:00
parent aac58f44d0
commit 8cc746fbfa
9 changed files with 146 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
---
- name: Converge
hosts: all
pre_tasks:
- name: "Check if the disk file already exists"
ansible.builtin.stat:
path: /tmp/test_file
register: disk_file
- name: "Create a file to act as a disk if it doesn't exist"
ansible.builtin.command: dd if=/dev/zero of=/tmp/test_file bs=1000000 count=100
when: not disk_file.stat.exists
register: dd_output
changed_when: dd_output.rc != 0
roles:
- role: genlab.mkfs
mkfs_device: "/tmp/test_file"
mkfs_type: ext3
mkfs_state: present

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,25 @@
---
- name: Verify
hosts: all
gather_facts: false
any_errors_fatal: true
tasks:
- name: "Attach the file to a loop device"
ansible.builtin.command: losetup /dev/loop3 /tmp/test_file
register: loop_device
changed_when: loop_device.rc != 0
- name: "Verify the filesystem type"
ansible.builtin.command: blkid /dev/loop3
register: blkid_output
changed_when: blkid_output.rc != 0
- name: "Ensure filesystem is ext3"
ansible.builtin.assert:
that:
- "'TYPE=\"ext3\"' in blkid_output.stdout"
- name: "Explore stdout"
ansible.builtin.debug:
var: blkid_output.stdout