---
-- name: restart inetd
- service:
- name: openbsd-inetd
- state: restarted
-
- name: restart haveged
service:
name: haveged
- name: install dependencies
apt:
name:
- - atftpd
- - openbsd-inetd
- qemu-kvm
- libvirt-bin
- python-libvirt
path: /etc/default/haveged
notify: restart haveged
-- name: configure tftpd via inetd
- lineinfile:
- regexp: "^#?({{ vm_host.network.ip }}:)?tftp"
- line: "{{ vm_host.network.ip }}:tftp dgram udp4 wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd --tftpd-timeout 300 --retry-timeout 5 --maxthread 10 --verbose=5 {{ vm_host.installer.preseed_path }}"
- path: /etc/inetd.conf
- notify: restart inetd
-
- name: make sure installer directories exists
with_items:
- "{{ vm_host.installer.path }}"
---
-- name: generate preseed file
- template:
- src: "preseed_{{ vmdistro }}-{{ vmdistcodename }}.cfg.j2"
- dest: "{{ vm_host.installer.preseed_path }}/vm-{{ vmname }}-{{ vmdistro }}-{{ vmdistcodename }}.cfg"
+- block:
+ - name: Make a temporary directory
+ command: mktemp -d
+ register: tmpdir
+
+ - set_fact:
+ tmpdir: "{{ tmpdir.stdout }}"
+ initramfs: "{{ vm_host.installer.preseed_path }}/vm-{{ vmname }}-{{ vmdistro }}-{{ vmdistcodename }}.initrd.gz"
+
+ - name: Copy initramfs into position
+ copy:
+ remote_src: yes
+ src: "{{ vm_host.installer.path }}/{{ vmdistro }}-{{ vmdistcodename }}/{{ hostvars[vmname].vm_install_cooked.arch | default('amd64') }}/initrd.gz"
+ dest: "{{ initramfs }}"
+
+ - name: generate preseed file
+ template:
+ src: "preseed_{{ vmdistro }}-{{ vmdistcodename }}.cfg.j2"
+ dest: "{{ tmpdir }}/preseed.cfg"
+
+ - name: Inject files into initramfs
+ shell: cpio -H newc -o | gzip -9 >> {{ initramfs }}
+ args:
+ chdir: "{{ tmpdir }}"
+ stdin: |
+ preseed.cfg
+
+ always:
+ - name: Delete temporary directory
+ file:
+ path: "{{ tmpdir }}"
+ state: absent
- name: create disks for vm
with_dict: "{{ hostvars[vmname].vm_install_cooked.disks.virtio | default({}) | combine(hostvars[vmname].vm_install_cooked.disks.scsi | default({})) }}"
<type arch='x86_64' machine='pc-0.12'>hvm</type>
{% if run_installer %}
<kernel>{{ vm_host.installer.path }}/{{ vmdistro }}-{{ vmdistcodename }}/{{ hostvars[vmname].vm_install_cooked.arch | default('amd64') }}/linux</kernel>
- <initrd>{{ vm_host.installer.path }}/{{ vmdistro }}-{{ vmdistcodename }}/{{ hostvars[vmname].vm_install_cooked.arch | default('amd64') }}/initrd.gz</initrd>
- <cmdline>console=ttyS0,115200n8 auto=true interface=auto url=tftp://{{ hostvars[inventory_hostname]['ansible_' + (vm_host.installer.net_if | replace('-', '_'))].ipv4.address }}/vm-{{ vmname }}-{{ vmdistro }}-{{ vmdistcodename }}.cfg netcfg/choose_interface=enp1s1 netcfg/disable_autoconfig=true netcfg/get_ipaddress={{ hostvars[vmname].vm_network_cooked.primary.ip }} netcfg/get_netmask={{ hostvars[vmname].vm_network_cooked.primary.mask }} netcfg/get_gateway={{ hostvars[vmname].vm_network_cooked.primary.gateway }} netcfg/get_nameservers="{{ hostvars[vmname].vm_network_cooked.nameservers | join(' ') }}" netcfg/confirm_static=true netcfg/get_hostname={{ vmname }} netcfg/get_domain={{ hostvars[vmname].vm_network_cooked.domain }}</cmdline>
+ <initrd>{{ vm_host.installer.preseed_path }}/vm-{{ vmname }}-{{ vmdistro }}-{{ vmdistcodename }}.initrd.gz</initrd>
+ <cmdline>console=ttyS0,115200n8</cmdline>
{% endif %}
<boot dev='hd'/>
</os>
d-i debian-installer/locale string en_US.UTF-8
d-i keyboard-configuration/xkb-keymap select us
-
-#d-i netcfg/choose_interface select enp1s1
-#d-i netcfg/disable_autoconfig boolean false
-#d-i netcfg/get_ipaddress string {{ hostvars[vmname].vm_network_cooked.primary.ip }}
-#d-i netcfg/get_netmask string {{ hostvars[vmname].vm_network_cooked.primary.mask }}
-#d-i netcfg/get_gateway string {{ hostvars[vmname].vm_network_cooked.primary.gateway }}
-#d-i netcfg/get_nameservers string {{ hostvars[vmname].vm_network_cooked.nameservers | join(' ') }}
-#d-i netcfg/confirm_static boolean true
+d-i netcfg/disable_dhcp boolean true
+d-i netcfg/choose_interface select enp1s1
+d-i netcfg/disable_autoconfig boolean false
+d-i netcfg/get_ipaddress string {{ hostvars[vmname].vm_network_cooked.primary.ip }}
+d-i netcfg/get_netmask string {{ hostvars[vmname].vm_network_cooked.primary.mask }}
+d-i netcfg/get_gateway string {{ hostvars[vmname].vm_network_cooked.primary.gateway }}
+d-i netcfg/get_nameservers string {{ hostvars[vmname].vm_network_cooked.nameservers | join(' ') }}
+d-i netcfg/confirm_static boolean true
d-i netcfg/get_hostname string {{ vmname }}
d-i netcfg/get_domain string {{ hostvars[vmname].vm_network_cooked.domain }}