Open yizhanglinux opened 4 years ago
Currently, the only support for partition
volumes is for a single partition that fills the entire disk (aka "partition pool").
Found another interesting thing, with bellow playbook, the first task will created one partition with the entire disk[1], and the second task will remove the encryption layer and creat one 4GB size disk partition. So size works for partition pool with remove encryption layer opeartion.
---
- hosts: all
become: true
vars:
storage_safe_mode: false
mount_location: '/opt/test1'
volume_size: '5g'
tasks:
- include_role:
name: storage
- include_tasks: get_unused_disk.yml
vars:
min_size: "{{ volume_size }}"
max_return: 1
- name: Create an encrypted partition volume w/ default fs
include_role:
name: storage
vars:
storage_pools:
- name: foo
type: partition
disks: "{{ unused_disks }}"
volumes:
- name: test1
type: partition
mount_point: "{{ mount_location }}"
size: 4g
encryption: true
encryption_passphrase: 'yabbadabbadoo'
- shell: lsblk
- name: Remove the encryption layer
include_role:
name: storage
vars:
storage_pools:
- name: foo
type: partition
disks: "{{ unused_disks }}"
volumes:
- name: test1
type: partition
mount_point: "{{ mount_location }}"
size: 4g
encryption: false
encryption_passphrase: 'yabbadabbadoo'
- shell: lsblk
- name: Clean up
include_role:
name: storage
vars:
storage_volumes:
- name: foo
type: disk
disks: "{{ unused_disks }}"
state: absent
The two times' lsblk ouput:
#lsblk
"stdout_lines": [
"NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT",
"sdb 8:16 0 279.4G 0 disk ",
"└─sdb1 8:17 0 279.4G 0 part ",
" └─luks-38db2aa2-5ef8-4a0b-96b7-77bf85658f72 253:3 0 279.4G 0 crypt /opt/test1"
]
#lsblk
"stdout_lines": [
"NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT",
"sdb 8:16 0 279.4G 0 disk ",
"└─sdb1 8:17 0 4G 0 part /opt/test1"
]
The two times' lsblk ouput:
#lsblk "stdout_lines": [ "NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT", "sdb 8:16 0 279.4G 0 disk ", "└─sdb1 8:17 0 279.4G 0 part ", " └─luks-38db2aa2-5ef8-4a0b-96b7-77bf85658f72 253:3 0 279.4G 0 crypt /opt/test1" ] #lsblk "stdout_lines": [ "NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT", "sdb 8:16 0 279.4G 0 disk ", "└─sdb1 8:17 0 4G 0 part /opt/test1" ]
This issue was fixed by bellow PR, the partition's size is now same as the disk https://github.com/linux-system-roles/storage/pull/125
playbook
ansible log
The size: 4g doesn't work for sdd disk