From e539dac7c994e21946fc604ef8b34dfeaee1c74b Mon Sep 17 00:00:00 2001 From: Zhangfei Gao Date: Mon, 13 Nov 2017 10:39:04 +0800 Subject: [PATCH] ironic-pxe: support pxe uefi mode Support pxe uefi mode following guide https://docs.openstack.org/ironic/latest/install/configure-pxe.html In the meantime, ironic-agent kernel and initramfs does not have to be provided as precondition under /etc/kolla/config in such mode. Add condition check as well. Change-Id: Ieefcf5f9fe839eab63f3fe4a1c5cf845f4fd4eb5 Signed-off-by: Zhangfei Gao --- ansible/group_vars/all.yml | 1 + ansible/roles/ironic/tasks/config.yml | 14 ++++++++++++++ ansible/roles/ironic/tasks/precheck.yml | 1 + ansible/roles/ironic/templates/ironic-pxe.json.j2 | 9 +++++++-- .../ironic/templates/ironic_pxe_uefi.default.j2 | 7 +++++++ etc/kolla/globals.yml | 1 + 6 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/ironic/templates/ironic_pxe_uefi.default.j2 diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 29f97bcb84..7a71556dc5 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -416,6 +416,7 @@ enable_horizon_zun: "{{ enable_zun | bool }}" enable_hyperv: "no" enable_influxdb: "no" enable_ironic: "no" +enable_ironic_pxe_uefi: "no" enable_iscsid: "{{ (enable_cinder | bool and enable_cinder_backend_iscsi | bool) or enable_ironic | bool }}" enable_karbor: "no" enable_kuryr: "no" diff --git a/ansible/roles/ironic/tasks/config.yml b/ansible/roles/ironic/tasks/config.yml index fd51d76b93..e93a9f7774 100644 --- a/ansible/roles/ironic/tasks/config.yml +++ b/ansible/roles/ironic/tasks/config.yml @@ -72,6 +72,19 @@ # Only required when Ironic inspector is in use. - groups['ironic-inspector'] | length > 0 - inventory_hostname in groups['ironic-pxe'] + - not enable_ironic_pxe_uefi + +- name: Copying ironic_pxe_uefi.cfg default + template: + src: "{{ item }}" + dest: "{{ node_config_directory }}/ironic-pxe/default" + with_first_found: + - "{{ node_custom_config }}/ironic/ironic_pxe_uefi.default" + - "{{ node_custom_config }}/ironic/{{ inventory_hostname }}/ironic_pxe_uefi.default" + - "ironic_pxe_uefi.default.j2" + when: + - inventory_hostname in groups['ironic-pxe'] + - enable_ironic_pxe_uefi | bool - name: Copying ironic-agent kernel and initramfs copy: @@ -84,6 +97,7 @@ # Only required when Ironic inspector is in use. - groups['ironic-inspector'] | length > 0 - inventory_hostname in groups['ironic-pxe'] + - not enable_ironic_pxe_uefi - name: Check if policies shall be overwritten local_action: stat path="{{ node_custom_config }}/ironic/policy.json" diff --git a/ansible/roles/ironic/tasks/precheck.yml b/ansible/roles/ironic/tasks/precheck.yml index 2ef0530544..0dc5a1a03f 100644 --- a/ansible/roles/ironic/tasks/precheck.yml +++ b/ansible/roles/ironic/tasks/precheck.yml @@ -37,6 +37,7 @@ # Only required when Ironic inspector is in use. - groups['ironic-inspector'] | length > 0 - inventory_hostname in groups['ironic-pxe'] + - not enable_ironic_pxe_uefi with_items: - "ironic-agent.kernel" - "ironic-agent.initramfs" diff --git a/ansible/roles/ironic/templates/ironic-pxe.json.j2 b/ansible/roles/ironic/templates/ironic-pxe.json.j2 index b56286fb0c..3a06abb7f0 100644 --- a/ansible/roles/ironic/templates/ironic-pxe.json.j2 +++ b/ansible/roles/ironic/templates/ironic-pxe.json.j2 @@ -1,7 +1,11 @@ +{% set pxe_dir = ('/tftpboot/grub' if kolla_base_distro in ['ubuntu', 'debian'] else '/tftpboot/EFI/centos') if enable_ironic_pxe_uefi | bool else '/tftpboot/pxelinux.cfg' %} +{% set pxe_cfg = 'grub.cfg' if enable_ironic_pxe_uefi | bool else 'default' %} + { "command": "/usr/sbin/in.tftpd --verbose --foreground --user root --address 0.0.0.0:69 --map-file /map-file /tftpboot", "config_files": [ {% if groups['ironic-inspector'] | length > 0 %} +{% if not enable_ironic_pxe_uefi %} { "source": "{{ container_config_directory }}/ironic-agent.kernel", "dest": "/tftpboot/ironic-agent.kernel", @@ -14,9 +18,10 @@ "owner": "root", "perm": "0644" }, +{% endif %} { "source": "{{ container_config_directory }}/default", - "dest": "/tftpboot/pxelinux.cfg/default", + "dest": "{{ pxe_dir }}/{{ pxe_cfg }}", "owner": "root", "perm": "0644" } @@ -24,7 +29,7 @@ ], "permissions": [ { - "path": "/tftpboot/pxelinux.cfg", + "path": "{{ pxe_dir }}", "owner": "ironic:ironic", "recurse": true } diff --git a/ansible/roles/ironic/templates/ironic_pxe_uefi.default.j2 b/ansible/roles/ironic/templates/ironic_pxe_uefi.default.j2 new file mode 100644 index 0000000000..1546765077 --- /dev/null +++ b/ansible/roles/ironic/templates/ironic_pxe_uefi.default.j2 @@ -0,0 +1,7 @@ +set default=master +set timeout=5 +set hidden_timeout_quiet=false + +menuentry "master" { + configfile /tftpboot/$net_default_ip.conf +} diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 9234f576f7..5fcd59fe05 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -185,6 +185,7 @@ kolla_internal_vip_address: "10.10.10.254" #enable_hyperv: "no" #enable_influxdb: "no" #enable_ironic: "no" +#enable_ironic_pxe_uefi: "no" #enable_karbor: "no" #enable_kuryr: "no" #enable_magnum: "no"