From c84eb30443915cde29d5805bc2d1437461b7a187 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 25 Oct 2022 02:55:23 +1300 Subject: [PATCH] sysprep problems --- ansible/roles/vm_template/tasks/main.yml | 32 ++++++++++++++++----- notes/arch_install_notes.txt | 36 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 notes/arch_install_notes.txt diff --git a/ansible/roles/vm_template/tasks/main.yml b/ansible/roles/vm_template/tasks/main.yml index d173b94..73362c7 100644 --- a/ansible/roles/vm_template/tasks/main.yml +++ b/ansible/roles/vm_template/tasks/main.yml @@ -1,11 +1,29 @@ --- -- name: sysprep the template vhd - # when: template_created is changed +- name: create the qcow mount point + ansible.builtin.file: + state: directory + path: "{{ qcow_mountpoint }}" + +- name: mount the guest qcow template image ansible.builtin.shell: cmd: | - virt-sysprep -a {{ root_vhd_pool_dir }}/{{ vhd_template }} \ - --format qcow2 \ - --delete /etc/systemd/network/* \ - --keep-user-accounts ladmin \ - --enable user-account,firewall-rules \ + guestmount --format=qcow2 \ + -a {{ root_vhd_pool_dir }}/{{ vhd_template }} \ + -m /dev/vda2 \ + {{ qcow_mountpoint }} + +- name: sysprep the template image + ansible.builtin.file: + state: absent + path: "{{ item }}" + with_items: + - "{{ qcow_mountpoint }}/home/ladmin/.ssh/" + - "{{ qcow_mountpoint }}/root/.ssh/" + - "{{ qcow_mountpoint }}/etc/machine-id" + - "{{ qcow_mountpoint }}/etc/hostname" + +- name: unmount the guest qcow image + ansible.builtin.shell: + cmd: | + guestunmount {{ qcow_mountpoint }} diff --git a/notes/arch_install_notes.txt b/notes/arch_install_notes.txt new file mode 100644 index 0000000..559421e --- /dev/null +++ b/notes/arch_install_notes.txt @@ -0,0 +1,36 @@ +fdisk on /dev/vda + +part 1 start 2048 +512M type UEFI +part 2 remaining type 23 (Linux root x86-64) + +mkfs.vfat -F 32 /dev/vda1 +mkfs.ext4 /dev/vda2 + +update archinstall + +extra packages: + + qemu-guest-agent + nano + openssh + ufw + +chroot: + + systemctl enable sshd + systemctl enable systemd-networkd + systemctl enable systemd-resolved + +manual sysprep steps: + + remove /etc/hostname + remove /etc/machine-id + remove /etc/systemd/network/* + remove /home/ladmin/.ssh + remove /root/.ssh + remove /home/ladmin/.bash_history + remove /root/.bash_history + remove /etc/ssh/ssh_host_* + remove /tmp/* + remove /var/tmp/* +