2 # Copyright 2015, Rackspace US, Inc.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 # Only execute the disk partitioning process if a partition labeled
18 # 'openstack-data{1,2}' is not present and that partition is not
19 # formatted as ext4. This is an attempt to achieve idempotency just
20 # in case these tasks are executed multiple times.
21 - name: Determine whether partitions labeled openstack-data{1,2} are present
23 parted --script -l -m | egrep -q ':ext4:openstack-data[12]:;$'
24 register: data_disk_partitions
28 - check-data-disk-partitions
30 - name: Dismount and remove fstab entries for anything on the data disk device
32 name: "{{ item.mount }}"
33 src: "{{ item.device }}"
37 - data_disk_partitions.rc == 1 or bootstrap_host_data_disk_device_force | bool
38 - item.device | search(bootstrap_host_data_disk_device)
40 - "{{ ansible_mounts }}"
42 - name: Partition the whole data disk for our usage
44 when: data_disk_partitions.rc == 1 or bootstrap_host_data_disk_device_force | bool
46 - "parted --script /dev/{{ bootstrap_host_data_disk_device | regex_replace('!','/') }} mklabel gpt"
47 - "parted --align optimal --script /dev/{{ bootstrap_host_data_disk_device | regex_replace('!','/') }} mkpart openstack-data1 ext4 0% 40%"
48 - "parted --align optimal --script /dev/{{ bootstrap_host_data_disk_device | regex_replace('!','/') }} mkpart openstack-data2 ext4 40% 100%"
50 - create-data-disk-partitions
52 - name: Format the partitions
56 when: data_disk_partitions.rc == 1 or bootstrap_host_data_disk_device_force | bool
58 - "/dev/{{ bootstrap_host_data_disk_device | regex_replace('!(.*)$','/\\1p') }}1"
59 - "/dev/{{ bootstrap_host_data_disk_device | regex_replace('!(.*)$','/\\1p') }}2"
61 - format-data-partitions
63 - name: Create the mount points, fstab entries and mount the file systems
65 name: "{{ item.mount_point }}"
66 src: "{{ item.device }}"
70 - { mount_point: /openstack, device: "/dev/{{ bootstrap_host_data_disk_device | regex_replace('!(.*)$','/\\1p') }}1"}
71 - { mount_point: /var/lib/lxc, device: "/dev/{{ bootstrap_host_data_disk_device | regex_replace('!(.*)$','/\\1p') }}2"}
73 - mount-data-partitions