Migrate the code for mount_device
This commit is contained in:
27
roles/mount_device/molecule/default/converge.yml
Normal file
27
roles/mount_device/molecule/default/converge.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- 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"
|
||||
when: not disk_file.stat.exists
|
||||
changed_when: false
|
||||
ansible.builtin.shell: |
|
||||
dd if=/dev/zero of=/tmp/test_file bs=1000000 count=100
|
||||
mkfs.ext3 /tmp/test_file
|
||||
|
||||
roles:
|
||||
- role: genlab.mount_device
|
||||
devices:
|
||||
- what: "/tmp/test_file"
|
||||
where: "/test_mount"
|
||||
fstype: ext3
|
||||
opts:
|
||||
- noatime
|
||||
state: mounted
|
||||
27
roles/mount_device/molecule/default/molecule.yml
Normal file
27
roles/mount_device/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 .
|
||||
18
roles/mount_device/molecule/default/verify.yml
Normal file
18
roles/mount_device/molecule/default/verify.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
any_errors_fatal: true
|
||||
|
||||
tasks:
|
||||
- name: "Check mountpoint" # noqa: command-instead-of-module
|
||||
changed_when: false
|
||||
register: mounts
|
||||
ansible.builtin.command:
|
||||
cmd: mount -l
|
||||
|
||||
- name: "Ensure test_file is mounted on test_mount"
|
||||
ansible.builtin.assert:
|
||||
that: "'/tmp/test_file on /test_mount type ext3' in mounts.stdout"
|
||||
success_msg: "/test_mount is a mounted"
|
||||
fail_msg: "/test_mount is not on the list of mounts"
|
||||
Reference in New Issue
Block a user