-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Hi,
In step 5 a few commands are mentioned to take snapshots, but the initial configuration was not mentioned before so that we can create those VMs.
Here is a draft I put together for ansible:
- name: Copy preseed file
ansible.builtin.copy:
src: "files/preseed.cfg"
dest: "/root/preseed.cfg"
- name: Create debian-1 VM
ansible.builtin.shell: >
virt-install
--name debian-1
--memory 1024
--install debian13
--graphics none
--console pty,target_type=serial
--noautoconsole
--initrd-inject /root/preseed.cfg
--extra-args="console=ttyS0,115200n8 preseed/file=/preseed.cfg"
- name: Create debian-2 VM
ansible.builtin.shell: >
virt-install
--name debian-2
--memory 1024
--install debian13
--graphics none
--console pty,target_type=serial
--noautoconsole
--initrd-inject /root/preseed.cfg
--extra-args="console=ttyS0,115200n8 preseed/file=/preseed.cfg"
- name: Sleep until VM installation is done
pause:
minutes: 10
- name: Start VMs
ansible.builtin.shell: |
virsh start debian-1
virsh start debian-2
- name: Wait for VMs to be reachable
pause:
minutes: 3
- name: Check VMs dhcp leases
ansible.builtin.shell: |
virsh net-dhcp-leases default
register: dhcp_leases
changed_when: False
- name: Show VMs dhcp leases
debug:
msg: "{{ dhcp_leases.stdout_lines }}"
- name: Shutdown VMs
ansible.builtin.shell: |
virsh shutdown debian-1
virsh shutdown debian-2
- name: Wait for VMs to shutdown
pause:
minutes: 1
- name: Take snapshots of VMs
ansible.builtin.shell: |
virsh snapshot-create-as debian-1 snapshot1 --description "Initial snapshot"
virsh snapshot-create-as debian-2 snapshot1 --description "Initial snapshot"
- name: List snapshots of VMs
ansible.builtin.shell: |
virsh snapshot-list debian-1
virsh snapshot-list debian-2
register: snapshot_list
- name: Show snapshots of VMs
debug:
msg: "{{ snapshot_list.stdout_lines }}"
- name: Start VMs
ansible.builtin.shell: |
virsh start debian-1
virsh start debian-2
- name: List VMs
ansible.builtin.shell: virsh list
register: vms_list
- name: Show VMs list
debug:
msg: "{{ vms_list.stdout_lines }}"and the preseed config:
d-i debian-installer/language string en
d-i debian-installer/country string US
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string debian
d-i netcfg/get_domain string
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
# root/toor and user/password
d-i passwd/root-password-crypted password $6$I8U7yNFep4gy/oTc$9jqHSPtccHF7jsE4k1astCfy2Ua/UX5fFHXU1mKWaXsU6shipTBmdV5pxa2vcw2xpFkm7BdzZT1E9BBbLG0jY/
d-i passwd/root-password-again-crypted password $6$I8U7yNFep4gy/oTc$9jqHSPtccHF7jsE4k1astCfy2Ua/UX5fFHXU1mKWaXsU6shipTBmdV5pxa2vcw2xpFkm7BdzZT1E9BBbLG0jY/
d-i passwd/root-login boolean true
d-i passwd/user-fullname string user
d-i passwd/username string user
d-i passwd/user-password-crypted password $6$/LokH9GXZC9ZA/vC$bQskFFFDEZa2JeSOEO7ZFRih.9Psq5so9QKSkyTcU8UDxcxe5ohgh.FaMyashhT44Q/bmZ3/HWXebS72L.ARu1
d-i passwd/user-password-again-crypted password $6$/LokH9GXZC9ZA/vC$bQskFFFDEZa2JeSOEO7ZFRih.9Psq5so9QKSkyTcU8UDxcxe5ohgh.FaMyashhT44Q/bmZ3/HWXebS72L.ARu1
d-i clock-setup/utc boolean true
d-i time/zone string UTC
d-i partman-auto/disk string /dev/vda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman/choose_partition select finish
d-i partman/confirm write_new_label boolean true
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_nochanges boolean true
tasksel tasksel/first multiselect standard, ssh-server
popularity-contest popularity-contest/participate boolean false
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
d-i grub-installer/bootdev string /dev/vda
d-i finish-install/reboot_in_progress note
Let me know if that helps and could be added to the ansible playbook!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels