summaryrefslogtreecommitdiffstats
path: root/ansible/build_yardstick_image.yml
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-09-01 02:17:54 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-09-25 00:29:39 -0700
commite487ba0ec96a7f2324a03778f1dc0097f818553b (patch)
treedf80e924b5ff7656bc8165988beebcdce562f822 /ansible/build_yardstick_image.yml
parent76ce36d88d9bcb274e65ed816f437a31fd2830a1 (diff)
ansible: resize VNF image
When compiling Trex, DPDK, collectd and all the SampleVNFs we use more than the 2.2GB size of the original Ubuntu cloud image. Accordingly we need to resize the image. If we were not inside a docker container we would use virt-resize to automatically handle all the cases, but virt-resize launches qemu. Instead we can use qemu-img to add extra space, then luckily we can use parted to resize the partition and finally resize2fs to resize the filesystem. This limits us to only ext3/4 images, but if we need to we could add support for other filesystems by checking file system type. Change-Id: Iac84b8e6967af5be64c280a7b1eaaf09f5d6b3aa Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'ansible/build_yardstick_image.yml')
-rw-r--r--ansible/build_yardstick_image.yml18
1 files changed, 18 insertions, 0 deletions
diff --git a/ansible/build_yardstick_image.yml b/ansible/build_yardstick_image.yml
index 5f9158576..35d9da45e 100644
--- a/ansible/build_yardstick_image.yml
+++ b/ansible/build_yardstick_image.yml
@@ -87,6 +87,12 @@
- name: convert image to raw
command: "qemu-img convert {{ image_dest }} {{ raw_imgfile }}"
+ - name: resize image to allow for more VNFs
+ command: "qemu-img resize -f raw {{ raw_imgfile }} +2G"
+
+ - name: resize parition to allow for more VNFs
+ command: "parted -s -a optimal {{ raw_imgfile }} resizepart 1 100%"
+
- name: create mknod devices in chroot
command: "mknod -m 0660 /dev/loop{{ item }} b 7 {{ item }}"
args:
@@ -124,6 +130,18 @@
- set_fact:
image_fs_type: "{{ blkid_res.stdout.strip() }}"
+ - fail:
+ msg: "We only support ext4 image filesystems because we have to resize"
+ when: image_fs_type != "ext4"
+
+ - name: fsck the image filesystem
+ command: "e2fsck -y -f {{ image_first_partition_device }}"
+
+ - name: resize filesystem to full partition size
+ command: resize2fs {{ image_first_partition_device }}
+
+ - name: fsck the image filesystem
+ command: "e2fsck -y -f {{ image_first_partition_device }}"
- name: make tmp disposable fstab
command: mktemp --tmpdir fake_fstab.XXXXXXXXXX