--- # https://documenter.getpostman.com/view/14802249/TzkyNLMQ#intro ## TODO: allow other installer variants - name: generate host specific installer iso delegate_to: localhost vars: installer_base_path: "{{ global_cache_dir }}/debian-installer" installer_keyrings_path: "{{ global_files_dir }}/common/keyrings" import_role: name: installer/debian/iso - name: upload installer iso to publishing host delegate_to: "{{ install.cloud.image_publish.host }}" copy: src: "{{ iso_install_target_dir }}/{{ install_hostname }}.iso" dest: "{{ install.cloud.image_publish.path }}" - name: generate auth sessions from API delegate_to: localhost check_mode: no uri: url: "https://session.edis.at/kvm/v2/get/auth" method: POST body_format: form-urlencoded body: email: "{{ install.cloud.credentials.email }}" pw: "{{ install.cloud.credentials.password }}" status_code: 200 register: edis_kvm_auth_session_response - name: make sure server-id is in results assert: that: install.cloud.id in edis_kvm_auth_session_response.json.data - name: retrieve auth session for server-id set_fact: edis_kvm_auth_session: "{{ edis_kvm_auth_session_response.json.data[install.cloud.id] }}" - 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" headers: Cache-Control: "no-cache" 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=8') }}" ## 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