Skip to content

Instantly share code, notes, and snippets.

@ffrank
Last active May 28, 2019 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffrank/e3e1a706b616155be9a06ad6af90dc8d to your computer and use it in GitHub Desktop.
Save ffrank/e3e1a706b616155be9a06ad6af90dc8d to your computer and use it in GitHub Desktop.
mount "/mnt/acceptance_mount" {
state => "exists",
device => "/tmp/loopdevice",
type => "ext2",
options => {
"rw"=>"",
"loop"=>"",
},
}
#!/bin/bash
fail()
{
echo >&2 "FATAL - $@"
exit 1
}
assert()
{
eval "$@"
if [ $? -ne 0 ] ; then
fail "ASSERTION: $@"
fi
}
mount_point=/mnt/acceptance_mount
fs_file=/tmp/loopdevice
manifest="mount { '$mount_point': device => '$fs_file', ensure => 'mounted' }"
mkdir -p $mount_point \
|| fail "could not prepare mount point at $mount_point"
dd if=/dev/zero of=$fs_file bs=1M count=10 \
|| fail "could not create empty file $fs_file"
mke2fs $fs_file \
|| fail "could not create filesystem in file $fs_file"
mgmt run --tmp-prefix --converged-timeout 5 \
puppet 'mount { "'$mount_point'": device => "'$fs_file'", fstype => "ext2", options => "loop,rw", ensure => "mounted" }'
assert grep -q $fs_file /proc/mounts
mgmt run --tmp-prefix --converged-timeout 5 \
puppet 'mount { "'$mount_point'": device => "'$fs_file'", ensure => "unmounted" }'
assert ! grep -q $fs_file /proc/mounts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment