summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-12-08 18:47:11 +0100
committerChristian Pointner <equinox@spreadspace.org>2022-12-08 18:47:11 +0100
commitae698f99be1dbc34ce79c330757680f0317fe11a (patch)
treeed882de1eb25e614ba5ced90f26a2c6f42690fb5
parentmonitoring: add simple landingpage (diff)
cloud/install: basic support for edis-kvm
-rw-r--r--roles/cloud/install/tasks/edis-kvm.yml141
1 files changed, 130 insertions, 11 deletions
diff --git a/roles/cloud/install/tasks/edis-kvm.yml b/roles/cloud/install/tasks/edis-kvm.yml
index d51a9305..60838b1f 100644
--- a/roles/cloud/install/tasks/edis-kvm.yml
+++ b/roles/cloud/install/tasks/edis-kvm.yml
@@ -37,14 +37,133 @@
set_fact:
edis_kvm_auth_session: "{{ edis_kvm_auth_session_response.json.data[install.cloud.id] }}"
-- debug:
- var: edis_kvm_auth_session
-
-## TODO: actually implement this
-## - @API: download custom iso
-## - @API: power off
-## - @API: mount custom iso
-## - @API: power on
-## - wait for installer to finish (@API get powerstate?)
-## - @API: umount custom iso
-## - @API: power on
+- name: make sure no iso image is mounted
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/umount"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ status_code: 200
+
+- name: download the custom installer image to API host
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/download_iso"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ url: "{{ install.cloud.image_publish.base_url }}/{{ install_hostname }}.iso"
+ status_code: 500 ## TODO: create ticket @ edis support ....
+
+- name: fetch list of isos
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/get/isos"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ status_code: 200
+ register: edis_kvm_installer_isos
+
+- name: extract full path of custom iso
+ set_fact:
+ edis_kvm_custom_iso_fullpath: "{{ edis_kvm_installer_isos.json.data | select('match', '.*/' + install.cloud.id + '.iso') | first }}"
+
+- name: mount custom iso
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/mount"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ iso: "{{ edis_kvm_custom_iso_fullpath }}"
+ status_code: 200
+
+- name: make sure VNC access is disabled
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/vnc/disable"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ status_code: 200
+
+- name: wait for VNC disable to kick in
+ pause:
+ seconds: 5
+
+- name: generate random password for VNC access
+ set_fact:
+ edis_kvm_vnc_password: "{{ lookup('password', '/dev/null chars=ascii_lowercase,ascii_uppercase,digits length=16') }}"
+
+ ## TODO: sadly setting the password does not work -> create ticket @ edis support ....
+- name: (re)enable VNC access with new temporary password
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/vnc/enable"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ vnc_pw: "{{ edis_kvm_vnc_password }}"
+ status_code: 200
+ register: edis_kvm_vnc_info
+
+- name: user interaction needed...
+ pause:
+ prompt: |
+ Please connect to the VNC using the following link:
+
+ https://manage.edis.at/novnc/?host={{ edis_kvm_vnc_info.json.vnc_host }}&port={{ edis_kvm_vnc_info.json.novnc_port }}&scale=true
+
+ Alternativly you may connect to the VNC server at {{ edis_kvm_vnc_info.json.vnc_host }} on port {{ edis_kvm_vnc_info.json.vnc_port }} using any VNC compatible client.
+
+ The VNC session is protected using this password: "{{ edis_kvm_vnc_password }}"
+
+ While VNC is connected reboot the server (i.e. using CTRL+ALT+DEL) and then press F12 or ESC during the BIOS phase of
+ the boot. At the boot device selection menu select the DVD/CD drive entry that contains the string '(ISOIMAGE)' to
+ boot the installer.
+
+ Once the installation is done press ENTER to continue or CTRL-C then A to abort.
+
+- name: unount the installer iso image
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/umount"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ status_code: 200
+
+- name: disable VNC access
+ delegate_to: localhost
+ uri:
+ url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/vnc/disable"
+ method: POST
+ body_format: form-urlencoded
+ body:
+ kvm_id: "{{ edis_kvm_auth_session.kvm_id }}"
+ signature: "{{ edis_kvm_auth_session.signature }}"
+ valid_until: "{{ edis_kvm_auth_session.valid_until }}"
+ status_code: 200