summaryrefslogtreecommitdiff
path: root/roles/installer/openbsd
diff options
context:
space:
mode:
Diffstat (limited to 'roles/installer/openbsd')
-rw-r--r--roles/installer/openbsd/autoinstall/defaults/main.yml19
-rw-r--r--roles/installer/openbsd/autoinstall/tasks/main.yml63
-rw-r--r--roles/installer/openbsd/autoinstall/templates/auto_install.conf.j232
-rw-r--r--roles/installer/openbsd/autoinstall/templates/boot.conf.j25
-rw-r--r--roles/installer/openbsd/autoinstall/templates/install.site.j226
-rw-r--r--roles/installer/openbsd/base/defaults/main.yml (renamed from roles/installer/openbsd/defaults/main.yml)2
-rw-r--r--roles/installer/openbsd/base/tasks/main.yml (renamed from roles/installer/openbsd/tasks/main.yml)7
7 files changed, 153 insertions, 1 deletions
diff --git a/roles/installer/openbsd/autoinstall/defaults/main.yml b/roles/installer/openbsd/autoinstall/defaults/main.yml
new file mode 100644
index 00000000..cdea194e
--- /dev/null
+++ b/roles/installer/openbsd/autoinstall/defaults/main.yml
@@ -0,0 +1,19 @@
+---
+# obsd_autoinstall_tmpdir:
+
+obsd_autoinstall_arch: "{{ hostvars[hostname].install_cooked.arch | default('amd64') }}"
+obsd_autoinstall_version: "{{ install_codename }}"
+obsd_autoinstall_version_short: "{{ obsd_autoinstall_version | replace('.', '') }}"
+
+# obsd_autoinstall_serial_device: com0
+# obsd_autoinstall_serial_baudrate: 115200
+
+obsd_autoinstall_file_sets:
+ - base
+ - man
+ #- comp
+ #- game
+ #- xbase
+ #- xfont
+ #- xserv
+ #- xshare
diff --git a/roles/installer/openbsd/autoinstall/tasks/main.yml b/roles/installer/openbsd/autoinstall/tasks/main.yml
new file mode 100644
index 00000000..cb9975de
--- /dev/null
+++ b/roles/installer/openbsd/autoinstall/tasks/main.yml
@@ -0,0 +1,63 @@
+---
+- name: create temporary directories
+ loop:
+ - files/etc
+ - files/sets
+ - site/
+ file:
+ path: "{{ obsd_autoinstall_tmpdir }}/{{ item }}"
+ state: directory
+
+- name: extract installer files from iso
+ iso_extract:
+ image: "{{ installer_path }}/openbsd-{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/install.iso"
+ dest: "{{ obsd_autoinstall_tmpdir }}/files"
+ files:
+ - "{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/cdbr"
+ - "{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/cdboot"
+ - "{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/bsd.rd"
+
+- name: generate bootloader and installer configuration
+ loop:
+ - auto_install.conf
+ - boot.conf
+ template:
+ src: "{{ item }}.j2"
+ dest: "{{ obsd_autoinstall_tmpdir }}/files/etc/{{ item }}"
+
+- name: generate random seed
+ shell: "head -c512 < /dev/random > {{ obsd_autoinstall_tmpdir }}/files/etc/random.seed"
+
+- name: extract file-sets from iso
+ vars:
+ set_names:
+ - bsd
+ - bsd.rd
+ - "INSTALL.{{ obsd_autoinstall_arch }}"
+ - "{{ obsd_autoinstall_file_sets | product([obsd_autoinstall_version_short+'.tgz']) | map('join') | list }}"
+ iso_extract:
+ image: "{{ installer_path }}/openbsd-{{ obsd_autoinstall_version }}/{{ obsd_autoinstall_arch }}/install.iso"
+ dest: "{{ obsd_autoinstall_tmpdir }}/files/sets"
+ files: "{{ [obsd_autoinstall_version+'/'+obsd_autoinstall_arch+'/'] | product(set_names | flatten) | map('join') | list }}"
+
+- name: generate install.site script
+ template:
+ src: install.site.j2
+ dest: "{{ obsd_autoinstall_tmpdir }}/site/install.site"
+ mode: 0755
+
+- name: generate site tarball
+ archive:
+ path: "{{ obsd_autoinstall_tmpdir }}/site/"
+ dest: "{{ obsd_autoinstall_tmpdir }}/files/sets/site{{ obsd_autoinstall_version_short }}.tgz"
+
+- name: generate host specific installer image
+ command: 'genisoimage -RTLldDN -o "install.iso" -no-emul-boot -b "cdbr" -c "boot.catalog" files/'
+ args:
+ chdir: "{{ obsd_autoinstall_tmpdir }}/"
+
+- name: set additional installer info
+ set_fact:
+ installer_manual_steps_msg: |
+ * at the installer prompt select: (S)hell
+ * # mount_cd9660 /dev/cd0c /mnt && cp /mnt/etc/auto_install.conf / && autoinstall
diff --git a/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2 b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2
new file mode 100644
index 00000000..18e85a80
--- /dev/null
+++ b/roles/installer/openbsd/autoinstall/templates/auto_install.conf.j2
@@ -0,0 +1,32 @@
+System hostname = {{ hostvars[hostname].host_name }}
+
+Which network interface do you wish to configure = {{ install_interface | default(hostvars[hostname].network_cooked.primary.interface) }}
+{% if 'install_dhcp' in hostvars[hostname] and hostvars[hostname].install_dhcp %}
+IPv4 address = dhcp
+{% else %}
+IPv4 address = {{ hostvars[hostname].network_cooked.primary.ip }}
+Netmask = {{ hostvars[hostname].network_cooked.primary.mask }}
+Default IPv4 route = {{ hostvars[hostname].network_cooked.primary.gateway }}
+{% endif %}
+DNS domain name = {{ hostvars[hostname].network_cooked.domain }}
+DNS nameservers = {{ hostvars[hostname].network_cooked.nameservers | join(' ') }}
+
+{% if obsd_autoinstall_serial_device is defined %}
+Change the default console to {{ obsd_autoinstall_serial_device }} = yes
+Which speed should {{ obsd_autoinstall_serial_device }} use = {{ obsd_autoinstall_tty_serial | default(115200) }}
+{% endif %}
+
+{# we will install only one key for now, install.site will install the rest #}
+Public ssh key for root account = {{ ssh_keys_root[0] }}
+Password for root = this-very-very-secure-password-will-be-overwritten-by-install.site
+Setup a user = no
+Start sshd(8) by default = yes
+Allow root ssh login = prohibit-password
+
+What timezone are you in = Europe/Vienna
+
+Location of sets = cd0
+Pathname to the sets = sets/
+Set name(s) = all
+{# iso-images don't contain the SHA256.sig file but are verified when downloading the iso-file #}
+Directory does not contain SHA256.sig. Continue without verification = yes
diff --git a/roles/installer/openbsd/autoinstall/templates/boot.conf.j2 b/roles/installer/openbsd/autoinstall/templates/boot.conf.j2
new file mode 100644
index 00000000..d6cdcfeb
--- /dev/null
+++ b/roles/installer/openbsd/autoinstall/templates/boot.conf.j2
@@ -0,0 +1,5 @@
+{% if obsd_autoinstall_serial_device is defined %}
+stty {{ obsd_autoinstall_serial_device }} {{ obsd_autoinstall_tty_serial | default(115200) }}
+set tty {{ obsd_autoinstall_serial_device }}
+{% endif %}
+set image /bsd.rd
diff --git a/roles/installer/openbsd/autoinstall/templates/install.site.j2 b/roles/installer/openbsd/autoinstall/templates/install.site.j2
new file mode 100644
index 00000000..82928daa
--- /dev/null
+++ b/roles/installer/openbsd/autoinstall/templates/install.site.j2
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+echo "Generating random root pasword"
+usermod -p "$(openssl rand -base64 24 | encrypt)" root
+
+echo "Installing SSH keys for root"
+cat <<EOF > /root/.ssh/authorized_keys
+{{ ssh_keys_root | join('\n') }}
+EOF
+
+{% if hostvars[hostname].ansible_port is defined %}
+echo "Setting SSH port to {{ hostvars[hostname].ansible_port }}"
+sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /etc/ssh/sshd_config
+{% endif %}
+
+echo "Installing python"
+pkg_add -Im python%3.7
+
+echo "Disable sndiod service on first boot"
+cat <<EOF >> /etc/rc.firsttime
+
+rcctl disable sndiod
+rcctl stop sndiod
+EOF
+
+rm /install.site
diff --git a/roles/installer/openbsd/defaults/main.yml b/roles/installer/openbsd/base/defaults/main.yml
index 004b8ecc..6650e064 100644
--- a/roles/installer/openbsd/defaults/main.yml
+++ b/roles/installer/openbsd/base/defaults/main.yml
@@ -5,4 +5,4 @@ openbsd_versions:
- i386
openbsd_installer_force_download: no
-openbsd_installer_url: "https://cdn.openbsd.org/pub/OpenBSD/"
+openbsd_installer_url: "https://ftp2.eu.openbsd.org/pub/OpenBSD/"
diff --git a/roles/installer/openbsd/tasks/main.yml b/roles/installer/openbsd/base/tasks/main.yml
index e7196258..0d5053d5 100644
--- a/roles/installer/openbsd/tasks/main.yml
+++ b/roles/installer/openbsd/base/tasks/main.yml
@@ -15,3 +15,10 @@
dest: "{{ installer_path }}/openbsd-{{ item.0.version }}/{{ item.1 }}/install.iso"
mode: 0644
force: "{{ openbsd_installer_force_download }}"
+
+# TODO: verify the image using openbsd-signify
+
+- name: install genisoimage
+ apt:
+ name: genisoimage
+ state: present