diff options
Diffstat (limited to 'roles/vmm')
-rw-r--r-- | roles/vmm/defaults/main.yml | 6 | ||||
-rw-r--r-- | roles/vmm/tasks/autoinstall_configuration.yml (renamed from roles/vmm/tasks/autoinstall-configuration.yml) | 22 | ||||
-rw-r--r-- | roles/vmm/tasks/facts.yml | 8 | ||||
-rw-r--r-- | roles/vmm/tasks/main.yml | 2 | ||||
-rw-r--r-- | roles/vmm/templates/autoinstall.conf.j2 | 10 | ||||
-rw-r--r-- | roles/vmm/templates/vm.conf.j2 | 3 |
6 files changed, 36 insertions, 15 deletions
diff --git a/roles/vmm/defaults/main.yml b/roles/vmm/defaults/main.yml index 8d26a49..13e8b92 100644 --- a/roles/vmm/defaults/main.yml +++ b/roles/vmm/defaults/main.yml @@ -9,6 +9,7 @@ vmm_default_timezone: Europe/Stockholm vmm_default_fallback_http: true vmm_default_ssh_key: a +vmm_image_openbsd_kernel_prefix: /bsd.vm vmm_network_forwarded_ips: ["", 6] @@ -22,11 +23,6 @@ vmm_iso: url: https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-virt-3.15.0-x86_64.iso checksum: sha256:e97eaedb3bff39a081d1d7e67629d5c0e8fb39677d6a9dd1eaf2752e39061e02 - - name: openbsd - version: 6.8 - url: https://cdn.openbsd.org/pub/OpenBSD/7.0/amd64/install70.img - checksum: sha256:6bc7f945c2709247d449892c33c0f1b9a31590528572c1e988fef4a7637210e6 - # vmm_vms: # - name: # image: diff --git a/roles/vmm/tasks/autoinstall-configuration.yml b/roles/vmm/tasks/autoinstall_configuration.yml index e05b11c..cd52a84 100644 --- a/roles/vmm/tasks/autoinstall-configuration.yml +++ b/roles/vmm/tasks/autoinstall_configuration.yml @@ -10,18 +10,36 @@ state: directory - name: generate autoinstall files - template: + template: &generation_steps src: autoinstall.conf.j2 dest: "/var/www/htdocs/autoinstall/{{ item.lladdr }}-install.conf" owner: www group: www mode: 0640 + when: item.image == "openbsd" + loop: "{{ vmm_vms }}" + +- name: generate autoupgrade files + template: + <<: *generation_steps + dest: "/var/www/htdocs/autoinstall/{{ item.lladdr }}-upgrade.conf" + when: item.image == "openbsd" loop: "{{ vmm_vms }}" - name: generate httpd configuration template: + <<: *generation_steps src: httpd.conf.j2 dest: "{{ httpd_configuration_dir }}/autoinstall.conf" owner: 0 group: 0 - mode: 0640 + +- name: link openbsd vm kernel to host kernel + file: + src: /bsd.sp + dest: "{{ vmm_image_openbsd_kernel_prefix }}.{{ item.name }}" + owner: 0 + group: 0 + state: hard + when: item.image == "openbsd" + loop: "{{ vmm_vms }}" diff --git a/roles/vmm/tasks/facts.yml b/roles/vmm/tasks/facts.yml index c7b453b..58a6df5 100644 --- a/roles/vmm/tasks/facts.yml +++ b/roles/vmm/tasks/facts.yml @@ -2,10 +2,10 @@ set_fact: vmm_vms_tmp: > {{ vmm_vms_tmp | default([]) + [ item | combine({ - 'lladdr': item.name - | hash('sha1') - | truncate(12, True, '') - | ansible.netcommon.hwaddr('unix') + "lladdr": item.name + | hash("sha1") + | truncate(12, True, "") + | ansible.netcommon.hwaddr("unix") }) ] }} loop: "{{ vmm_vms }}" diff --git a/roles/vmm/tasks/main.yml b/roles/vmm/tasks/main.yml index c596664..26580f2 100644 --- a/roles/vmm/tasks/main.yml +++ b/roles/vmm/tasks/main.yml @@ -14,7 +14,7 @@ include_tasks: facts.yml - name: include autoinstall generation - include_tasks: autoinstall-configuration.yml + include_tasks: autoinstall_configuration.yml tags: task_autoinstall_configuration - name: include iso management diff --git a/roles/vmm/templates/autoinstall.conf.j2 b/roles/vmm/templates/autoinstall.conf.j2 index de64c42..829c90f 100644 --- a/roles/vmm/templates/autoinstall.conf.j2 +++ b/roles/vmm/templates/autoinstall.conf.j2 @@ -1,9 +1,13 @@ +{% set guest = hostvars[item.name] %} System hostname = {{ item.name }} +Network interfaces = vio0 +IPv4 address for vio0 = {{ host.__ip.external }} +Using DNS domainname = {{ host.__domain_name }} +Using DNS nameservers = {{ __global_domain_name_servers | join (" ") }} Password for root = {{ vmm_default_password }} -Network interfaces = run0 -IPv4 address for run0 = dhcp -Public ssh key for user = {{ vmm_default_ssh_key }} +Public ssh key for root account = {{ vmm_default_ssh_key }} Which disk is the root disk = sd0 +Allow root ssh login = yes What timezone are you in = {{ vmm_default_timezone }} Unable to connect using https. Use http instead = {{ "yes" if vmm_default_fallback_http else "no" }} Location of sets = http diff --git a/roles/vmm/templates/vm.conf.j2 b/roles/vmm/templates/vm.conf.j2 index 8653616..32e4316 100644 --- a/roles/vmm/templates/vm.conf.j2 +++ b/roles/vmm/templates/vm.conf.j2 @@ -11,6 +11,9 @@ vm "{{ vm.name }}" { {% if vm.enabled is defined and not vm.enabled %} disable {% endif %} +{% if vm.image == "openbsd" %} + boot "/bsd.vm.{{ vm.name }}" +{% endif %} memory {{ vm.memory }} disk "{{ vmm_disk_dir }}/{{ vm.name }}.{{ vmm_disk_format }}" interface { |