Initial commit of pxeboot role
- iPXE menu that can be chainloaded
- Memtest and Ubuntu 18.04 targets
- preseed created on a per-serial basis
Change-Id: I6f231ad615025c50963110945a06378936ecf26f
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
new file mode 100644
index 0000000..7c7d5ce
--- /dev/null
+++ b/tasks/Debian.yml
@@ -0,0 +1,13 @@
+---
+# pxeboot tasks/Debian.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Install unzip to decompress files
+ apt:
+ name:
+ - "unzip"
+ state: "present"
+ update_cache: true
+ cache_valid_time: 3600
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..0128696
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,39 @@
+---
+# pxeboot tasks/main.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: include OS-specific vars
+ include_vars: "{{ ansible_os_family }}.yml"
+
+- name: include OS-specific tasks
+ include_tasks: "{{ ansible_os_family }}.yml"
+
+- name: Create pxeboot dist dir
+ file:
+ state: directory
+ path: "{{ pxeboot_dist_dir }}"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: "0755"
+
+- name: Create pxeboot webroot dir (may already exist from webserver role)
+ file:
+ state: directory
+ path: "{{ pxeboot_web_root }}"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: "0755"
+
+# create boot targets
+- include_tasks: "memtest.yml"
+- include_tasks: "ubuntu1804.yml"
+
+- name: Create iPXE menu chainboot script from template
+ template:
+ src: "boot.ipxe.j2"
+ dest: "{{ pxeboot_web_root }}/boot.ipxe"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: 0644
diff --git a/tasks/memtest.yml b/tasks/memtest.yml
new file mode 100644
index 0000000..6b9dec3
--- /dev/null
+++ b/tasks/memtest.yml
@@ -0,0 +1,77 @@
+---
+# pxeboot tasks/memtest.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Create memtest dir in webroot
+ file:
+ state: directory
+ path: "{{ pxeboot_web_root }}/memtest"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: "0755"
+
+- name: Download memtest compressed ISO
+ get_url:
+ url: >
+ http://memtest.org/download/{{ pxeboot_memtest_version }}/memtest86+-{{ pxeboot_memtest_version }}.iso.gz
+ checksum: "{{ pxeboot_memtest_checksum }}"
+ dest: "{{ pxeboot_dist_dir }}/memtest86+-{{ pxeboot_memtest_version }}.iso.gz"
+ owner: "root"
+ group: "root"
+ mode: "0644"
+ register: memtest_dl
+
+# ansible unarchive module can't handle bare (not tarred) gzipped files
+# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/unarchive_module.html#notes
+- name: Decompress memtest ISO
+ command:
+ cmd: "gunzip -k {{ pxeboot_dist_dir }}/memtest86+-{{ pxeboot_memtest_version }}.iso.gz"
+ creates: "{{ pxeboot_dist_dir }}/memtest86+-{{ pxeboot_memtest_version }}.iso"
+
+- name: Copy memtest ISO to web root
+ copy:
+ remote_src: true
+ src: "{{ pxeboot_dist_dir }}/memtest86+-{{ pxeboot_memtest_version }}.iso"
+ dest: "{{ pxeboot_web_root }}/memtest/memtest.iso"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: 0644
+
+- name: Download syslinux archive (contains memdisk)
+ get_url:
+ url: >
+ https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-{{ pxeboot_syslinux_version }}.zip
+ checksum: "{{ pxeboot_syslinux_checksum }}"
+ dest: "{{ pxeboot_dist_dir }}/syslinux-{{ pxeboot_syslinux_version }}.zip"
+ owner: "root"
+ group: "root"
+ mode: "0644"
+ register: syslinux_dl
+
+- name: Create syslinux unarchive dir
+ file:
+ state: directory
+ path: "{{ pxeboot_dist_dir }}/syslinux-{{ pxeboot_syslinux_version }}"
+ owner: "root"
+ group: "{{ pxeboot_groupname }}"
+ mode: "0755"
+
+- name: Unarchive syslinux
+ unarchive:
+ remote_src: true
+ src: "{{ pxeboot_dist_dir }}/syslinux-{{ pxeboot_syslinux_version }}.zip"
+ dest: "{{ pxeboot_dist_dir }}/syslinux-{{ pxeboot_syslinux_version }}"
+ owner: "root"
+ group: "root"
+ mode: "0644"
+
+- name: Copy memdisk from syslinux
+ copy:
+ remote_src: true
+ src: "{{ pxeboot_dist_dir }}/syslinux-{{ pxeboot_syslinux_version }}/memdisk/memdisk"
+ dest: "{{ pxeboot_web_root }}/memtest/memdisk"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: 0644
diff --git a/tasks/ubuntu1804.yml b/tasks/ubuntu1804.yml
new file mode 100644
index 0000000..f7468e5
--- /dev/null
+++ b/tasks/ubuntu1804.yml
@@ -0,0 +1,32 @@
+---
+# pxeboot tasks/ubuntu1804.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Create ubuntu1804 dir in webroot
+ file:
+ state: directory
+ path: "{{ pxeboot_web_root }}/ubuntu1804"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: "0755"
+
+- name: Download ubuntu1804 files
+ get_url:
+ url: "{{ pxeboot_ubuntu1804_base_url }}/{{ pxeboot_ubuntu1804_version }}/{{ item['name'] }}"
+ dest: "{{ pxeboot_web_root }}/ubuntu1804/{{ item['name'] }}"
+ checksum: "{{ item['checksum'] }}"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: "0644"
+ with_items: "{{ pxeboot_ubuntu1804_files }}"
+
+- name: Create preseed files
+ template:
+ src: "ubuntu1804_preseed.cfg.j2"
+ dest: "{{ pxeboot_web_root }}/ubuntu1804/{{ item['serial'] }}_preseed.cfg"
+ owner: "{{ pxeboot_username }}"
+ group: "{{ pxeboot_groupname }}"
+ mode: "0644"
+ with_items: "{{ pxeboot_hosts }}"