blob: a4b6de0d521637bc477e8d296321ecd75ba878ff [file] [log] [blame]
---
- hosts: 127.0.0.1
connection: local
vars:
vbox_manage: 'VBoxManage'
vmdk_path: '~/.vagrant.d/boxes/uclbioresource-VAGRANTSLASH-oracle68/1.0.0/virtualbox'
original_hd: '{{ vmdk_path }}/box-disk1.vmdk'
resize_hd: '{{ vmdk_path }}/resized-box-disk1.vdi'
swap_hd: '{{ vmdk_path }}/swap-box-disk1.vmdk'
size: '32678'
tasks:
- name: Check for existing resize hd
stat:
path: '{{ resize_hd }}'
register: exists
tags:
- clean
- name: Remove existing resize hd
ignore_errors: yes
shell: "{{ vbox_manage }} closemedium {{ resize_hd }}"
register: exists.stat.exists
tags:
- clean
- name: Remove existing resize hd file if it still remains
file:
path: '{{ resize_hd }}'
state: absent
register: exists.stat.exists
tags:
- clean
- name: Clone and reformat hd
shell: "{{ vbox_manage }} clonehd {{ original_hd }} {{ resize_hd }} --format VDI"
tags:
- clone
- name: Resize hd
shell: "{{ vbox_manage }} modifyhd {{ resize_hd }} --resize {{ size }}"
tags:
- resize
- name: Reformat resized hd for swap
shell: "{{ vbox_manage }} clonehd {{ original_hd }} {{ swap_hd }} --format VMDK"
tags:
- format
- name: Removed interim resize
shell: "{{ vbox_manage }} closemedium {{ resize_hd }}"
tags:
- remove
# - name: Remove original_hd
# shell: "{{ vbox_manage }} closemedium {{ original_hd }}"
# tags:
# - remove
- name: Rename swap file to original
copy:
src: '{{ swap_hd }}'
dest: '{{ original_hd }}'
force: yes
tags:
- rename
# - name: Attached resized hd to vm
# shell: "{{ vbox_manage }} modifyvm {{ vm_id }} --hda {{ original_hd }}"
# tags:
# - attach