From 70169451cf2323f072557089f21048e925786819 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Thu, 12 Mar 2015 17:55:29 +0000 Subject: [PATCH] Initial support for diskimage-builder Changing the process over to utilize diskimage-builder as it has support for building images that will boot utilizing configuration drives. --- ...table_image.yaml => create_bootable_image.yml} | 0 .../tasks/create_dib_image.yml | 4 ++++ .../tasks/dib_install.yml | 11 +++++++++++ .../tasks/main.yml | 15 +++++++++++---- .../vars/main.yml | 7 ++++++- inventory/group_vars/all.yaml | 1 - 6 files changed, 32 insertions(+), 6 deletions(-) rename install/roles/install_standalone_ironic_localhost/tasks/{create_bootable_image.yaml => create_bootable_image.yml} (100%) create mode 100644 install/roles/install_standalone_ironic_localhost/tasks/create_dib_image.yml create mode 100644 install/roles/install_standalone_ironic_localhost/tasks/dib_install.yml diff --git a/install/roles/install_standalone_ironic_localhost/tasks/create_bootable_image.yaml b/install/roles/install_standalone_ironic_localhost/tasks/create_bootable_image.yml similarity index 100% rename from install/roles/install_standalone_ironic_localhost/tasks/create_bootable_image.yaml rename to install/roles/install_standalone_ironic_localhost/tasks/create_bootable_image.yml diff --git a/install/roles/install_standalone_ironic_localhost/tasks/create_dib_image.yml b/install/roles/install_standalone_ironic_localhost/tasks/create_dib_image.yml new file mode 100644 index 000000000..0dd5397d1 --- /dev/null +++ b/install/roles/install_standalone_ironic_localhost/tasks/create_dib_image.yml @@ -0,0 +1,4 @@ +--- +- name: "Initiate image build" + shell: disk-image-create -a amd64 -o "{{http_boot_folder}}/{{deploy_image_filename}}" -t qcow2 vm ubuntu serial-console cloud-init-datasources "{{ extra_dib_elements}}" + environment: dib_env_vars diff --git a/install/roles/install_standalone_ironic_localhost/tasks/dib_install.yml b/install/roles/install_standalone_ironic_localhost/tasks/dib_install.yml new file mode 100644 index 000000000..a25a56114 --- /dev/null +++ b/install/roles/install_standalone_ironic_localhost/tasks/dib_install.yml @@ -0,0 +1,11 @@ +--- +- name: "Shade - Retrieving diskimage-builder from git.openstack.org" + local_action: command git clone https://git.openstack.org/openstack/diskimage-builder chdir=/opt/stack creates=/opt/stack/diskimage-builder +- name: "Shade - Checking out master branch" + local_action: command git checkout -f master chdir=/opt/stack/diskimage-builder +- name: "Shade - Resetting local repository" + local_action: command git reset --hard master chdir=/opt/stack/diskimage-builder +- name: "Shade - Resyncing local repository" + local_action: command git pull --ff-only chdir=/opt/stack/diskimage-builder +- name: "Shade - Installing patched library." + local_action: command pip install -I --force-reinstall /opt/stack/diskimage-builder diff --git a/install/roles/install_standalone_ironic_localhost/tasks/main.yml b/install/roles/install_standalone_ironic_localhost/tasks/main.yml index c64077010..1bd2f8965 100644 --- a/install/roles/install_standalone_ironic_localhost/tasks/main.yml +++ b/install/roles/install_standalone_ironic_localhost/tasks/main.yml @@ -74,6 +74,9 @@ local_action: command git pull --ff-only chdir=/opt/stack/shade - name: "Shade - Installing patched shade library." local_action: command pip install -I --force-reinstall /opt/stack/shade +- name: "Include diskimage-builder installation" + include: dib_install.yml + when: create_image_via_dib == true - name: "Starting MySQL" local_action: service name=mysql state=started - name: "Starting rabbitmq-server" @@ -200,9 +203,13 @@ # Anything better! - name: "Download Ubuntu image" local_action: get_url url=http://cloud-images.ubuntu.com/releases/trusty/release/ubuntu-14.04-server-cloudimg-amd64.tar.gz dest=/httpboot/ubuntu-14.04-server-cloudimg-amd64.tar.gz - when: test_os_image_present.stat.exists == false + when: test_os_image_present.stat.exists == false and create_image_via_dib == false - name: "Extract Ubuntu image" local_action: command tar -xvzf ubuntu-14.04-server-cloudimg-amd64.tar.gz chdir=/httpboot creates=/httpboot/trusty-server-cloudimg-amd64.img - when: test_os_image_present.stat.exists == false -- include: create_bootable_image.yaml - when: test_os_image_present.stat.exists == false and transform_boot_image == true + when: test_os_image_present.stat.exists == false and create_image_via_dib == false +- name: "Creating bootable image" + include: create_bootable_image.yml + when: test_os_image_present.stat.exists == false and transform_boot_image == true and create_image_via_dib == false +- name: "Creating image via disk imae builder" + include: create_dib_image.yml + when: test_os_image_present.stat.exists == false and transform_boot_image == false and create_image_via_dib == true diff --git a/install/roles/install_standalone_ironic_localhost/vars/main.yml b/install/roles/install_standalone_ironic_localhost/vars/main.yml index 3eaf4372b..da9345e2a 100644 --- a/install/roles/install_standalone_ironic_localhost/vars/main.yml +++ b/install/roles/install_standalone_ironic_localhost/vars/main.yml @@ -28,5 +28,10 @@ required_packages_ubuntu: http_boot_folder: /httpboot transform_boot_image: false ironic_url: "http://localhost:6385/" -network_interface: "eth0" ssh_public_key_path: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub" +dib_env_vars: + DIB_CLOUD_INIT_DATASOURCES: "ConfigDrive" +# extra_dib_elements is a space separated list of elements. +extra_dib_elements: "" +create_image_via_dib: true +transform_boot_image: false diff --git a/inventory/group_vars/all.yaml b/inventory/group_vars/all.yaml index 9d09d0cc7..55ae83a4e 100644 --- a/inventory/group_vars/all.yaml +++ b/inventory/group_vars/all.yaml @@ -15,7 +15,6 @@ deploy_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network deploy_image_filename: "trusty-server-cloudimg-amd64.img" deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}" # Transform boot image is intended for use with the Ubuntu trusty image. It makes the image bootable by ihnstalling Grub. -transform_boot_image: true node_default_network_interface: eth0 # ipv4_subnet_mask is intended for the static ipv4 address assignments. ipv4_subnet_mask: 255.255.255.0