From 97f20c5e9db50f6a4c93eef922cd198b53b8d5ba Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 28 Nov 2018 13:41:02 +0000 Subject: [PATCH] MNAIO: If there is no secondary data disk, use the root disk In order to allow testing within OpenStack-CI, we need to cater for the ability to run the tooling without a secondary data disk. This patch changes the tooling to try the detection, and if there is no secondary disk it will just use the root disk for /data/images. Change-Id: I56d76e68b6914b3e12948b022e0e702557684c50 --- multi-node-aio/playbooks/setup-host.yml | 62 +++++++++++++++---------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/multi-node-aio/playbooks/setup-host.yml b/multi-node-aio/playbooks/setup-host.yml index c96cd718..4f1c858d 100644 --- a/multi-node-aio/playbooks/setup-host.yml +++ b/multi-node-aio/playbooks/setup-host.yml @@ -333,37 +333,49 @@ autostart: yes with_dict: "{{ mnaio_host_networks }}" - - name: Locate the largest writable data disk if mnaio_data_disk is not set - shell: > - lsblk -brndo NAME,TYPE,FSTYPE,RO,SIZE | awk '/d[b-z]+ disk +0/{ if ($4>m){m=$4; d=$1}}; END{print d}' - register: lsblk - changed_when: false + - name: If mnaio_data_disk is not set, discover and set it if possible when: - mnaio_data_disk is undefined + block: + - name: Locate the largest writable data disk if mnaio_data_disk is not set + shell: > + lsblk -brndo NAME,TYPE,FSTYPE,RO,SIZE | awk '/d[b-z]+ disk +0/{ if ($4>m){m=$4; d=$1}}; END{print d}' + register: lsblk + changed_when: false - - name: Setup the data disk partition - parted: - device: "/dev/{{ mnaio_data_disk | default(lsblk.stdout) }}" - label: gpt - number: 1 - name: data1 - state: present - register: _add_partition + - name: Set mnaio_data_disk fact if a suitable disk was found + set_fact: + mnaio_data_disk: "{{ lsblk.stdout | trim }}" + when: + - lsblk.stdout | trim != '' - - name: Prepare the data disk file system - filesystem: - fstype: ext4 - dev: "/dev/{{ mnaio_data_disk | default(lsblk.stdout) }}1" - force: yes + - name: Setup the data disk if one was set or found when: - - _add_partition is changed + - mnaio_data_disk is defined + block: + - name: Setup the data disk partition + parted: + device: "/dev/{{ mnaio_data_disk }}" + label: gpt + number: 1 + name: data1 + state: present + register: _add_partition - - name: Mount the data disk - mount: - src: "/dev/{{ mnaio_data_disk | default(lsblk.stdout) }}1" - path: /data - state: mounted - fstype: ext4 + - name: Prepare the data disk file system + filesystem: + fstype: ext4 + dev: "/dev/{{ mnaio_data_disk }}1" + force: yes + when: + - _add_partition is changed + + - name: Mount the data disk + mount: + src: "/dev/{{ mnaio_data_disk }}1" + path: /data + state: mounted + fstype: ext4 - name: Create the images directory file: