first commit
This commit is contained in:
51
roles/proxmox_lxc/tasks/main.yml
Normal file
51
roles/proxmox_lxc/tasks/main.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
- name: Get next available VMID
|
||||
community.general.proxmox_next_id:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
register: next_vmid
|
||||
|
||||
- name: Clone LXC from template
|
||||
community.general.proxmox:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
node: "{{ target_node }}"
|
||||
clone: "ubuntu24lxc"
|
||||
hostname: "{{ vm_hostname }}"
|
||||
vmid: "{{ next_vmid.vmid }}"
|
||||
full: true
|
||||
storage: "local-lvm"
|
||||
timeout: 300
|
||||
register: cloned_lxc
|
||||
|
||||
- name: Configure LXC resources
|
||||
community.general.proxmox:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
node: "{{ target_node }}"
|
||||
vmid: "{{ next_vmid.vmid }}"
|
||||
cores: "{{ cpu_cores }}"
|
||||
memory: "{{ ram_gb | int * 1024 }}"
|
||||
netif:
|
||||
net0: "name=eth0,bridge=vmbr0,ip=dhcp"
|
||||
state: present
|
||||
|
||||
- name: Start the LXC container
|
||||
community.general.proxmox:
|
||||
api_host: "{{ proxmox_api_host }}"
|
||||
api_user: "{{ proxmox_api_user }}"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
node: "{{ target_node }}"
|
||||
vmid: "{{ next_vmid.vmid }}"
|
||||
state: started
|
||||
|
||||
- name: Set VMID fact for later use
|
||||
ansible.builtin.set_fact:
|
||||
created_vmid: "{{ next_vmid.vmid }}"
|
||||
Reference in New Issue
Block a user