Do you work under AAP now?
This commit is contained in:
parent
ff5eeea88b
commit
efaf76ff23
66
filter_plugins/fallback_space_check.py
Executable file
66
filter_plugins/fallback_space_check.py
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
# bigboot_size: "{{ bigboot_size_expansion_mb[:-2] | int | get_block_size_up }}"
|
||||||
|
|
||||||
|
class FilterModule (object):
|
||||||
|
def filters (self):
|
||||||
|
return {
|
||||||
|
'bigboot_fallback_size': self.bigboot_fallback_size,
|
||||||
|
'moo': self.moo,
|
||||||
|
}
|
||||||
|
|
||||||
|
def bigboot_fallback_size(self, fallback_size):
|
||||||
|
return ('{}{}'.format(fallback_size, 'M'))
|
||||||
|
|
||||||
|
def moo(self, a_variable):
|
||||||
|
a_new_variable = (str(a_variable) + '~~~~MOOOOOOOOOOOOOOOOOOOOOOOOO! => ' + '%s' % type(a_variable))
|
||||||
|
return a_new_variable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# import shutil
|
||||||
|
# import os
|
||||||
|
|
||||||
|
# def check_mount_space(mount_path, min_space_gb=1):
|
||||||
|
# try:
|
||||||
|
# # Get disk usage statistics for the mount point
|
||||||
|
# disk_usage = shutil.disk_usage(mount_path)
|
||||||
|
|
||||||
|
# # Convert bytes to gigabytes
|
||||||
|
# free_space_gb = disk_usage.free / (1024 ** 3)
|
||||||
|
|
||||||
|
# print(f"Mount point: {mount_path}")
|
||||||
|
# print(f"Free space: {free_space_gb:.2f} GB")
|
||||||
|
|
||||||
|
# if free_space_gb > min_space_gb:
|
||||||
|
# print("✓ More than 1GB available")
|
||||||
|
# return True
|
||||||
|
# else:
|
||||||
|
# print("✗ Less than 1GB available")
|
||||||
|
# return False
|
||||||
|
|
||||||
|
# except Exception as e:
|
||||||
|
# print(f"Error checking {mount_path}: {str(e)}")
|
||||||
|
# return False
|
||||||
|
|
||||||
|
# def check_all_mounts():
|
||||||
|
# # Read mount points from /proc/mounts
|
||||||
|
# with open('/proc/mounts', 'r') as f:
|
||||||
|
# mounts = f.readlines()
|
||||||
|
|
||||||
|
# results = []
|
||||||
|
# for mount in mounts:
|
||||||
|
# # Split the mount line and get the mount point (second field)
|
||||||
|
# mount_point = mount.split()[1]
|
||||||
|
|
||||||
|
# # Skip some virtual filesystems
|
||||||
|
# if mount_point.startswith(('/proc', '/sys', '/dev', '/run')):
|
||||||
|
# continue
|
||||||
|
|
||||||
|
# results.append(check_mount_space(mount_point))
|
||||||
|
|
||||||
|
# return results
|
||||||
|
|
||||||
|
# if __name__ == "__main__":
|
||||||
|
# print("Checking mount points for available space...")
|
||||||
|
# check_all_mounts()
|
@ -47,6 +47,10 @@
|
|||||||
# that: bigboot_lv_info.size_available > bigboot_expansion_diff | int
|
# that: bigboot_lv_info.size_available > bigboot_expansion_diff | int
|
||||||
# fail_msg: There is not enough space available for LV shrinking.
|
# fail_msg: There is not enough space available for LV shrinking.
|
||||||
|
|
||||||
|
- name: Copy size target to temporary variable
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
bigboot_size_target_fallback: "{{ bigboot_size_target | human_to_bytes }}"
|
||||||
|
|
||||||
- name: Check for available space and fallback if needed
|
- name: Check for available space and fallback if needed
|
||||||
ansible.builtin.include_tasks: check_space_fallback.yml
|
ansible.builtin.include_tasks: check_space_fallback.yml
|
||||||
|
|
||||||
@ -58,8 +62,8 @@
|
|||||||
# ansible.builtin.debug:
|
# ansible.builtin.debug:
|
||||||
# msg: "{{ bigboot_lv_shrink_size | int | human_readable(unit='M') }}"
|
# msg: "{{ bigboot_lv_shrink_size | int | human_readable(unit='M') }}"
|
||||||
|
|
||||||
# - name: Kill the play
|
- name: Kill the play
|
||||||
# ansible.builtin.meta: end_host
|
ansible.builtin.meta: end_host
|
||||||
|
|
||||||
- name: Capture logical volume name
|
- name: Capture logical volume name
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
|
@ -1,20 +1,12 @@
|
|||||||
---
|
---
|
||||||
- name: Debug bigboot_size_target
|
|
||||||
ansible.builtin.debug:
|
|
||||||
var: bigboot_size_target
|
|
||||||
|
|
||||||
- name: Convert size target to bytes
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
bigboot_size_target: "{{ bigboot_size_target | human_to_bytes }}"
|
|
||||||
|
|
||||||
- name: Debug bigboot_expansion_diff
|
- name: Debug bigboot_expansion_diff
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ bigboot_expansion_diff }} + {{ bigboot_size_target }}"
|
msg: "{{ bigboot_expansion_diff }} + {{ bigboot_size_target_fallback }}"
|
||||||
|
|
||||||
- name: Fail if /boot can't expand to at least 1GB
|
- name: Fail if /boot can't expand to at least 1GB
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: bigboot_size_target | human_to_bytes > 1073741824
|
that: bigboot_size_target_fallback | human_to_bytes > 1073741824
|
||||||
fail_msg: "{{ bigboot_size_target | int | human_readable(unit='M') }} is less than the minimum of 1GB for /boot"
|
fail_msg: "{{ bigboot_size_target_fallback | int | human_readable(unit='M') }} is less than the minimum of 1GB for /boot"
|
||||||
|
|
||||||
- name: Verify available space and re-check if needed
|
- name: Verify available space and re-check if needed
|
||||||
block:
|
block:
|
||||||
@ -26,12 +18,12 @@
|
|||||||
rescue:
|
rescue:
|
||||||
- name: Decrement size target by .25G
|
- name: Decrement size target by .25G
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
bigboot_size_target: "{{ bigboot_size_target | human_to_bytes - 262144000 }}"
|
bigboot_size_target_fallback: "{{ bigboot_size_target_fallback | human_to_bytes - 262144000 }}"
|
||||||
|
|
||||||
- name: Update required expansion space
|
- name: Update required expansion space
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
bigboot_expansion_diff:
|
bigboot_expansion_diff:
|
||||||
"{{ bigboot_size_target | human_to_bytes - bigboot_boot_partsize | human_to_bytes }}"
|
"{{ bigboot_size_target_fallback | human_to_bytes - bigboot_boot_partsize | human_to_bytes }}"
|
||||||
|
|
||||||
- name: Re-check disk space - RESCUE
|
- name: Re-check disk space - RESCUE
|
||||||
ansible.builtin.include_tasks: check_space_fallback.yml
|
ansible.builtin.include_tasks: check_space_fallback.yml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user