From 2d8127aa1787819776410f359e756ffd3b1848ed Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Fri, 5 Jun 2015 09:36:23 -0400 Subject: [PATCH] Add initial dynamic deployment role Addition of a basic role to support dynamic deployment from an inventory as opposed to a CSV file. This contains an additional conceptual feature of allowing a user to override the default instance_info by defining it as a variable. Updated test-bifrost-dynamic.yaml to incorporate the dynamic deployment role. Change-Id: I5e95c4963b3deff74243126385713ac678f38759 --- .../bifrost-deploy-nodes-dynamic/README.md | 63 ++++++++++ .../defaults/main.yml | 4 + .../handlers/main.yml | 2 + .../meta/main.yml | 117 ++++++++++++++++++ .../tasks/main.yml | 44 +++++++ .../vars/main.yml | 2 + playbooks/test-bifrost-dynamic.yaml | 4 +- 7 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 playbooks/roles/bifrost-deploy-nodes-dynamic/README.md create mode 100644 playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml create mode 100644 playbooks/roles/bifrost-deploy-nodes-dynamic/handlers/main.yml create mode 100644 playbooks/roles/bifrost-deploy-nodes-dynamic/meta/main.yml create mode 100644 playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml create mode 100644 playbooks/roles/bifrost-deploy-nodes-dynamic/vars/main.yml diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/README.md b/playbooks/roles/bifrost-deploy-nodes-dynamic/README.md new file mode 100644 index 000000000..6b0e2afca --- /dev/null +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/README.md @@ -0,0 +1,63 @@ +bifrost-deploy-nodes-dynamic +============================ + +Provisions nodes based on inventory utilizing the os_ironic_node module installed by Bifrost. + +Requirements +------------ + +This role is expected to be executed on a node that the "ironic-install" node has been executed upon. + +This role expects to be executed in a sequence with bifrost-configdrives-dynamic, however that is un-necessary IF the host has a dictionary named instance_info defined as that will be used as overriding values. + +Role Variables +-------------- + +ironic_url: This is the URL to the ironic server. By default, this is set to "http://localhost:6385/" + +network_interface: This is the network interface that the nodes receive DHCP/PXE/iPXE. This is utilized to generate the url that Ironic is configured with for image retrieval. This variable does not have a default in this role and expects to receive this information from the calling playbook. + +deploy_image_filename: This is the filename of the image to deploy, which is combined with the network_interface variable to generate a URL used to set the Ironic instance image_source. This variable does not have a default in this role and expects to receive this information from the calling playbook. + +deploy_image: This is the full path to the image to be deployed to the system. This is as Ironic requires the MD5 hash of the file to be deployed for validation during the deployment process. As a result of this requirement, the hash is automatically collected and submitted to Ironic with the node deployment request. This variable does not have a default in this role and expects to receive this information from the calling playbook. + +instance_info: A dictionary containing the information to define an instance. By default, this is NOT expected to be defined, however if defined it is passed in whole to the deployment step. This value will override deploy_image_filename, deploy_image, and network_interface variables. Key-value pairs that are generally expected are image_source, image_checksum, root_gb, however any supported key/value can be submitted to the API. + +Dependencies +------------ + +This role is intended to be executed upon a node that the ironic-install role has been executed upon. The configuration that is leveraged by this role utilizes a configuration drive to place network configuration and an SSH key on the newly deployed host. As such, the bifrost-configdrives role is required. + +Example Playbook +---------------- + +NOTE: The example below assumes bifrost's default and that an instance_info variable is not defined. + +- hosts: baremetal + connection: local + sudo: no + roles: + - role: bifrost-configdrives + - role: bifrost-setup-nodes + +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 diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml new file mode 100644 index 000000000..71704b89f --- /dev/null +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/defaults/main.yml @@ -0,0 +1,4 @@ +--- +# defaults file for bifrost-deploy-nodes-dynamic +ironic_url: "http://localhost:6385/" +nginx_port: 8080 diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/handlers/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/handlers/main.yml new file mode 100644 index 000000000..fab1e39a6 --- /dev/null +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for bifrost-deploy-nodes-dynamic diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/meta/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/meta/main.yml new file mode 100644 index 000000000..6eab5b716 --- /dev/null +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/meta/main.yml @@ -0,0 +1,117 @@ +--- +galaxy_info: + author: Ironic Developers + description: Deploys the image on to nodes in Ironic + company: OpenStack + license: Apache + min_ansible_version: 1.9 + # + # Below are all platforms currently available. Just uncomment + # the ones that apply to your role. If you don't see your + # platform on this list, let us know and we'll get it added! + # + platforms: + #- name: EL + # versions: + # - all + # - 5 + # - 6 + # - 7 + #- name: GenericUNIX + # versions: + # - all + # - any + #- name: Fedora + # versions: + # - all + # - 16 + # - 17 + # - 18 + # - 19 + # - 20 + #- name: SmartOS + # versions: + # - all + # - any + #- name: opensuse + # versions: + # - all + # - 12.1 + # - 12.2 + # - 12.3 + # - 13.1 + # - 13.2 + #- name: Amazon + # versions: + # - all + # - 2013.03 + # - 2013.09 + #- name: GenericBSD + # versions: + # - all + # - any + #- name: FreeBSD + # versions: + # - all + # - 8.0 + # - 8.1 + # - 8.2 + # - 8.3 + # - 8.4 + # - 9.0 + # - 9.1 + # - 9.1 + # - 9.2 + #- name: Ubuntu + # versions: + # - all + # - lucid + # - maverick + # - natty + # - oneiric + # - precise + # - quantal + # - raring + # - saucy + - trusty + #- name: SLES + # versions: + # - all + # - 10SP3 + # - 10SP4 + # - 11 + # - 11SP1 + # - 11SP2 + # - 11SP3 + #- name: GenericLinux + # versions: + # - all + # - any + #- name: Debian + # versions: + # - all + # - etch + # - lenny + # - squeeze + # - wheezy + # + # Below are all categories currently available. Just as with + # the platforms above, uncomment those that apply to your role. + # + categories: + - cloud + - cloud:openstack + #- cloud:gce + #- cloud:rax + #- clustering + #- database + #- database:nosql + #- database:sql + #- development + #- monitoring + #- networking + #- packaging + #- system + #- web +dependencies: +- bifrost-configdrives-dynamic diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml new file mode 100644 index 000000000..3bfe59aab --- /dev/null +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml @@ -0,0 +1,44 @@ +# 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: "Deploy to Hardware - Using custom instance_info." + os_ironic_node: + auth_type: None + auth: None + ironic_url: "{{ ironic_url }}" + uuid: "{{ uuid }}" + state: present + config_drive: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{ nginx_port }}/configdrive-{{ uuid }}.iso.gz" + instance_info: "{{ instance_info }}" + delegate_to: localhost + when: instance_info is defined +- name: "Collect the checksum of the deployment image." + local_action: stat path={{deploy_image}} + register: test_deploy_image + when: instance_info is not defined +- name: "Deploy to Hardware - Bifrost Default" + os_ironic_node: + auth_type: None + auth: None + ironic_url: "{{ ironic_url }}" + uuid: "{{ uuid }}" + state: present + config_drive: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{ nginx_port }/configdrive-{{ uuid }}.iso.gz" + instance_info: + image_source: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{ nginx_port }}/{{deploy_image_filename}}" + image_checksum: "{{ test_deploy_image.stat.md5 }}" + image_disk_format: "raw" + root_gb: 10 + delegate_to: localhost + when: instance_info is not defined diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/vars/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/vars/main.yml new file mode 100644 index 000000000..06e697ce0 --- /dev/null +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for bifrost-deploy-nodes-dynamic diff --git a/playbooks/test-bifrost-dynamic.yaml b/playbooks/test-bifrost-dynamic.yaml index ad2ec53cd..dca9a8cbe 100644 --- a/playbooks/test-bifrost-dynamic.yaml +++ b/playbooks/test-bifrost-dynamic.yaml @@ -43,18 +43,18 @@ roles: - role: bifrost-validate-host-for-deploy - hosts: baremetal - name: "Creat configuration drives." + name: "Creat configuration drive files and deploy machines." sudo: no connection: local roles: - role: bifrost-configdrives-dynamic + - role: bifrost-deploy-nodes-dynamic - hosts: localhost connection: local name: "Executes install, enrollment, and testing in one playbook" sudo: no gather_facts: yes roles: - - role: bifrost-setup-nodes - role: bifrost-prepare-for-test # The testvm Host group is added by bifrost-prepare-for-test based # on the contents of the CSV file.