You've already forked role_proxmox
78 lines
2.8 KiB
YAML
78 lines
2.8 KiB
YAML
---
|
|
# tasks file for proxmox
|
|
|
|
- name: Get instance configuration file informations
|
|
ansible.builtin.stat:
|
|
path: /etc/pve/lxc/{{ proxmox_instance_vmid }}.conf
|
|
become: true
|
|
delegate_to: "{{ proxmox_delegate_to }}"
|
|
register: proxmox_ct_configuration
|
|
|
|
- name: Manage instance
|
|
community.proxmox.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 }}"
|
|
cores: "{{ proxmox_instance_cores }}"
|
|
disk_volume: "{{ proxmox_instance_disk_volumes }}"
|
|
features: "{{ proxmox_instance_features if proxmox_ct_configuration.stat.exists else omit }}"
|
|
hostname: "{{ inventory_hostname }}"
|
|
memory: "{{ proxmox_instance_memory }}"
|
|
mount_volumes: "{{ proxmox_instance_mount_volumes }}"
|
|
netif: "{{ proxmox_instance_netif }}"
|
|
node: "{{ proxmox_instance_node }}"
|
|
ostemplate: "{{ proxmox_instance_ostemplate }}"
|
|
ostype: "{{ proxmox_instance_ostype }}"
|
|
password: "{{ omit if proxmox_instance_password | length == 0 else proxmox_instance_password }}"
|
|
startup: "{{ omit if proxmox_instance_startup | length == 0 else proxmox_instance_startup }}"
|
|
swap: "{{ proxmox_instance_swap }}"
|
|
timeout: "{{ proxmox_instance_timeout }}"
|
|
unprivileged: "{{ (proxmox_instance_unprivileged | int) if proxmox_ct_configuration.stat.exists else omit }}"
|
|
update: true
|
|
vmid: "{{ proxmox_instance_vmid }}"
|
|
become: true
|
|
delegate_to: "{{ proxmox_delegate_to }}"
|
|
notify: Restart instance
|
|
|
|
- name: Ensure instance is started
|
|
community.proxmox.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 }}"
|
|
vmid: "{{ proxmox_instance_vmid }}"
|
|
node: "{{ proxmox_instance_node }}"
|
|
state: started
|
|
delegate_to: "{{ proxmox_delegate_to }}"
|
|
|
|
- name: Manage cmode option
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/pve/lxc/{{ proxmox_instance_vmid }}.conf
|
|
regexp: '^cmode:'
|
|
line: "cmode: {{ proxmox_instance_cmode }}"
|
|
become: true
|
|
delegate_to: "{{ proxmox_delegate_to }}"
|
|
notify: Restart instance
|
|
|
|
- name: Manage features option
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/pve/lxc/{{ proxmox_instance_vmid }}.conf
|
|
regexp: '^features:'
|
|
line: "features: {{ proxmox_instance_features | join(' ') }}"
|
|
become: true
|
|
delegate_to: "{{ proxmox_delegate_to }}"
|
|
notify: Restart instance
|
|
|
|
- name: Manage unprivileged option
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/pve/lxc/{{ proxmox_instance_vmid }}.conf
|
|
regexp: '^unprivileged:'
|
|
line: "unprivileged: {{ proxmox_instance_unprivileged | int }}"
|
|
become: true
|
|
delegate_to: "{{ proxmox_delegate_to }}"
|
|
notify: Restart instance
|
|
|
|
- name: Flush handlers
|
|
ansible.builtin.meta: flush_handlers
|