Initial dynamic enrollment role

Adding a role and modified test playbook that can be leveraged
to utilize the dynamic inventory for enrolling nodes into Ironic
without any special logic in the role it's self.

Change-Id: I085d81aa7fc4926cd2a1354f0cd9da403c802d2d
This commit is contained in:
Julia Kreger 2015-06-03 16:49:54 -04:00
parent e05809c07e
commit d700c832cd
7 changed files with 313 additions and 0 deletions

View File

@ -0,0 +1,85 @@
ironic-enroll-dynamic
=====================
Enrolls nodes into Ironic utilizing the os_ironic Ansible module that is installed by Bifrost.
Requirements
------------
This role is dependent upon the os-ironic ansible module, which is dependent upon shade (https://git.openstack.org/cgit/openstack-infra/shade/), which in this case is presently dependent upon the Ironic Python Client Library (http://git.openstack.org/cgit/openstack/python-ironicclient/).
Role Variables
--------------
ironic_url: The setting defining the URL to the Ironic API. Presently defaulted to: "http://localhost:6385/"
deploy_kernel: The kernel url, image id, or file representing the kernel to utilize for deploying to this node.
deploy_ramdisk: The ramdisk url, image id, or file representing the ramdisk image to load to deploy this node.
This role expects a data structure similar to the one below, however it should be understood that the individual entries under power can vary based on power driver required.
{
"node1": {
"uuid": "00000000-0000-0000-0000-000000000000",
"driver_info": {
"power": {
"ipmi_target_channel": "0",
"ipmi_username": "ADMIN",
"ipmi_address": "192.168.122.1",
"ipmi_target_address": "0",
"ipmi_password": "undefined",
"ipmi_bridging": "single"
}
},
"nics": [
{
"mac": "00:01:02:03:04:05"
}.
],
"driver": "agent_ipmitool",
"ip_address": "192.168.122.2",
"properties": {
"cpu_arch": "x86_64",
"ram": "3072",
"disk_size": "10",
"cpus": "1"
},
"name": "node1"
}
}
Dependencies
------------
This role is presently dependent upon the ironic-install role which installs the necessary requirements.
Example Playbook
----------------
- hosts: baremetal
connection: local
name: "Executes enrollment of nodes into Ironic"
roles:
- role: ironic-enroll-dynamic
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

View File

@ -0,0 +1,2 @@
---
ironic_url: "http://localhost:6385/"

View File

@ -0,0 +1,2 @@
---
# handlers file for ironic-enroll-dynamic

View File

@ -0,0 +1,116 @@
---
galaxy_info:
author: Ironic Developers
description: Enrolls nodes into 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: []

View File

@ -0,0 +1,30 @@
# 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: "Dynamic Enrollment"
os_ironic:
auth_type: None
auth: None
ironic_url: "{{ ironic_url }}"
driver: "{{ driver }}"
uuid: "{{ uuid }}"
state: present
nics: "{{nics}}"
properties: "{{ properties }}"
driver_info:
power: "{{ driver_info.power }}"
deploy:
deploy_kernel: "{{ deploy_kernel_url }}"
deploy_ramdisk: "{{ deploy_ramdisk_url }}"
delegate_to: localhost

View File

@ -0,0 +1,2 @@
---
# vars file for ironic-enroll-dynamic

View File

@ -0,0 +1,76 @@
# Example command line to use:
# ansible-playbook -vvvv -i inventory/bifrost_inventory.py test-bifrost-dynamic.yaml -e use_cirros=true -e testing_user=cirros
---
- hosts: localhost
connection: local
name: "Executes install, enrollment, and testing in one playbook"
sudo: yes
gather_facts: yes
pre_tasks:
- name: "Set default baremetal.csv file if not already defined"
set_fact:
baremetal_csv_file: "/tmp/baremetal.csv"
when: baremetal_csv_file is not defined
- name: "Set ci_testing flag if a list of changes are found in the environment variables"
set_fact:
ci_testing: true
when: lookup('env', 'ZUUL_CHANGES') != ""
- name: "Set ci_testing_zuul if it appears we are running in upstream OpenStack CI"
set_fact:
ci_testing_zuul: true
when: "'bare-trusty' in ansible_hostname"
- name: "Collect process list if running in OpenStack CI"
command: ps aux
when: ci_testing_zuul is defined
- name: "Collect list of listening network sockets if running in OpenStack CI"
shell: netstat -apn|grep LISTEN
when: ci_testing_zuul is defined
roles:
- role: bifrost-create-vm-nodes
- role: ironic-install
cleaning: false
testing: true
- hosts: baremetal
name: "Enroll node with Ironic"
sudo: no
connection: local
roles:
- role: ironic-enroll-dynamic
- hosts: localhost
connection: local
name: "Validates prior to deployment"
sudo: yes
roles:
- role: bifrost-validate-host-for-deploy
- hosts: localhost
connection: local
name: "Executes install, enrollment, and testing in one playbook"
sudo: no
gather_facts: yes
roles:
- role: bifrost-configdrives
- 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.
- hosts: testvm
name: "Tests connectivity to the VM"
sudo: no
gather_facts: no
remote_user: "{{ testing_user }}"
roles:
- role: bifrost-test-vm
- hosts: localhost
connection: local
name: "Unprovisions the test node"
sudo: no
gather_facts: no
roles:
- role: bifrost-unprovision-nodes
- hosts: localhost
connection: local
name: "Unprovisions the test node"
sudo: no
gather_facts: no
roles:
- role: ironic-delete