New stuff
This commit is contained in:
parent
fa1b5cce00
commit
7a93d8d72a
29
check_device2.yml
Normal file
29
check_device2.yml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Something
|
||||
hosts: bigboot
|
||||
become: false
|
||||
gather_facts: true
|
||||
|
||||
vars:
|
||||
shrink_lv_devices:
|
||||
- device: "/dev/mapper/system-root"
|
||||
size: 81229615104
|
||||
|
||||
tasks:
|
||||
- name: Get the mount point info
|
||||
ansible.builtin.set_fact:
|
||||
shrink_lv_mount_info: "{{ ansible_facts.mounts | selectattr('device', 'equalto', shrink_lv_devices[0].device) }}"
|
||||
|
||||
- name: Debug shrink_lv_mount_info
|
||||
ansible.builtin.debug:
|
||||
var: shrink_lv_mount_info
|
||||
|
||||
# - name: Assert that the mount point exists
|
||||
# ansible.builtin.assert:
|
||||
# that: (shrink_lv_mount_info | length) >= 1
|
||||
# fail_msg: "Mount point {{ shrink_lv_devices[0].device }} does not exist"
|
||||
|
||||
# - name: Assert that the filesystem is supported
|
||||
# ansible.builtin.assert:
|
||||
# that: shrink_lv_mount_info[0].fstype in ['ext4']
|
||||
# fail_msg: "Unsupported filesystem '{{ shrink_lv_mount_info[0].fstype }}' on '{{ shrink_lv_devices[0].device }}'"
|
29
check_device3.yml
Normal file
29
check_device3.yml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Something
|
||||
hosts: bigboot
|
||||
become: false
|
||||
gather_facts: true
|
||||
|
||||
vars:
|
||||
shrink_lv_devices:
|
||||
- device: "/dev/mapper/system-root"
|
||||
size: 81229615104
|
||||
|
||||
- device: "/dev/mapper/system-home"
|
||||
size: 21536149506
|
||||
|
||||
tasks:
|
||||
- name: Retrieve mount points
|
||||
ansible.builtin.setup:
|
||||
gather_subset:
|
||||
- "!all"
|
||||
- "!min"
|
||||
- mounts
|
||||
|
||||
- name: Debug mounts
|
||||
ansible.builtin.debug:
|
||||
var: ansible_facts['mounts']
|
||||
|
||||
- name: Check if device has shrunken successfully
|
||||
ansible.builtin.include_tasks: tasks/check_if_shrunk.yml
|
||||
loop: "{{ shrink_lv_devices }}"
|
10
hosts
10
hosts
@ -1,16 +1,16 @@
|
||||
[bigboot]
|
||||
bigboot-test-custom-1 ansible_host=10.10.42.5
|
||||
# bigboot-test-custom-1 ansible_host=10.10.42.5
|
||||
# bigboot-test-custom-2 ansible_host=10.10.42.13
|
||||
# bigboot-test-custom-4 ansible_host=10.10.42.15
|
||||
bigboot-test-custom-5 ansible_host=10.10.42.16
|
||||
# bigboot-test-custom-5 ansible_host=10.10.42.16
|
||||
bigboot-test-custom-6 ansible_host=10.10.42.1
|
||||
bigboot-test-custom-7 ansible_host=10.10.42.2
|
||||
# bigboot-test-custom-7 ansible_host=10.10.42.2
|
||||
# bigboot-test-custom-8 ansible_host=10.10.42.216
|
||||
# bigboot-test-custom-9 ansible_host=10.1.1.80
|
||||
|
||||
[bigboot:vars]
|
||||
# ansible_user=root
|
||||
ansible_user=testuser1
|
||||
ansible_user=root
|
||||
# ansible_user=testuser1
|
||||
|
||||
|
||||
# [mailcow_dev]
|
||||
|
21
tasks/check_if_shrunk.yml
Normal file
21
tasks/check_if_shrunk.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: Debug item
|
||||
ansible.builtin.debug:
|
||||
var: item
|
||||
|
||||
- name: Set device for mount
|
||||
ansible.builtin.set_fact:
|
||||
size_three: "{{ ansible_facts['mounts'] | selectattr('device', 'equalto', item['device']) | first }}"
|
||||
|
||||
- name: Debug size_three
|
||||
ansible.builtin.debug:
|
||||
var: size_three['size_total']
|
||||
|
||||
- name: Assert that the filesystem has shrunk
|
||||
ansible.builtin.assert:
|
||||
# yamllint disable-line rule:line-length
|
||||
that: (size_three['size_total'] | int) <= (item['size'] | ansible.builtin.human_to_bytes)
|
||||
fail_msg: >
|
||||
Logical Volume {{ item['device'] }} was NOT shrunk as requested.
|
||||
success_msg: >
|
||||
Logical Volume {{ item['device'] }} has been shrunk as requested.
|
Loading…
x
Reference in New Issue
Block a user