diff options
| author | Troy Dawson <tdawson@redhat.com> | 2015-06-25 11:29:42 -0500 | 
|---|---|---|
| committer | Troy Dawson <tdawson@redhat.com> | 2015-06-25 11:29:42 -0500 | 
| commit | 0bd9aa5e06febf45030743d7322e66c850d0b290 (patch) | |
| tree | 51cca2ac4b38a50810086cef4551c18f82fe355a | |
| parent | 1bff88ee9b5cb52251454f01849831b4681229ff (diff) | |
| parent | 9e05538cbfd593198b176b4fd4b8d0473a7f3a43 (diff) | |
| download | openshift-0bd9aa5e06febf45030743d7322e66c850d0b290.tar.gz openshift-0bd9aa5e06febf45030743d7322e66c850d0b290.tar.bz2 openshift-0bd9aa5e06febf45030743d7322e66c850d0b290.tar.xz openshift-0bd9aa5e06febf45030743d7322e66c850d0b290.zip  | |
Merge pull request #306 from tdawson/2015-06-partition
Expand partition and filesystem to use entire disk.
| -rw-r--r-- | roles/openshift_expand_partition/README.md | 87 | ||||
| -rw-r--r-- | roles/openshift_expand_partition/defaults/main.yml | 18 | ||||
| -rw-r--r-- | roles/openshift_expand_partition/meta/main.yml | 17 | ||||
| -rw-r--r-- | roles/openshift_expand_partition/tasks/main.yml | 14 | 
4 files changed, 136 insertions, 0 deletions
diff --git a/roles/openshift_expand_partition/README.md b/roles/openshift_expand_partition/README.md new file mode 100644 index 000000000..cd394e1ba --- /dev/null +++ b/roles/openshift_expand_partition/README.md @@ -0,0 +1,87 @@ +# openshift_expand_partition + +This role is useful to expand a partition, and it's file system to +fully utilize the disk it is on.  It does this by first expanding the +partition, and then expanding the file system on the partition. + +## Requirements + +* A machine with a disk that is not fully utilized + +* cloud-utils-growpart rpm (either installed or avialable via yum) + +* The partition you are expanding needs to be at the end of the partition list + +## Role Variables + +``` +# The following variables are if you want to expand +#   /dev/xvda3 that has a filesystem xfs + +# oep_drive +# Drive that has the partition we wish to expand. +oep_drive: "/dev/xvda" + +# oep_partition +# Partition that we wish to expand. +oep_partition: 3 + +# oep_file_system +# What file system is on the partition +#   Currently only xfs, and ext(2,3,4) are supported +#   For ext2, ext3, or ext4 just use ext +oep_file_system: "xfs" + +``` + +## Dependencies + +growpart + +## Example Playbook + +With this playbook, the partition /dev/xvda3 will expand to fill the free +space on /dev/xvda, and the file system will be expanded to fill the new +partition space. + +    - hosts: mynodes +      sudo: no +      remote_user: root +      gather_facts: no +      roles: +        - role: openshift_expand_partition +          oep_drive: "/dev/xvda" +          oep_partition: 3 +          oep_file_system: "xfs" + + +## Full example + + +* Create an `inventory` file: +    ``` +    [mynodes] +    10.0.0.1 +    10.0.0.2 +    ``` + +* Create an ansible playbook, say `expandvar.yaml`: +    ``` +    - hosts: mynodes +      sudo: no +      remote_user: root +      gather_facts: no +      roles: +        - role: openshift_expand_partition +          oep_drive: "/dev/xvda" +          oep_partition: 3 +          oep_file_system: "xfs" + +* Run the playbook: +    ``` +    ansible-playbook -i inventory expandvar.yml +    ``` + +## License + +Apache 2.0 diff --git a/roles/openshift_expand_partition/defaults/main.yml b/roles/openshift_expand_partition/defaults/main.yml new file mode 100644 index 000000000..cce9bd951 --- /dev/null +++ b/roles/openshift_expand_partition/defaults/main.yml @@ -0,0 +1,18 @@ +--- +# oep_drive +# Drive that has the partition we wish to expand. +oep_drive: "/dev/xvda" + +# oep_partition +# Partition that we wish to expand. +oep_partition: 3 + +# oep_partition_mount_point +# Where the partition is mounted +oep_partition_mount_point: /var + +# oep_file_system +# What file system is on the partition +#   Currently only xfs, and ext(2,3,4) are supported +#   For ext2, ext3, or ext4 just use ext +oep_file_system: "xfs" diff --git a/roles/openshift_expand_partition/meta/main.yml b/roles/openshift_expand_partition/meta/main.yml new file mode 100644 index 000000000..c2a38be17 --- /dev/null +++ b/roles/openshift_expand_partition/meta/main.yml @@ -0,0 +1,17 @@ +--- +galaxy_info: +  author: Troy Dawson +  description: Expand partition and filesystem to fill free space on disks. +  company: Red Hat, Inc. +  license: license (Apache) +  min_ansible_version: 1.4 +  platforms: +  - name: EL +    versions: +    - 7 +  - name: Fedora +    versions: +    - all +  categories: +    - openshift +    - cloud diff --git a/roles/openshift_expand_partition/tasks/main.yml b/roles/openshift_expand_partition/tasks/main.yml new file mode 100644 index 000000000..8bc399070 --- /dev/null +++ b/roles/openshift_expand_partition/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: Ensure growpart is installed +  yum: pkg=cloud-utils-growpart state=present + +- name: Grow the partitions +  command: "growpart {{oep_drive}} {{oep_partition}}" + +- name: Expand the filesystem - xfs +  command: "xfs_growfs {{oep_drive}}{{oep_partition}}" +  when: oep_file_system == "xfs" + +- name: Expand the filesystem - ext(2,3,4) +  command: "resize2fs {{oep_drive}}{{oep_partition}}" +  when: oep_file_system == "ext"  | 
