Git Product home page Git Product logo

ansible-bash-shrink-lv's Introduction

ansible-bash-shrink-lv

Ansible role for shrinking a logical volume. The role contains the shell scripts to shrink the logical volume, as well as the script wrapping it to run as part of the pre-mount step during the boot process. The devices to shrink and their expected sizes should be passed via the shrink_lv_devices variable. For example

vars:
  shrink_lv_devices:
  - device: /dev/mapper/test
    size: 4G

Example of a playbook to run the role

The following yaml is an example of a playbook that runs the role against a group of hosts named rhel to extend their boot partition by 1G. The boot partition is automatically retrieved by the role by identifying the existing mounted partition to /boot and passing the information to the script using the kernel_opts.

- name: Shrink Logical Volumes playbook
  hosts: rhel
  debugger: on_failed
  vars:
    shrink_lv_devices:
      - device: /dev/mapper/test
        size: 4G
  pre_tasks:
    - name: Gather facts
      ansible.builtin.setup:
        gather_subset:
          - kernel
  roles:
    - shrink_lv

With an inventory file consisting of group [rhel]:

[rhel]
localhost

[rhel:vars]
ansible_user=root
ansible_port=2022

Validate execution

The script will add an entry to the kernel messages (/dev/kmsg or /var/log/messages) with success or failure. In case of failure, it may also include an error message retrieved from the execution of the script.

A successful execution will look similar to this:

[root@localhost ~]# cat /var/log/messages |grep Resizing -A 2 -B 2
Oct 16 17:55:00 localhost /dev/mapper/rhel-root: 29715/2686976 files (0.2% non-contiguous), 534773/10743808 blocks
Oct 16 17:55:00 localhost dracut-pre-mount: resize2fs 1.42.9 (28-Dec-2013)
Oct 16 17:55:00 localhost journal: Resizing the filesystem on /dev/mapper/rhel-root to 9699328 (4k) blocks.#012The filesystem on /dev/mapper/rhel-root is now 9699328 blocks long.
Oct 16 17:55:00 localhost journal:  Size of logical volume rhel/root changed from 40.98 GiB (10492 extents) to 37.00 GiB (9472 extents).
Oct 16 17:55:00 localhost journal:  Logical volume rhel/root successfully resized.

ansible-bash-shrink-lv's People

Contributors

jordigilh avatar ygalblum avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

swapdisk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.