Skip to content
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

could not get the luks2 key size in in task 'Check LUKS key size' #495

Closed
guazhangRH opened this issue Dec 11, 2024 · 5 comments · Fixed by #497
Closed

could not get the luks2 key size in in task 'Check LUKS key size' #495

guazhangRH opened this issue Dec 11, 2024 · 5 comments · Fixed by #497

Comments

@guazhangRH
Copy link

this is testcase issue I think.
reproducer

        - name: Create an encrypted lvm pool using a key file and key size
          include_role:
            name: linux-system-roles.storage
          vars:
            storage_pools:
              - name: foo
                type: lvm
                disks: "{{ unused_disks }}"
                encryption: true
                encryption_key: "{{ storage_test_key_file.path }}"
                encryption_luks_version: luks2
                encryption_key_size: 512
                volumes:
                  - name: test2
                    mount_point: "{{ mount_location }}"
                    size: 4g
 

error info

TASK [Check LUKS key size] *****************************************************************************************************
fatal: [localhost]: FAILED! => {
    "assertion": "_storage_test_luks_dump.stdout is search(__pattern, multiline=True)",
    "changed": false,
    "evaluated_to": false,
    "msg": "Wrong key size for pool foo"

looks the task [Check LUKS key size] just support luks1

add a task to check luks2 key size

 - name: Check LUKS key size for luks1
  assert:
    that: _storage_test_luks_dump.stdout is search(__pattern, multiline=True)
    msg: Wrong key size for pool {{ storage_test_pool.name }}
  vars:
    __pattern: >-
      ^MK bits:\s+{{ storage_test_pool.encryption_key_size }}$
  when:
    - storage_test_pool.state == 'present'
    - storage_test_pool.encryption
    - storage_test_pool.encryption_key_size
    - storage_test_pool.encryption_luks_version == 'luks1'


- name: Check LUKS key size for luks2
  assert:
    that: _storage_test_luks_dump.stdout is search(__pattern, multiline=True)
    msg: Wrong key size for pool {{ storage_test_pool.name }}
  vars:
    __pattern: >-
      Key:.*{{ storage_test_pool.encryption_key_size  }}\s+bits$
  when:
    - storage_test_pool.state == 'present'
    - storage_test_pool.encryption
    - storage_test_pool.encryption_key_size
    - storage_test_pool.encryption_luks_version == 'luks2'
@guazhangRH
Copy link
Author

the task Check LUKS cipher also failed with luks2

add new task for luks2 to check the cipher.

- name: Check LUKS cipher for luks2
  assert:
    that: _storage_test_luks_dump.stdout is search(__pattern, multiline=True)
    msg: Wrong cipher  for pool {{ storage_test_pool.name }} 
  vars:
    __pattern: "Cipher:\\s+{{ storage_test_pool.encryption_cipher }}$"
  when:
    - storage_test_pool.state == 'present'
    - storage_test_pool.encryption
    - storage_test_pool.encryption_cipher
    - storage_test_pool.encryption_luks_version == 'luks2'

@spetrosi
Copy link
Contributor

Hi @guazhangRH, I do not understand the root of this issue. The task Check LUKS key size is present in tests in tests/tests_luks.yml. And tests that use this code pass in our CI, see latest results in #395.
On what platform does it fail for you?

@guazhangRH
Copy link
Author

Hi,
in our tests_luks.yaml just cover encryption_luks_version: luks1 and don't cover encryption_luks_version: luks2

the task Check LUKS key size will failed if set encryption_luks_version: luks2

please check my reproducer if need.

richm added a commit to richm/linux-system-roles-storage that referenced this issue Dec 11, 2024
This fixes linux-system-roles#495

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm
Copy link
Contributor

richm commented Dec 11, 2024

@guazhangRH #497

@guazhangRH
Copy link
Author

thanks , looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants