bifrost/playbooks/roles/bifrost-ironic-install/tasks/create_esp.yml

61 lines
1.8 KiB
YAML

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: "Set grub2 and shim paths for Debian and Red Hat systems"
set_fact:
grub_efi_source: /usr/lib/ironic/grub-efi
shim_efi_source: /usr/lib/ironic/shim-efi
- name: "Create a temporary directory for mounting ESP"
tempfile:
state: directory
register: esp_temp_dir
- name: "Create an empty ESP image"
command: dd if=/dev/zero of={{ esp_image }} bs=4096 count=1024
- name: "Initialize ESP filesystem"
command: mkfs.fat -s 4 -r 512 -S 4096 {{ esp_image }}
- name: "Mount ESP filesystem"
command: mount {{ esp_image }} {{ esp_temp_dir.path }} # noqa 303
- block:
- name: "Create ESP boot directory"
file:
path: "{{ esp_temp_dir.path }}/EFI/BOOT"
state: directory
- name: "Copy the shim image to ESP"
copy:
src: "{{ shim_efi_source }}"
remote_src: true
dest: "{{ esp_temp_dir.path }}/EFI/BOOT/BOOTX64.efi"
- name: "Copy the grub2 image to ESP"
copy:
src: "{{ grub_efi_source }}"
remote_src: true
dest: "{{ esp_temp_dir.path }}/EFI/BOOT/GRUBX64.efi"
always:
- name: "Unmount ESP filesystem"
command: umount {{ esp_temp_dir.path }}
- name: "Ensure ESP image is readable"
file:
path: "{{ esp_image }}"
owner: ironic
group: ironic
mode: 0644