Compare commits
No commits in common. "870e4e94765e12be80394fcc57eee58f16b03ece" and "29906fc4621aa4250b1beabdee0a2fbed628293d" have entirely different histories.
870e4e9476
...
29906fc462
|
@ -31,21 +31,30 @@
|
||||||
api_token_secret: "{{ api_token_secret }}"
|
api_token_secret: "{{ api_token_secret }}"
|
||||||
name: "{{ vmname }}"
|
name: "{{ vmname }}"
|
||||||
tasks:
|
tasks:
|
||||||
# Initial setup
|
|
||||||
- name: Create VM
|
- name: Create VM
|
||||||
community.general.proxmox_kvm:
|
community.general.proxmox_kvm:
|
||||||
clone: "{{ node }}-debian-12"
|
clone: "{{ node }}-debian-12"
|
||||||
storage: nvme
|
storage: nvme
|
||||||
register: create
|
register: create
|
||||||
- name: Wait for status
|
- name: Initial boot
|
||||||
|
when: create.changed is true
|
||||||
|
block:
|
||||||
|
- name: Start
|
||||||
community.general.proxmox_kvm:
|
community.general.proxmox_kvm:
|
||||||
state: current
|
state: started
|
||||||
register: vm
|
register: start
|
||||||
retries: 30
|
retries: 30
|
||||||
delay: 10
|
delay: 10
|
||||||
until: vm.status is defined
|
until: start.status is defined
|
||||||
|
- name: Wait
|
||||||
# Networking
|
ansible.builtin.wait_for:
|
||||||
|
timeout: 180
|
||||||
|
- name: Poweroff
|
||||||
|
community.general.proxmox_kvm:
|
||||||
|
state: stopped
|
||||||
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: create
|
||||||
- name: Add HOME NIC
|
- name: Add HOME NIC
|
||||||
community.general.proxmox_nic:
|
community.general.proxmox_nic:
|
||||||
interface: net0
|
interface: net0
|
||||||
|
@ -56,27 +65,6 @@
|
||||||
interface: net1
|
interface: net1
|
||||||
firewall: false
|
firewall: false
|
||||||
bridge: SRV
|
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
|
- name: Resize disk
|
||||||
community.general.proxmox_disk:
|
community.general.proxmox_disk:
|
||||||
disk: scsi0
|
disk: scsi0
|
||||||
|
@ -97,19 +85,16 @@
|
||||||
onboot: true
|
onboot: true
|
||||||
cores: 2
|
cores: 2
|
||||||
memory: 2048
|
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
|
- name: Retart VM # doesn't start if stopped
|
||||||
when:
|
when:
|
||||||
- vm.status is defined
|
- create.status is defined
|
||||||
- vm.status == "running"
|
- create.status == "running"
|
||||||
community.general.proxmox_kvm:
|
community.general.proxmox_kvm:
|
||||||
state: restarted
|
state: restarted
|
||||||
timeout: 60
|
timeout: 60
|
||||||
- name: Start VM # start if stopped
|
- name: Start VM # start if stopped
|
||||||
when:
|
when:
|
||||||
- vm.status is defined
|
- create.status is defined
|
||||||
- vm.status != "running"
|
- create.status != "running"
|
||||||
community.general.proxmox_kvm:
|
community.general.proxmox_kvm:
|
||||||
state: started
|
state: started
|
||||||
|
|
|
@ -3,16 +3,11 @@
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
- name: Wait for connection
|
- name: Wait for connection
|
||||||
ansible.builtin.ping:
|
ansible.builtin.wait_for:
|
||||||
register: wait_conn
|
host: "{{ inventory_hostname }}"
|
||||||
retries: 30
|
port: 22
|
||||||
delay: 10
|
timeout: 300
|
||||||
until: wait_conn.ping is defined
|
delegate_to: localhost
|
||||||
# ansible.builtin.wait_for:
|
|
||||||
# host: "{{ inventory_hostname }}"
|
|
||||||
# port: 22
|
|
||||||
# timeout: 300
|
|
||||||
# delegate_to: localhost
|
|
||||||
- name: Test some stuff
|
- name: Test some stuff
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
touch ~/hmm
|
touch ~/hmm
|
||||||
|
@ -20,6 +15,10 @@
|
||||||
echo test2 >> ~/test
|
echo test2 >> ~/test
|
||||||
mkdir ~/dir
|
mkdir ~/dir
|
||||||
touch ~/dir/testing
|
touch ~/dir/testing
|
||||||
|
register: stuff
|
||||||
|
retries: 10
|
||||||
|
delay: 6
|
||||||
|
until: stuff.rc == 0
|
||||||
- name: Install some stuff
|
- name: Install some stuff
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
Loading…
Reference in New Issue