Skip to content

Ansible Role for automated filesystem extension management on AWS EC2 RHEL-based instances. It intelligently detects XFS and EXT4 partitions and extends them with configurable thresholds and built-in safety features.

License

Notifications You must be signed in to change notification settings

damarseta/ansible-role-filesystem-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible - Filesystem Extension

Automated filesystem extension detection and management for AWS EC2 RHEL-based instances.

Description

This Ansible role automatically detects and extends filesystem partitions on AWS EC2 instances running RHEL-based distributions. It provides intelligent detection of available disk space, automatic partition extension, and filesystem growth while maintaining system stability and data integrity.

Features

  • Automatic detection of extendable disk devices
  • Support for XFS, EXT4, and EXT3 filesystems
  • Configurable thresholds for extension triggers
  • Dry-run mode for safe testing
  • Partition table backup before modifications
  • AWS EC2 optimized device detection
  • Comprehensive logging and reporting

Requirements

  • Ansible >= 2.12
  • Target systems: RHEL 8/9, CentOS 8/9, Amazon Linux 2/2023
  • Root privileges on target hosts
  • Cloud-utils-growpart package availability

Role Variables

Core Configuration

Variable Default Description
filesystem_extension_enabled true Enable/disable filesystem extension
filesystem_extension_auto_extend true Automatically extend when conditions are met
filesystem_extension_dry_run false Only check and report, don't make changes

Device Configuration

Variable Default Description
filesystem_extension_devices ["/dev/xvda", "/dev/xvdf", "/dev/nvme0n1", "/dev/nvme1n1"] Disk devices to check
filesystem_extension_max_partitions 5 Maximum partitions to check per device

Threshold Configuration

Variable Default Description
filesystem_extension_threshold_percent 10 Minimum free space percentage trigger
filesystem_extension_threshold_gb 5 Minimum free space GB trigger

Advanced Configuration

Variable Default Description
filesystem_extension_supported_fs ["xfs", "ext4", "ext3"] Supported filesystem types
filesystem_extension_backup_partition_table true Backup partition table before changes
filesystem_extension_log_level info Log level for operations

Dependencies

None. This role manages its own package dependencies.

Example Playbook

Basic Usage

---
- hosts: aws_ec2_instances
  become: yes
  roles:
    - damarseta.filesystem-extension

Custom Configuration

---
- hosts: aws_ec2_instances
  become: yes
  vars:
    filesystem_extension_threshold_percent: 5
    filesystem_extension_threshold_gb: 10
    filesystem_extension_devices:
      - /dev/xvda
      - /dev/nvme0n1
  roles:
    - damarseta.filesystem-extension

Dry Run Mode

---
- hosts: aws_ec2_instances
  become: yes
  vars:
    filesystem_extension_dry_run: true
  roles:
    - damarseta.filesystem-extension

Usage Examples

Check filesystem status

ansible-playbook -i inventory site.yml --tags filesystem-extension

Run in dry-run mode

ansible-playbook -i inventory site.yml -e "filesystem_extension_dry_run=true"

Extension with custom thresholds

ansible-playbook -i inventory site.yml -e "filesystem_extension_threshold_percent=15"

Tags

  • filesystem-extension: All tasks
  • packages: Package installation
  • detection: Device and filesystem detection
  • analysis: Filesystem analysis
  • extension: Filesystem extension operations
  • summary: Summary and reporting

Supported Platforms

  • Amazon Linux 2
  • Amazon Linux 2023
  • RHEL 8.x
  • RHEL 9.x
  • CentOS 8.x
  • CentOS 9.x
  • Rocky Linux 8.x/9.x
  • AlmaLinux 8.x/9.x

AWS EC2 Specific Features

  • Automatic detection of EBS volume types
  • Support for NVMe and traditional block devices
  • Integration with EC2 instance metadata
  • Optimized for common AWS storage patterns

Safety Features

  • Partition table backup before modifications
  • Dry-run mode for testing
  • Filesystem type validation
  • Error handling and rollback capabilities
  • Comprehensive logging

Troubleshooting

Common Issues

  1. Permission denied errors

    • Ensure the playbook runs with become: yes
    • Verify sudo privileges on target hosts
  2. Package installation failures

    • Check repository configuration
    • Verify network connectivity
    • Ensure package manager is functional
  3. Device not found

    • Verify device paths in filesystem_extension_devices
    • Check lsblk output on target system
    • Ensure devices are attached to EC2 instance

Debug Mode

Enable debug output:

vars:
  filesystem_extension_log_level: debug

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License. See LICENSE file for details.

Author Information

Copyleft 2025 - Damarseta Infrastructure Team.

Support

For issues and feature requests, please use the GitHub issue tracker.

About

Ansible Role for automated filesystem extension management on AWS EC2 RHEL-based instances. It intelligently detects XFS and EXT4 partitions and extends them with configurable thresholds and built-in safety features.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published