Updates for enrolling VMs

This commit is contained in:
David Shrewsbury 2015-03-12 21:06:57 +00:00
parent 1b315d406d
commit 97a8dd5d34
4 changed files with 58 additions and 3 deletions

View File

@ -15,12 +15,15 @@
- name: "Error if file does not exist." - 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." 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 when: test_baremetal_csv_file.stat.isreg == false
- name: "If testing, enroll virtual machines."
include: virtual_enroll.yaml
when: testing == true
- name: "If no ipmi_bridging value set, or a value of no exists, execute standard sequence." - name: "If no ipmi_bridging value set, or a value of no exists, execute standard sequence."
include: standard_enroll.yaml include: standard_enroll.yaml
when: ipmi_bridging is not defined or ipmi_bridging == "no" when: testing == false and (ipmi_bridging is not defined or ipmi_bridging == "no")
- name: "If ipmi_bridging is set to single, execute single bridge enrollment sequence.." - name: "If ipmi_bridging is set to single, execute single bridge enrollment sequence.."
include: ipmi_bridging_single_enroll.yaml include: ipmi_bridging_single_enroll.yaml
when: ipmi_bridging is defined and ipmi_bridging == "single" when: testing == false and (ipmi_bridging is defined and ipmi_bridging == "single")
- name: "If ipmi_bridging is set to single, execute dual bridge enrollment sequence.." - name: "If ipmi_bridging is set to single, execute dual bridge enrollment sequence.."
include: ipmi_bridging_dual_enroll.yaml include: ipmi_bridging_dual_enroll.yaml
when: ipmi_bridging is defined and ipmi_bridging == "dual" when: testing == false and (ipmi_bridging is defined and ipmi_bridging == "dual")

View File

@ -0,0 +1,43 @@
---
- name: "Enroll Virtual Machines"
# The variable definitions below seem far from ideal, however there
# seems to be no better way to handle CSV files for looping at this time.
#
# Ideally with_lines would be used with an include, however that support was removed in
# Ansible 1.6 and no direct replacement exists.
#
# mac_address: "{{item.split(',')[1]}}"
# username: "{{item.split(',')[2]}}"
# password: "{{item.split(',')[3]}}"
# management_address: "{{item.split(',')[4]}}"
# cpu_cores: "{{item.split(',')[5]}}"
# memory_MB: "{{item.split(',')[6]}}"
# disk_MB: "{{item.split(',')[7]}}"
os_ironic:
auth_plugin: None
auth: None
ironic_url: "{{ ironic_url }}"
driver: "agent_ssh"
# UUID determination TBD for mass enrollment.
uuid: "{{item.split(',')[9]}}"
state: present
nics:
- mac: "{{item.split(',')[0]}}"
properties:
cpus: "{{item.split(',')[4]}}"
cpu_arch: "x86_64"
ram: "{{item.split(',')[5]}}"
disk_size: "{{item.split(',')[6]}}"
driver_info:
power:
ssh_virt_type: "virsh"
ssh_address: "{{ ssh_address }}"
ssh_port: "{{ ssh_port }}"
ssh_username: "{{ ssh_username }}"
ssh_key_filename: "{{ ssh_private_key_path }}"
deploy:
deploy_kernel: "{{ deploy_kernel_url }}"
deploy_ramdisk: "{{ deploy_ramdisk_url }}"
delegate_to: localhost
with_lines:
- cat {{ baremetal_csv_file }}

View File

@ -128,6 +128,9 @@
local_action: group name=ironic local_action: group name=ironic
- name: "Creating an ironic service user" - name: "Creating an ironic service user"
local_action: user name=ironic group=ironic local_action: user name=ironic group=ironic
- name: "Adding ironic user to libvirtd group"
local_action: user name=ironic group=libvirtd append=yes
when: testing == true
- name: "Placing services" - name: "Placing services"
local_action: template src=init_template.j2 dest=/etc/init/{{item.service_name}}.conf owner=root group=root local_action: template src=init_template.j2 dest=/etc/init/{{item.service_name}}.conf owner=root group=root
with_items: with_items:

View File

@ -27,3 +27,9 @@ dhcp_pool_end: 192.168.1.250
# ipmi_bridging: Default undefined. Valid values: "no", "single", and "dual" # ipmi_bridging: Default undefined. Valid values: "no", "single", and "dual"
# See http://docs.openstack.org/developer/ironic/_modules/ironic/drivers/modules/ipmitool.html # See http://docs.openstack.org/developer/ironic/_modules/ironic/drivers/modules/ipmitool.html
#ipmi_bridging: no #ipmi_bridging: no
# When testing with VMs, define SSH address, port, and user for agent_ssh driver.
ssh_username: ironic
ssh_port: 1024
ssh_address: 127.0.0.1
ssh_private_key_path: /home/ironic/.ssh/ironic_key