]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Add task to partition extra drives (like on smithi) 178/head
authorDan Mick <dan.mick@redhat.com>
Fri, 11 Dec 2015 20:36:03 +0000 (12:36 -0800)
committerDan Mick <dan.mick@redhat.com>
Sat, 12 Dec 2015 00:22:58 +0000 (16:22 -0800)
Signed-off-by: Dan Mick <dan.mick@redhat.com>
roles/testnode/tasks/drive_partitioning.yml [new file with mode: 0644]
roles/testnode/tasks/main.yml

diff --git a/roles/testnode/tasks/drive_partitioning.yml b/roles/testnode/tasks/drive_partitioning.yml
new file mode 100644 (file)
index 0000000..6f0bf64
--- /dev/null
@@ -0,0 +1,39 @@
+---
+# Partition a data drive, like the nvme devices in smithi.  Only included
+# if drive_to_partition is defined, and only changes the drive if it
+# doesn't already have four partitions
+#
+# It might be nice to make this flexible someday and parameterize the
+# number of chunks
+
+- name: "Check if partitioning is needed for {{ drive_to_partition }}"
+  shell: "parted -m {{ drive_to_partition }} print | grep '^[0-9]:' | wc -l"
+  register: partition_count
+
+- name: Write a new partition table to {{ drive_to_partition }}
+  # -s: don't prompt for "are you sure"
+  command: "parted -s {{ drive_to_partition }} mktable msdos"
+  when: partition_count.stdout != '4'
+
+- name: "Write partition entries to {{ drive_to_partition }}"
+  command: "parted {{ drive_to_partition }} unit '%' mkpart primary {{ item }}"
+  with_items:
+    - "0 25"
+    - "25 50"
+    - "50 75"
+    - "75 100"
+  when: partition_count.stdout != '4'
+
+- name: "Add /scratch_devs for {{ drive_to_partition }} p1"
+  lineinfile:
+    dest: /scratch_devs
+    create: yes
+    owner: root
+    group: root
+    mode: 0644
+    line: "{{ drive_to_partition }}{{ item }}"
+  with_items:
+    - p1
+    - p2
+    - p3
+    - p4
index 3a751a55a94f0fe11c5099512145732d82f1edbd..eeb6019b888832fabc9c11d43f62ae5794bb45f8 100644 (file)
   tags:
     - monitoring-scripts
 
+# partition drives, if any are requested
+- include: drive_partitioning.yml
+  when: drive_to_partition is defined
+  tags:
+    - partition
+
 # configure ssh
 - include: ssh.yml
   tags: