An initial framework for deployment
An initial framework for deployment. As the os_ironic_node module has not yet been written, the actual deployment step is commented out. That being said, configdrive files are generated utilizing the supplied data.
This commit is contained in:
parent
84424be8ae
commit
3789eea86e
15
deploy/README.rst
Normal file
15
deploy/README.rst
Normal file
@ -0,0 +1,15 @@
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
Requirements:
|
||||
|
||||
- The baremetal.csv file that was utilized for the enrollment process.
|
||||
|
||||
How this works?
|
||||
===============
|
||||
|
||||
The deploy.yaml playbook is intended to create configdrives for servers, and initiate the node deployments through ironic.
|
||||
|
||||
Example:
|
||||
|
||||
ansible-playbook -i ../inventory/localhost -vvvv deploy.yaml -e baremetal_csv_file=../enroll/baremetal.csv
|
34
deploy/configdrive.yaml
Normal file
34
deploy/configdrive.yaml
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
- name: "Name Make Temporary folder to build configdrive"
|
||||
local_action: command mktemp -d
|
||||
register: variable_configdrive_location
|
||||
- name: "Make Metadata folder - /openstack/2012-08-10"
|
||||
local_action: file state=directory name={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/2012-08-10/
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
||||
- name: "Make Metadata folder - /openstack/latest"
|
||||
local_action: file state=directory name={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/latest/
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
||||
- name: "Place template in each openstack/2012-08-10 folder"
|
||||
local_action: template src=templates/openstack_meta_data.json.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/2012-08-10/meta_data.json
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
||||
- name: "Place template in each openstack/latest folder"
|
||||
local_action: template src=templates/openstack_meta_data.json.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/latest/meta_data.json
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
||||
- name: "Make Metadata folder - /openstack/latest"
|
||||
local_action: file state=directory name={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/content/
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
||||
- name: "Write network interface template"
|
||||
local_action: template src=templates/interfaces.j2 dest={{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}/openstack/content/0000
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
||||
- name: "Make config drive files"
|
||||
local_action: command mkisofs -R -V config-2 -o /tmp/configdrive-{{item.split(',')[9]}}.iso {{ variable_configdrive_location.stdout }}/{{item.split(',')[9]}}
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
||||
- name: "Cleanup configdrive"
|
||||
local_action: file state=absent force=yes name={{ variable_configdrive_location.stdout }}
|
48
deploy/deploy.yaml
Normal file
48
deploy/deploy.yaml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
name: "Enroll hardware from baremetal.csv into Ironic"
|
||||
sudo: yes
|
||||
gather_facts: yes
|
||||
# Todo: Rip vars out, refactor.
|
||||
tasks:
|
||||
- name: "Error if variable baremetal_csv_file is not defined"
|
||||
local_action: fail msg="baremetal_csv_file must be defined for this playbook to execute, please pass option '-e baremetal_csv_file=<path/to/file>'"
|
||||
when: baremetal_csv_file is not defined
|
||||
- name: "Validate that CSV file exists"
|
||||
local_action: stat path={{ baremetal_csv_file }}
|
||||
register: test_baremetal_csv_file
|
||||
- name: "Error if file does not exist."
|
||||
local_action: fail msg="The variable defined for baremetal_csv_file is not to a file. Please define a file and try again."
|
||||
when: test_baremetal_csv_file.stat.isreg == false
|
||||
- name: "Verify CoreOS kernel is present."
|
||||
local_action: stat path={{ http_boot_folder }}/coreos_production_pxe.vmlinuz
|
||||
register: test_core_os_kernel_present
|
||||
- name: "Error if the CoreOS kernel is missing."
|
||||
local_action: error msg="CoreOS kernel not found. Consider re-running setup."
|
||||
when: test_core_os_kernel_present.stat.exists == false
|
||||
- name: "Verify CoreOS ramdisk is present."
|
||||
local_action: stat path={{ http_boot_folder }}/coreos_production_pxe_image-oem.cpio.gz
|
||||
register: test_core_os_image_present
|
||||
- name: "Error if the CoreOS ramdisk is missing."
|
||||
local_action: error msg="CoreOS ramdisk was not. Consider re-running setup."
|
||||
when: test_core_os_image_present.stat.exists == false
|
||||
- name: "Verify that deployment image is present."
|
||||
local_action: stat path={{deploy_image}}
|
||||
register: test_deploy_image
|
||||
# TODO: checksum for the above stat operation will be required for deployment.
|
||||
- name: "Error if deployment image is missing."
|
||||
local_action: error msg="Deployment image is missing. Consider re-running setup."
|
||||
when: test_deploy_image.stat.exists == false
|
||||
- name: "Check to see if there is a file where the ssh_key_path is defined"
|
||||
local_action: stat path={{ ssh_public_key_path }}
|
||||
register: test_ssh_public_key_path
|
||||
- name: "Error if ssh_public_key_path is not valid"
|
||||
local_action: error msg="CoreOS ramdisk was not. Consider re-running setup."
|
||||
when: test_ssh_public_key_path.stat.exists == false
|
||||
- name: "Read ssh public key in"
|
||||
local_action: set_fact ssh_public_key="{{ lookup('file', ssh_public_key_path ) }}"
|
||||
- name: "Create configdrives"
|
||||
include: configdrive.yaml
|
||||
#- name: "Enroll nodes in Ironic"
|
||||
# include: setup_nodes.yaml
|
21
deploy/setup_nodes.yaml
Normal file
21
deploy/setup_nodes.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: "Enroll Hardware"
|
||||
# TODO: Conceptual idea of structure, needs image_source corrected and
|
||||
#disk format clarified
|
||||
os_ironic_node:
|
||||
auth_plugin: None
|
||||
auth: None
|
||||
ironic_url: "{{ ironic_url }}"
|
||||
uuid: "{{item.split(',')[9]}}"
|
||||
state: active
|
||||
config_drive: "/tmp/{{item.split(',')[9]}}-configdrive.iso"
|
||||
deploy_kernel: "{{ deploy_kernel }}"
|
||||
deploy_ramdisk: "{{ deploy_ramdisk }}"
|
||||
instance_info:
|
||||
image_source: "http://this.host:8080/{{deploy_image_filename}}"
|
||||
image_checksum: "{{ test_deploy_image.md5 }}"
|
||||
image_disk_format:
|
||||
uuid: "{{item.split(',')[9]}}"
|
||||
delegate_to: localhost
|
||||
with_lines:
|
||||
- cat {{ baremetal_csv_file }}
|
10
deploy/templates/interfaces.j2
Normal file
10
deploy/templates/interfaces.j2
Normal file
@ -0,0 +1,10 @@
|
||||
# interfaces(5) file used by ifup(8) and ifdown(8)
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto {{ node_default_network_interface }}
|
||||
iface {{ node_default_network_interface }} inet static
|
||||
address {{ item.split(',')[11] }}
|
||||
netmask {{ ipv4_subnet_mask }}
|
||||
gateway {{ ipv4_gateway }}
|
||||
dns-nameservers {{ ipv4_nameserver }}
|
16
deploy/templates/openstack_meta_data.json.j2
Normal file
16
deploy/templates/openstack_meta_data.json.j2
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"availability_zone": "",
|
||||
"files": [
|
||||
{
|
||||
"content_path": "/content/0000",
|
||||
"path": "/etc/network/interfaces"
|
||||
},
|
||||
],
|
||||
"hostname": "{{item.split(',')[10]}}",
|
||||
"name": "{{item.split(',')[10]}}",
|
||||
"meta": {},
|
||||
"public_keys": {
|
||||
"mykey": "{{ ssh_public_key }}"
|
||||
},
|
||||
"uuid": "{{item.split(',')[9]}}"
|
||||
}
|
@ -5,17 +5,17 @@ ironic_db_password: aSecretPassword473z
|
||||
mysql_password:
|
||||
testing: true
|
||||
http_boot_folder: /httpboot
|
||||
ssh_public_key_path: ~/.ssh/id_rsa.pub
|
||||
latest_os_ironic_url: https://raw.githubusercontent.com/juliakreger/ansible-modules-extras/features/new-openstack/cloud/os_ironic.py
|
||||
deploy_kernel: "{{http_boot_folder}}/coreos_production_pxe.vmlinuz"
|
||||
deploy_ramdisk: "{{http_boot_folder}}/coreos_production_pxe_image-oem.cpio.gz"
|
||||
deploy_image_filename: "ubuntu-14.04-server-cloudimg-amd64.tar.gz"
|
||||
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
|
||||
node_default_network_interface: eth0
|
||||
# ipv4_subnet_mask is intended for the static ipv4 address assignments.
|
||||
ipv4_subnet_mask: 255.255.255.0
|
||||
ipv4_gateway: 192.168.1.1
|
||||
ipv4_nameservers:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
ipv4_nameserver: 8.8.8.8
|
||||
# ipmi_bridging: Default undefined. Valid values: "no", "single", and "dual"
|
||||
# See http://docs.openstack.org/developer/ironic/_modules/ironic/drivers/modules/ipmitool.html
|
||||
#ipmi_bridging: no
|
||||
|
@ -33,6 +33,7 @@
|
||||
- psmisc
|
||||
- nginx
|
||||
- wget
|
||||
- genisoimage
|
||||
- name: "Install 14.10 packages"
|
||||
local_action: apt name={{ item }}
|
||||
with_items:
|
||||
|
Loading…
x
Reference in New Issue
Block a user