summaryrefslogtreecommitdiff
path: root/roles/cloud/install/tasks/hetzner_installimage.yml
blob: c8bca1c05b476b7ee1a554c08362930aee5dea7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
- name: determine latest image name
  check_mode: no
  args:
    executable: /bin/bash
  shell: |
    set -o pipefail
    shopt -s nocaseglob
    ls /root/images/{{ install_distro }}-*-{{ install_codename }}-{{ install.arch | default('amd64') }}-base.tar.gz | sort -r | head -n 1
  changed_when: false
  register: latest_image

- name: generate installimage config
  template:
    src: hetzner_installimage.conf.j2
    dest: /root/installimage.conf

- name: generate postinst script
  template:
    src: hetzner_postinst.sh.j2
    dest: /root/postinst.sh
    mode: 0755

- name: run installimage
  args:
    chdir: /root
  command: /root/.oldroot/nfs/install/installimage -a -c installimage.conf -x postinst.sh
  register: hetzner_installimage_cmd

- name: print installimage output
  debug:
    msg: "{{ hetzner_installimage_cmd.stdout_lines + hetzner_installimage_cmd.stderr_lines }}"

- name: check if installimage succeeded
  when: "hetzner_installimage_cmd.rc != 0 or 'postinst.sh finished successfully' not in hetzner_installimage_cmd.stdout_lines"
  fail:
    msg: failed to run installimage