-- block:
- - name: Make a temporary directory
- command: mktemp -d
- register: tmpdir
+- name: Copy initramfs into position
+ copy:
+ remote_src: yes
+ src: "{{ debian_installer_path | mandatory }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/initrd.gz"
+ dest: "{{ preseed_tmpdir }}/initrd.preseed.gz"
- - set_fact:
- tmpdir: "{{ tmpdir.stdout }}"
- initramfs: "{{ preseed_path | mandatory }}/{{ hostname }}-{{ install_distro }}-{{ install_codename }}.initrd.gz"
+- name: Generate preseed file
+ template:
+ src: "preseed_{{ install_distro }}-{{ install_codename }}.cfg.j2"
+ dest: "{{ preseed_tmpdir }}/preseed.cfg"
- - name: Copy initramfs into position
- copy:
- remote_src: yes
- src: "{{ debian_installer_path | mandatory }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/initrd.gz"
- dest: "{{ initramfs }}"
+- name: Generate authorized_keys file
+ authorized_key:
+ user: root
+ manage_dir: no
+ path: "{{ preseed_tmpdir }}/authorized_keys"
+ key: "{{ ssh_keys | join('\n') }}"
- - name: Generate preseed file
- template:
- src: "preseed_{{ install_distro }}-{{ install_codename }}.cfg.j2"
- dest: "{{ tmpdir }}/preseed.cfg"
-
- - name: Generate authorized_keys file
- authorized_key:
- user: root
- manage_dir: no
- path: "{{ tmpdir }}/authorized_keys"
- key: "{{ ssh_keys | join('\n') }}"
-
- - name: Inject files into initramfs
- shell: cpio -H newc -o | gzip -9 >> '{{ initramfs }}'
- args:
- chdir: "{{ tmpdir }}"
- stdin: |
- preseed.cfg
- authorized_keys
-
- always:
- - name: Delete temporary directory
- file:
- path: "{{ tmpdir }}"
- state: absent
+- name: Inject files into initramfs
+ shell: cpio -H newc -o | gzip -9 >> 'initrd.preseed.gz'
+ args:
+ chdir: "{{ preseed_tmpdir }}"
+ stdin: |
+ preseed.cfg
+ authorized_keys
- distro: "{{ install_distro }}"
codename: "{{ install_codename }}"
arch: [ "{{ install.arch | default('amd64') }}" ]
-
- - role: preseed
--- /dev/null
+---
+- block:
+ - name: Create temporary workdir
+ command: mktemp -d
+ register: tmpdir
+
+ - import_role:
+ name: preseed
+ vars:
+ preseed_tmpdir: "{{ tmpdir.stdout }}"
+
+ - name: Copy the preseed initramfs to the artifacts directory
+ copy:
+ src: "{{ tmpdir.stdout }}/initrd.preseed.gz"
+ dest: "{{ artifacts_dir }}/"
+
+
+ always:
+ - name: Cleanup temporary workdir
+ file:
+ path: "{{ tmpdir.stdout }}"
+ state: absent
- distro: "{{ install_distro }}"
codename: "{{ install_codename }}"
arch: [ "{{ hostvars[hostname].install_cooked.arch | default('amd64') }}" ]
- - role: preseed
- ssh_keys: "{{ hostvars[hostname].ssh_keys }}"
- install_interface: enp1s1
when: hostname in vmhost_info
-- name: define new installer vm
- virt:
- name: "{{ hostname }}"
- command: define
- xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
- vars:
- run_installer: yes
+- block:
+ - name: create a temporary workdir
+ command: mktemp -d
+ register: tmpdir
-- name: start vm
- virt:
- name: "{{ hostname }}"
- state: running
+ - import_role:
+ name: preseed
+ vars:
+ ssh_keys: "{{ hostvars[hostname].ssh_keys }}"
+ install_interface: enp1s1
+ preseed_tmpdir: "{{ tmpdir.stdout }}"
-- name: wait for installer to start
- wait_for_virt:
- name: "{{ hostname }}"
- states: running
- timeout: 10
+ - name: Make preseed workdir readable by qemu
+ acl:
+ path: "{{ tmpdir.stdout }}"
+ state: present
+ entity: libvirt-qemu
+ etype: user
+ permissions: rx
-- debug:
- msg: "you can check on the status of the installer running this command 'virsh console {{ hostname }}' on host {{ inventory_hostname }}."
+ - name: define new installer vm
+ virt:
+ name: "{{ hostname }}"
+ command: define
+ xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
+ vars:
+ run_installer: yes
+ preseed_tmpdir: "{{ tmpdir.stdout }}"
-- name: wait for installer to finish or crash
- wait_for_virt:
- name: "{{ hostname }}"
- states: shutdown,crashed
- timeout: 1800
- register: installer_result
- failed_when: installer_result.failed or installer_result.state == "crashed"
+ - name: start vm
+ virt:
+ name: "{{ hostname }}"
+ state: running
-- name: undefining installer vm
- virt:
- name: "{{ hostname }}"
- command: undefine
+ - name: wait for installer to start
+ wait_for_virt:
+ name: "{{ hostname }}"
+ states: running
+ timeout: 10
+
+ - debug:
+ msg: "you can check on the status of the installer running this command 'virsh console {{ hostname }}' on host {{ inventory_hostname }}."
+
+ - name: wait for installer to finish or crash
+ wait_for_virt:
+ name: "{{ hostname }}"
+ states: shutdown,crashed
+ timeout: 900
+ register: installer_result
+ failed_when: installer_result.failed or installer_result.state == "crashed"
+
+ - name: undefining installer vm
+ virt:
+ name: "{{ hostname }}"
+ command: undefine
+
+ always:
+ - name: cleanup temporary workdir
+ file:
+ path: "{{ tmpdir.stdout }}"
+ state: absent
- name: define new production vm
virt:
<type arch='x86_64' machine='pc-0.12'>hvm</type>
{% if run_installer %}
<kernel>{{ debian_installer_path }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/linux</kernel>
- <initrd>{{ preseed_path }}/{{ hostname }}-{{ install_distro }}-{{ install_codename }}.initrd.gz</initrd>
+ <initrd>{{ preseed_tmpdir }}/initrd.preseed.gz</initrd>
<cmdline>console=ttyS0,115200n8</cmdline>
{% endif %}
<boot dev='hd'/>
default: ""
private: no
- vars:
- preseed_path: "{{ global_artifacts_dir }}/{{ hostname }}"
- debian_installer_path: "{{ global_cache_dir }}/debian-installer"
-
pre_tasks:
- set_fact:
install_cooked: "{{ install }}"
network_cooked: "{{ network }}"
+ artifacts_dir: "{{ global_artifacts_dir }}/{{ hostname }}"
- file:
state: directory
name: "{{ item }}"
with_items:
- - "{{ preseed_path }}"
+ - "{{ artifacts_dir }}"
- "{{ debian_installer_path }}"
roles:
src: "{{ item.value }}"
dest: "{{ usbdrive_path }}/{{ item.key }}"
with_dict:
- initrd.gz: "{{ global_artifacts_dir }}/{{ hostname }}/{{ hostname }}-{{ install_distro }}-{{ install_codename }}.initrd.gz"
+ initrd.gz: "{{ artifacts_dir }}/initrd.preseed.gz"
linux: "{{ global_cache_dir }}/debian-installer/{{ install_distro }}-{{ install_codename }}/{{ install.arch | default('amd64') }}/linux"
- name: Generate syslinux configuration