Compare commits
2 Commits
29906fc462
...
870e4e9476
Author | SHA1 | Date |
---|---|---|
Gleb Koval | 870e4e9476 | |
Gleb Koval | 763958634e |
|
@ -31,30 +31,21 @@
|
|||
api_token_secret: "{{ api_token_secret }}"
|
||||
name: "{{ vmname }}"
|
||||
tasks:
|
||||
# Initial setup
|
||||
- name: Create VM
|
||||
community.general.proxmox_kvm:
|
||||
clone: "{{ node }}-debian-12"
|
||||
storage: nvme
|
||||
register: create
|
||||
- name: Initial boot
|
||||
when: create.changed is true
|
||||
block:
|
||||
- name: Start
|
||||
community.general.proxmox_kvm:
|
||||
state: started
|
||||
register: start
|
||||
retries: 30
|
||||
delay: 10
|
||||
until: start.status is defined
|
||||
- name: Wait
|
||||
ansible.builtin.wait_for:
|
||||
timeout: 180
|
||||
- name: Poweroff
|
||||
community.general.proxmox_kvm:
|
||||
state: stopped
|
||||
- name: Debug
|
||||
ansible.builtin.debug:
|
||||
var: create
|
||||
- name: Wait for status
|
||||
community.general.proxmox_kvm:
|
||||
state: current
|
||||
register: vm
|
||||
retries: 30
|
||||
delay: 10
|
||||
until: vm.status is defined
|
||||
|
||||
# Networking
|
||||
- name: Add HOME NIC
|
||||
community.general.proxmox_nic:
|
||||
interface: net0
|
||||
|
@ -65,6 +56,27 @@
|
|||
interface: net1
|
||||
firewall: false
|
||||
bridge: SRV
|
||||
|
||||
# Initial boot
|
||||
# For some reason debian cloud images don't use
|
||||
# cloud-init for networking on first boot (cloud-init files
|
||||
# are regenerated AFTER networking starts). But we need the
|
||||
# hostname to be registered with DHCP later on so ¯\_(ツ)_/¯
|
||||
- name: Initial boot
|
||||
when: create.changed is true
|
||||
block:
|
||||
- name: Start
|
||||
community.general.proxmox_kvm:
|
||||
state: started
|
||||
register: start
|
||||
- name: Wait # Initial apt update, apt upgrade, cloud-init
|
||||
ansible.builtin.wait_for:
|
||||
timeout: 180
|
||||
- name: Poweroff
|
||||
community.general.proxmox_kvm:
|
||||
state: stopped
|
||||
|
||||
# VM Configuration
|
||||
- name: Resize disk
|
||||
community.general.proxmox_disk:
|
||||
disk: scsi0
|
||||
|
@ -85,16 +97,19 @@
|
|||
onboot: true
|
||||
cores: 2
|
||||
memory: 2048
|
||||
|
||||
# We have now enabled qemu guest agent, but have not installed it
|
||||
# Rebooting will timeout if started
|
||||
- name: Retart VM # doesn't start if stopped
|
||||
when:
|
||||
- create.status is defined
|
||||
- create.status == "running"
|
||||
- vm.status is defined
|
||||
- vm.status == "running"
|
||||
community.general.proxmox_kvm:
|
||||
state: restarted
|
||||
timeout: 60
|
||||
- name: Start VM # start if stopped
|
||||
when:
|
||||
- create.status is defined
|
||||
- create.status != "running"
|
||||
- vm.status is defined
|
||||
- vm.status != "running"
|
||||
community.general.proxmox_kvm:
|
||||
state: started
|
||||
|
|
|
@ -3,11 +3,16 @@
|
|||
gather_facts: false
|
||||
tasks:
|
||||
- name: Wait for connection
|
||||
ansible.builtin.wait_for:
|
||||
host: "{{ inventory_hostname }}"
|
||||
port: 22
|
||||
timeout: 300
|
||||
delegate_to: localhost
|
||||
ansible.builtin.ping:
|
||||
register: wait_conn
|
||||
retries: 30
|
||||
delay: 10
|
||||
until: wait_conn.ping is defined
|
||||
# ansible.builtin.wait_for:
|
||||
# host: "{{ inventory_hostname }}"
|
||||
# port: 22
|
||||
# timeout: 300
|
||||
# delegate_to: localhost
|
||||
- name: Test some stuff
|
||||
ansible.builtin.shell: |
|
||||
touch ~/hmm
|
||||
|
@ -15,10 +20,6 @@
|
|||
echo test2 >> ~/test
|
||||
mkdir ~/dir
|
||||
touch ~/dir/testing
|
||||
register: stuff
|
||||
retries: 10
|
||||
delay: 6
|
||||
until: stuff.rc == 0
|
||||
- name: Install some stuff
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
|
|
Loading…
Reference in New Issue