--- # 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" debian_preseed_poweroff_when_done: yes 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: 200 - 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 and boot from 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 }}" force_reset: "yes" status_code: 200 - name: installing the system pause: minutes: 3 prompt: | Waiting for the installer to finish. You may watch the progress via the EDIS Managemet interface at https://manage.edis.at/whmcs/clientarea.php?action=services Just go to the product page of the VM {{ install.cloud.id }} and enable VNC. After that you may use the built-in noVNC instance to watch the installer doing its thing. The installer will terminate the VM when done and the install process will continue automatically. If the installation is done quicker than this you may press ENTER to continue or CTRL-C then A to abort. - name: wait for installer to shutdown the VM delegate_to: localhost uri: url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/get/power" 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 }}" register: edis_kvm_power_state until: "edis_kvm_power_state.json.data == 'server powered off'" retries: 60 delay: 5 - name: unmount 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: start the newly installed VM delegate_to: localhost uri: url: "https://{{ edis_kvm_auth_session.api_host }}/kvm/v2/set/poweron" 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