From 94aee5d0ce022fe12eded82a282dc9793252f2b6 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 14:06:43 +0000 Subject: [PATCH] Set interfaces and properties on Ironic nodes Pass any interface that was specified through to Ironic; otherwise, let Ironic decide a default for it. Also, pass through any property key-value pairs we get. --- ansible/host_vars/localhost | 43 ++++++------------- .../roles/ironic-enrolment/defaults/main.yml | 13 ++++++ ansible/roles/ironic-enrolment/tasks/node.yml | 21 ++++----- 3 files changed, 34 insertions(+), 43 deletions(-) diff --git a/ansible/host_vars/localhost b/ansible/host_vars/localhost index 78bc3c7..023c830 100644 --- a/ansible/host_vars/localhost +++ b/ansible/host_vars/localhost @@ -41,13 +41,22 @@ node_types: {} # resource_class: my_rc # # Optional - defaults to []. # traits: [] -# # The following variables are all optional; if not set, a default will -# # be inferred from the `ironic_driver` specified by the node type -# # `type`. +# # A dict of key-value pairs to be set as properties on the Ironic +# # nodes. Can be used to set capabilities. Optional - defaults to {}. +# properties: {} +# # The following variables are all optional; if not set, Ironic's +# # default value will be used. +# bios_interface: no-bios # boot_interface: pxe +# console_interface: ipmitool-socat # deploy_interface: iscsi +# inspect_interface: inspector # management_interface: ipmitool +# network_interface: neutron # power_interface: ipmitool +# raid_interface: no-raid +# storage_interface: noop +# vendor_interface: ipmitool specs: [] # nova_flavors is a list of Nova flavors to be created. Each flavor must @@ -82,34 +91,6 @@ allocations_file_path: >- # The default Ironic driver of a node. Can be overridden per-node. default_ironic_driver: ipmi -# Maps Ironic drivers to a dict containing default values for Ironic node -# interfaces. Any of these values can be overridden per-node. -default_interfaces: - ipmi: - bios_interface: no-bios - boot_interface: pxe - console_interface: ipmitool-socat - deploy_interface: iscsi - inspect_interface: inspector - management_interface: ipmitool - network_interface: neutron - power_interface: ipmitool - raid_interface: no-raid - storage_interface: noop - vendor_interface: ipmitool - # NOTE(w-miller): Redfish is not currently fully supported by Tenks. - redfish: - bios_interface: no-bios - boot_interface: pxe - console_interface: no-console - deploy_interface: iscsi - inspect_interface: inspector - management_interface: redfish - network_interface: neutron - power_interface: redfish - raid_interface: no-raid - storage_interface: noop - vendor_interface: no-vendor # Maps BMC emulation tools to the Ironic driver they support. bmc_emulators: diff --git a/ansible/roles/ironic-enrolment/defaults/main.yml b/ansible/roles/ironic-enrolment/defaults/main.yml index 813f185..07692c9 100644 --- a/ansible/roles/ironic-enrolment/defaults/main.yml +++ b/ansible/roles/ironic-enrolment/defaults/main.yml @@ -12,3 +12,16 @@ ironic_virtualenv_path: # The URL of the upper constraints file to pass to pip when installing Python # packages. ironic_python_upper_constraints_url: +# A list of the interfaces that can be configured on an Ironic node. +ironic_interfaces: + - bios + - boot + - console + - deploy + - inspect + - management + - network + - power + - raid + - storage + - vendor diff --git a/ansible/roles/ironic-enrolment/tasks/node.yml b/ansible/roles/ironic-enrolment/tasks/node.yml index f63718f..4797ed6 100644 --- a/ansible/roles/ironic-enrolment/tasks/node.yml +++ b/ansible/roles/ironic-enrolment/tasks/node.yml @@ -67,18 +67,15 @@ '{{ ironic_virtualenv_path }}/bin/openstack' baremetal node set '{{ created_node.uuid }}' --resource-class {{ node.ironic_config.resource_class }} - --boot-interface - {{ node.ironic_config.boot_interface | default( - default_interfaces[node.ironic_driver].boot_interface) }} - --deploy-interface - {{ node.ironic_config.deploy_interface | default( - default_interfaces[node.ironic_driver].deploy_interface) }} - --management-interface - {{ node.ironic_config.management_interface | default( - default_interfaces[node.ironic_driver].management_interface) }} - --power-interface - {{ node.ironic_config.power_interface | default( - default_interfaces[node.ironic_driver].power_interface) }} + {% for iface in ironic_interfaces %} + {% if (iface + '_interface') in node.ironic_config %} + --{{ iface }}-interface {{ node.ironic_config[iface + '_interface'] }} + {% endif %} + {% endfor %} + {% for key, val in ( + node.ironic_config.properties | default({})).iteritems() %} + --property '{{ key }}={{ val }}' + {% endfor %} - name: Add Ironic node traits command: >-