From 97a8dd5d3419cd148f102131953cfa71aefcf0f9 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 12 Mar 2015 21:06:57 +0000 Subject: [PATCH] Updates for enrolling VMs --- enroll/enroll.yaml | 9 ++-- enroll/virtual_enroll.yaml | 43 +++++++++++++++++++ .../tasks/main.yml | 3 ++ inventory/group_vars/all.yaml | 6 +++ 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 enroll/virtual_enroll.yaml diff --git a/enroll/enroll.yaml b/enroll/enroll.yaml index ea230b3af..97a7c24b9 100644 --- a/enroll/enroll.yaml +++ b/enroll/enroll.yaml @@ -15,12 +15,15 @@ - 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: "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." 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.." 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.." 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") diff --git a/enroll/virtual_enroll.yaml b/enroll/virtual_enroll.yaml new file mode 100644 index 000000000..a2924b14d --- /dev/null +++ b/enroll/virtual_enroll.yaml @@ -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 }} diff --git a/install/roles/install_standalone_ironic_localhost/tasks/main.yml b/install/roles/install_standalone_ironic_localhost/tasks/main.yml index 658dcafe7..b4fb21d47 100644 --- a/install/roles/install_standalone_ironic_localhost/tasks/main.yml +++ b/install/roles/install_standalone_ironic_localhost/tasks/main.yml @@ -128,6 +128,9 @@ local_action: group name=ironic - name: "Creating an ironic service user" 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" local_action: template src=init_template.j2 dest=/etc/init/{{item.service_name}}.conf owner=root group=root with_items: diff --git a/inventory/group_vars/all.yaml b/inventory/group_vars/all.yaml index 22aea202a..f53ccc3ec 100644 --- a/inventory/group_vars/all.yaml +++ b/inventory/group_vars/all.yaml @@ -27,3 +27,9 @@ dhcp_pool_end: 192.168.1.250 # 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 + +# 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