1
0
IaC/ansible/roles/vm_template/tasks/main.yml
2022-10-25 02:55:23 +13:00

30 lines
745 B
YAML

---
- 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: |
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 }}