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

Shrink LV: prefix all internal variables with role name #44

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/shrinklv-internal-variable-names.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- shrink_lv - Rename internal variables with role name prefix
12 changes: 6 additions & 6 deletions roles/shrink_lv/tasks/check_device.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
- name: Get the mount point info
ansible.builtin.set_fact:
_mount_info: "{{ ansible_facts.mounts | selectattr('device', 'equalto', item.device) }}"
shrink_lv_mount_info: "{{ ansible_facts.mounts | selectattr('device', 'equalto', item.device) }}"

- name: Assert that the mount point exists
ansible.builtin.assert:
that: (_mount_info | length) == 1
that: (shrink_lv_mount_info | length) == 1
fail_msg: "Mount point {{ item.device }} does not exist"

- name: Assert that the filesystem is supported
ansible.builtin.assert:
that: _mount_info[0].fstype in ['ext4']
fail_msg: "Unsupported filesystem '{{ _mount_info[0].fstype }}' on '{{ item.device }}'"
that: shrink_lv_mount_info[0].fstype in ['ext4']
fail_msg: "Unsupported filesystem '{{ shrink_lv_mount_info[0].fstype }}' on '{{ item.device }}'"

- name: Assert that the filesystem has enough free space
ansible.builtin.assert:
that: _mount_info[0].block_size * _mount_info[0].block_used < (item.size | ansible.builtin.human_to_bytes)
that: shrink_lv_mount_info[0].block_size * shrink_lv_mount_info[0].block_used < (item.size | ansible.builtin.human_to_bytes)
fail_msg: >
Requested size {{ item.size }} is smaller than currently used
{{ (_mount_info[0].block_size * _mount_info[0].block_used) | ansible.builtin.human_readable }}
{{ (shrink_lv_mount_info[0].block_size * shrink_lv_mount_info[0].block_used) | ansible.builtin.human_readable }}