-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
luks_device: unexpected behavior involving devices named "*crypt" #409
Comments
I guess going through the output of |
The following code might work: def get_container_name_by_device(self, device):
''' obtain LUKS container name based on the device where it is located
return None if not found
raise ValueError if lsblk command fails
'''
result = self._run_command([self._lsblk_bin, device, '-nlo', 'type,name'])
if result[RETURN_CODE] != 0:
raise ValueError('Error while obtaining LUKS name for %s: %s'
% (device, result[STDERR]))
r = re.compile(r'^crypt\s+([^\s]*)\s*$')
for line in result[STDOUT].splitlines(False):
m = r.match(line)
if m:
return m.group(1)
return None @maxchaos can you try that out? |
Yes, the above fix works for my case. Thanks a lot for looking at this so fast! |
Great to hear! I created a PR out of it: #410 |
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SUMMARY
I have several LVM2 devices encrypted with LUKS whose names end with "_crypt", i.e., the file of each device after activation is of the form
/dev/VG/LV_crypt
where VG and LV are placeholders for the name of the associated LVM2 volume group and the prefix of the logical volume's name, respectively. Trying to open any of these devices using theluks_device
module fails differently depending on whether I set the parametername
or not.Particularly, when running the task described in the minimal test-case below while explicitly specifying a name for new device fails
whereas running the same task without the parameter
name
appears to succeed but no device mapped to the encrypted volume is actually created.Digging around in the implementation, this cause appears to be the current implementation of
luks_device.CryptHandler.get_container_name_by_device
and the regular expressionLUKS_NAME_REGEX
when combined with the fact that the output of executing `lsblk DEVFILE -nlo type,name' yields a result of the formfor the setup described above.
Obviously, not prefixing the names of any block device with the word "crypt" is a valid workaround for my use case but given that this module deals with encrypted data, it may be worth fixing altogether.
ISSUE TYPE
COMPONENT NAME
luks_device
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Host: Void Linux using Guix as package manager for installing ansible.
Remote: Arch Linux
STEPS TO REPRODUCE
Particularly, the following task
EXPECTED RESULTS
Open "/dev/VG/LV_crypt" and create a device "/dev/mapper/LV_opened" mapped to the former.
ACTUAL RESULTS
Fails with error
The text was updated successfully, but these errors were encountered: