summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorTroy Dawson <tdawson@redhat.com>2015-06-24 17:54:23 -0500
committerTroy Dawson <tdawson@redhat.com>2015-06-24 17:54:23 -0500
commit9e05538cbfd593198b176b4fd4b8d0473a7f3a43 (patch)
tree468d1155ea99785252f3a6103a6c6069e704a158 /roles
parent3ab174fe4e0d9a6d300890bcfcaaa346181f8ec9 (diff)
downloadopenshift-9e05538cbfd593198b176b4fd4b8d0473a7f3a43.tar.gz
openshift-9e05538cbfd593198b176b4fd4b8d0473a7f3a43.tar.bz2
openshift-9e05538cbfd593198b176b4fd4b8d0473a7f3a43.tar.xz
openshift-9e05538cbfd593198b176b4fd4b8d0473a7f3a43.zip
Creating openshift_expand_partition
Diffstat (limited to 'roles')
-rw-r--r--roles/openshift_expand_partition/README.md87
-rw-r--r--roles/openshift_expand_partition/defaults/main.yml18
-rw-r--r--roles/openshift_expand_partition/meta/main.yml17
-rw-r--r--roles/openshift_expand_partition/tasks/main.yml14
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"