Merge "Move diskimage-builder and bootable image creation to roles"
This commit is contained in:
commit
64a6b88478
@ -74,7 +74,7 @@ To enable EPEL on CentOS, run::
|
||||
Installation
|
||||
============
|
||||
|
||||
The installation is split in to two parts.
|
||||
The installation is split into two parts.
|
||||
|
||||
The first part is a bash script which lays the basic groundwork of installing
|
||||
Ansible itself.
|
||||
@ -85,6 +85,12 @@ Edit ``./playbooks/inventory/group_vars/all`` to match your environment.
|
||||
- Change network_interface to match the interface that will need to service DHCP requests.
|
||||
- Change the ironic_db_password which is set by Ansible in MySQL and in Ironic's configuration file.
|
||||
|
||||
The install process builds or modifies a disk image to deploy. The following two settings (which are mutually exclusive) allow you to choose if a partition image is used or an image is created with diskimage-builder.
|
||||
|
||||
create_image_via_dib: true
|
||||
transform_boot_image: false
|
||||
|
||||
|
||||
Proxy::
|
||||
|
||||
if running behind the proxy. export environment variables http_proxy and https_proxy
|
||||
|
@ -7,6 +7,8 @@
|
||||
roles:
|
||||
- { role: bifrost-prep-for-install, when: skip_install is not defined }
|
||||
- ironic-install
|
||||
- { role: bifrost-create-dib-image, when: create_image_via_dib == true and transform_boot_image == false }
|
||||
- { role: bifrost-create-bootable-image, when: create_image_via_dib == false and transform_boot_image == true }
|
||||
environment:
|
||||
http_proxy: "{{ lookup('env','http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env','https_proxy') }}"
|
||||
|
@ -27,7 +27,11 @@ deploy_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network
|
||||
# due to the image creation process.
|
||||
deploy_image_filename: "deployment_image.qcow2"
|
||||
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.
|
||||
# Setting to utilize diskimage-builder to create a bootable image.
|
||||
create_image_via_dib: true
|
||||
# Transform boot image is intended for use with the Ubuntu trusty image. It makes the image bootable by installing Grub.
|
||||
# Setting to prepend a partition image with a boot sector and partition table.
|
||||
transform_boot_image: false
|
||||
node_default_network_interface: eth0
|
||||
# ipv4_subnet_mask is intended for the static ipv4 address assignments.
|
||||
ipv4_subnet_mask: 255.255.255.0
|
||||
|
63
playbooks/roles/bifrost-create-bootable-image/README.md
Normal file
63
playbooks/roles/bifrost-create-bootable-image/README.md
Normal file
@ -0,0 +1,63 @@
|
||||
bifrost-create-bootable-image
|
||||
=============================
|
||||
|
||||
This role modifies an existing partition image to create a bootable disk image.
|
||||
This role is now legacy code and will not be supported in future.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
This role requires:
|
||||
|
||||
- Ansible 1.9
|
||||
- qemu-img
|
||||
- kpartx
|
||||
- The partition image must have the grub bootloader installed.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
http_boot_folder, deploy_image_filename, and deploy_image all control the final destination of the built image.
|
||||
|
||||
http_boot_folder: /httpboot
|
||||
deploy_image_filename: "partition_image.raw"
|
||||
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
None at this time.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
name: "Create bootable image"
|
||||
sudo: yes
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- role: bifrost-create-bootable-image
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
Ironic Developers
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
http_boot_folder: /httpboot
|
||||
deploy_image_filename: "partition_image.raw"
|
||||
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
|
||||
|
16
playbooks/roles/bifrost-create-bootable-image/meta/main.yml
Normal file
16
playbooks/roles/bifrost-create-bootable-image/meta/main.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: Ironic Developers
|
||||
description: Create bootable disk image for Bifrost
|
||||
company: OpenStack
|
||||
license: Apache
|
||||
min_ansible_version: 1.9
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- trusty
|
||||
- utopic
|
||||
categories:
|
||||
- cloud
|
||||
- cloud:openstack
|
||||
dependencies: []
|
@ -14,16 +14,16 @@
|
||||
# limitations under the License.
|
||||
---
|
||||
- name: "Extracting the raw disk image"
|
||||
command: qemu-img convert -O raw "{{http_boot_folder}}/{{deploy_image_filename}}" "{{http_boot_folder}}/{{deploy_image_filename}}.raw"
|
||||
command: qemu-img convert -O raw "{{deploy_image}}" "{{deploy_image}}.raw"
|
||||
- name: "Copying Image however with 32k of empty space at the beginning of the file."
|
||||
command: dd if="{{http_boot_folder}}/{{deploy_image_filename}}.raw" of="{{http_boot_folder}}/{{deploy_image_filename}}.bootimg" seek=64
|
||||
command: dd if="{{deploy_image}}.raw" of="{{deploy_image}}.bootimg" seek=64
|
||||
- name: "Creating Partition Table lining up with the copied file's contents."
|
||||
shell: echo '32;' | sfdisk "{{http_boot_folder}}/{{deploy_image_filename}}.bootimg" -uB -f
|
||||
shell: echo '32;' | sfdisk "{{deploy_image}}.bootimg" -uB -f
|
||||
- name: "Allocating one of two loopbacks"
|
||||
command: losetup -f
|
||||
register: stored_value_loopback_alpha
|
||||
- name: "Creating loopback connetion to new image file"
|
||||
command: losetup "{{stored_value_loopback_alpha.stdout}}" "{{http_boot_folder}}/{{deploy_image_filename}}.bootimg"
|
||||
command: losetup "{{stored_value_loopback_alpha.stdout}}" "{{deploy_image}}.bootimg"
|
||||
- name: "Forcing partition table to be re-read"
|
||||
command: kpartx -v -a "{{stored_value_loopback_alpha.stdout}}"
|
||||
# Using second loopback as for some reason /dev/mapper does not translate into a chroot cleanly when devfs is mounted
|
||||
@ -64,6 +64,6 @@
|
||||
- name: "Detaching first loop device"
|
||||
command: losetup -d "{{stored_value_loopback_alpha.stdout}}"
|
||||
- name: "Moving image to .oldimg"
|
||||
command: mv "{{http_boot_folder}}/{{deploy_image_filename}}" "{{http_boot_folder}}/{{deploy_image_filename}}.oldimg"
|
||||
command: mv "{{deploy_image}}" "{{deploy_image}}.oldimg"
|
||||
- name: "Moving new image into place"
|
||||
command: mv "{{http_boot_folder}}/{{deploy_image_filename}}.bootimg" "{{http_boot_folder}}/{{deploy_image_filename}}"
|
||||
command: mv "{{deploy_image}}.bootimg" "{{deploy_image}}"
|
21
playbooks/roles/bifrost-create-bootable-image/tasks/main.yml
Normal file
21
playbooks/roles/bifrost-create-bootable-image/tasks/main.yml
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
---
|
||||
- name: "Test if deploy image is present"
|
||||
stat: path={{ deploy_image }}
|
||||
register: test_image_present
|
||||
- name: "Creating bootable image"
|
||||
include: create_bootable_image.yml
|
||||
when: test_image_present.stat.exists == true
|
69
playbooks/roles/bifrost-create-dib-image/README.md
Normal file
69
playbooks/roles/bifrost-create-dib-image/README.md
Normal file
@ -0,0 +1,69 @@
|
||||
bifrost-create-dib-image
|
||||
========================
|
||||
|
||||
This role uses diskimage-builder to create a bootable disk image.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
This role requires:
|
||||
|
||||
- Ansible 1.9
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
The dib_env_vars are settings for the diskimage-builder environment variables which allow settings to be passed to elements that are being utilized to build a disk image. More information on diskimage-builder can be found at http://git.openstack.org/cgit/openstack/diskimage-builder/. Additionally, an extra_dib_elements setting exists which is a space separated list of elements to incorporate into the image.
|
||||
|
||||
dib_env_vars:
|
||||
DIB_CLOUD_INIT_DATASOURCES: "ConfigDrive"
|
||||
ELEMENTS_PATH: "/opt/stack/diskimage-builder/elements"
|
||||
extra_dib_elements: ""
|
||||
|
||||
http_boot_folder, deploy_image_filename, and deploy_image all control the final destination of the built image.
|
||||
|
||||
http_boot_folder: /httpboot
|
||||
deploy_image_filename: "deployment_image.qcow2"
|
||||
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
|
||||
|
||||
dib_os_element controls which OS will be used to build the image.
|
||||
|
||||
dib_os_element: "ubuntu"
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
dib-utils must be installed from pip for the image creation to work.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
name: "Build DIB image"
|
||||
sudo: yes
|
||||
gather_facts: yes
|
||||
roles:
|
||||
- role: bifrost-create-dib-image
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
10
playbooks/roles/bifrost-create-dib-image/defaults/main.yml
Normal file
10
playbooks/roles/bifrost-create-dib-image/defaults/main.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
http_boot_folder: /httpboot
|
||||
deploy_image_filename: "deployment_image.qcow2"
|
||||
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
|
||||
dib_os_element: "ubuntu"
|
||||
dib_env_vars:
|
||||
DIB_CLOUD_INIT_DATASOURCES: "ConfigDrive"
|
||||
ELEMENTS_PATH: "/opt/stack/diskimage-builder/elements"
|
||||
# extra_dib_elements is a space separated list of elements.
|
||||
extra_dib_elements: ""
|
16
playbooks/roles/bifrost-create-dib-image/meta/main.yml
Normal file
16
playbooks/roles/bifrost-create-dib-image/meta/main.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: Ironic Developers
|
||||
description: Create image with diskimage-builder for Bifrost
|
||||
company: OpenStack
|
||||
license: Apache
|
||||
min_ansible_version: 1.9
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- trusty
|
||||
- utopic
|
||||
categories:
|
||||
- cloud
|
||||
- cloud:openstack
|
||||
dependencies: []
|
@ -13,6 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
---
|
||||
# If attempting to utilize a base Ubuntu image, diskimage-builder
|
||||
# is the recommended, and default path.
|
||||
- name: "Test if deploy image is present"
|
||||
stat: path={{ deploy_image }}
|
||||
register: test_image_present
|
||||
- name: "Initiate image build"
|
||||
shell: disk-image-create -a amd64 -o "{{http_boot_folder}}/{{deploy_image_filename}}" -t qcow2 "{{dib_os_element}}" vm serial-console cloud-init-datasources "{{ extra_dib_elements}}"
|
||||
environment: dib_env_vars
|
||||
when: test_image_present.stat.exists == false
|
@ -1,7 +1,7 @@
|
||||
Role Name
|
||||
ironic-install
|
||||
=========
|
||||
|
||||
This role installs a standalone ironic deployment with all required substrate in order for it to be utilized, including MySQL, RabbitMQ, dnsmasq, nginx. Additionally, it utilizes diskimage-builder to create a bootable disk image.
|
||||
This role installs a standalone ironic deployment with all required substrate in order for it to be utilized, including MySQL, RabbitMQ, dnsmasq, nginx.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
@ -15,8 +15,6 @@ Internet access was originally a requirement but no longer is. See doc/source/o
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Testing mode is intended to help facilitate testing of the Bifrost roles and Ironic by utilizing virtual machines on the localhost and the agent_ssh driver. This variable should be set globally for playbooks utilizing the install-ironic role.
|
||||
|
||||
testing: false
|
||||
@ -30,18 +28,6 @@ The Ironic python client and shade libraries can be installed directly from GIT.
|
||||
ironicclient_source_install: false
|
||||
shade_source_install: false
|
||||
|
||||
The dib_env_vars are settings for the diskimage-builder environment variables which allow settings to be passed to elements that are being utilized to build a disk image. More information on diskimage-builder can be found at http://git.openstack.org/cgit/openstack/diskimage-builder/. Additionally, an extra_dib_elements setting exists which is a space separated list of elements to incorporate into the image.
|
||||
|
||||
dib_env_vars:
|
||||
DIB_CLOUD_INIT_DATASOURCES: "ConfigDrive"
|
||||
ELEMENTS_PATH: "/opt/stack/diskimage-builder/elements"
|
||||
extra_dib_elements: ""
|
||||
|
||||
As for controlling if a partition image is utilized or an image is created with diskimage-builder, the following two settings which are mutually exclusive, can allow a user to choose which logic is utilized.
|
||||
|
||||
create_image_via_dib: true
|
||||
transform_boot_image: false
|
||||
|
||||
By default this role installs dnsmasq to act as a DHCP server for provisioning hosts. In the event this is not required, set the following configuration:
|
||||
|
||||
include_dhcp_server: false
|
||||
@ -87,3 +73,4 @@ limitations under the License.
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
Ironic Developers
|
||||
|
@ -28,7 +28,6 @@ deploy_kernel_upstream_url: http://tarballs.openstack.org/ironic-python-agent/co
|
||||
deploy_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{nginx_port}}/coreos_production_pxe_image-oem.cpio.gz"
|
||||
deploy_ramdisk_upstream_url: http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe_image-oem.cpio.gz
|
||||
deploy_image_filename: "deployment_image.qcow2"
|
||||
deploy_image_upstream_url: http://cloud-images.ubuntu.com/releases/trusty/release/ubuntu-14.04-server-cloudimg-amd64.tar.gz
|
||||
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
|
||||
# Use cirros instead of building an image via diskimage-builder
|
||||
use_cirros: false
|
||||
|
@ -209,21 +209,6 @@
|
||||
- name: "Download cirros to use for deployment if requested"
|
||||
get_url: url={{ cirros_deploy_image_upstream_url }} dest="{{ deploy_image }}"
|
||||
when: "{{use_cirros|bool}}"
|
||||
- name: "Test if deploy image is present"
|
||||
stat: path={{ deploy_image }}
|
||||
register: test_os_image_present
|
||||
# Create bootable image takes a partition image, prepends space for a
|
||||
# bootloader, partition table, and then installs the bootloader.
|
||||
#
|
||||
# If attempting to utilize a base Ubuntu image, diskimage-builder
|
||||
# is the recommended, and default path.
|
||||
- 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
|
||||
# DIB is presently the default path.
|
||||
- name: "Creating image via disk image 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
|
||||
- name: "Explicitly permit nginx port (TCP) for file downloads from nodes to be provisioned"
|
||||
command: iptables -I INPUT -p tcp --dport {{nginx_port}} -i {{network_interface}} -j ACCEPT
|
||||
- name: "Explicitly permit TCP/6385 for IPA callback"
|
||||
|
@ -50,6 +50,8 @@
|
||||
- role: ironic-install
|
||||
cleaning: false
|
||||
testing: true
|
||||
- { role: bifrost-create-dib-image, when: create_image_via_dib == true and transform_boot_image == false }
|
||||
- { role: bifrost-create-bootable-image, when: create_image_via_dib == false and transform_boot_image == true }
|
||||
environment:
|
||||
http_proxy: "{{ lookup('env','http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env','https_proxy') }}"
|
||||
|
@ -34,6 +34,8 @@
|
||||
- role: ironic-install
|
||||
cleaning: false
|
||||
testing: true
|
||||
- { role: bifrost-create-dib-image, when: create_image_via_dib == true and transform_boot_image == false }
|
||||
- { role: bifrost-create-bootable-image, when: create_image_via_dib == false and transform_boot_image == true }
|
||||
- role: ironic-enroll
|
||||
testing: true
|
||||
- role: bifrost-validate-host-for-deploy
|
||||
|
Loading…
x
Reference in New Issue
Block a user