ansible-collections / community.crypto

The community.crypto collection for Ansible.
https://galaxy.ansible.com/ui/repo/published/community/crypto/
Other
100 stars 89 forks source link

luks_device: Add disk image supports #505

Open ba0f3 opened 2 years ago

ba0f3 commented 2 years ago

LUKS is able to create/open a disk image/ file, so please add disk image supports by add S_ISREG checking here

https://github.com/ansible-collections/community.crypto/blob/d0d99c31b0001f3df9828cace1e5b0f176c0b04f/plugins/modules/luks_device.py#L887

felixfontein commented 2 years ago

This might be more tricky, since "device" is built into the module in some more places (see also the usage of lsblk).

sietsevanderbom commented 2 years ago

I think I was looking for the same feature. I saw this: http://freesoftwaremagazine.com/articles/create_encrypted_disk_image_gnulinux/

Which makes a luks virtual volume from an .iso file. Tried to do this with ansible using luks_device, but only device is accepted.

felixfontein commented 2 years ago

One useful bit needed to implement this is losetup -j /path/to/file --output name. (I would prefer to use --json instead of parsing the text output, but that's not supported on CentOS 6 and 7, for example; it was only added in June 2015 in https://github.com/util-linux/util-linux/commit/4827093d4b3090389ae0cabb7d8b522cf794ef90.)