feat(pb,role,task): adds storage validation and uses it in LXC and VM deployment
This commit is contained in:
@@ -26,6 +26,9 @@
|
|||||||
- name: Include input and validation for human admin user creation
|
- name: Include input and validation for human admin user creation
|
||||||
ansible.builtin.include_tasks: ../tasks/human_admin_user_validation.yaml
|
ansible.builtin.include_tasks: ../tasks/human_admin_user_validation.yaml
|
||||||
|
|
||||||
|
- name: Include input and validation for storage selection
|
||||||
|
ansible.builtin.include_tasks: ../tasks/storage_validation.yaml
|
||||||
|
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- ../roles/deploy_lxc_on_proxmox
|
- ../roles/deploy_lxc_on_proxmox
|
||||||
|
|||||||
@@ -26,6 +26,9 @@
|
|||||||
- name: Include input and validation for become method
|
- name: Include input and validation for become method
|
||||||
ansible.builtin.include_tasks: ../tasks/become_method_validation.yaml
|
ansible.builtin.include_tasks: ../tasks/become_method_validation.yaml
|
||||||
|
|
||||||
|
- name: Include input and validation for storage selection
|
||||||
|
ansible.builtin.include_tasks: ../tasks/storage_validation.yaml
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- ../roles/deploy_vm_on_proxmox
|
- ../roles/deploy_vm_on_proxmox
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,10 @@
|
|||||||
# This is minimal requirement for rootfs
|
# This is minimal requirement for rootfs
|
||||||
# It might be resized later
|
# It might be resized later
|
||||||
size: 4 # 4GB rootfs
|
size: 4 # 4GB rootfs
|
||||||
# We put rootfs on fast local storage (NVMe SSD)
|
# We put rootfs on user-selected sotrage
|
||||||
storage: local
|
storage: "{{ guest_storage }}"
|
||||||
|
# We need timeout in case a slow storage is used, since it may cause a significant delay
|
||||||
|
timeout: 90
|
||||||
pubkey: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/ansible_key.pub') }}"
|
pubkey: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/ansible_key.pub') }}"
|
||||||
netif:
|
netif:
|
||||||
net0: "name=eth0,gw=192.168.0.1,ip={{ guest_ip_address }}/{{ guest_netmask }},bridge=vmbr0"
|
net0: "name=eth0,gw=192.168.0.1,ip={{ guest_ip_address }}/{{ guest_netmask }},bridge=vmbr0"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
clone: "{{ guest_os_template }}-cloud-init-template"
|
clone: "{{ guest_os_template }}-cloud-init-template"
|
||||||
name: "{{ guest_hostname }}"
|
name: "{{ guest_hostname }}"
|
||||||
storage: main
|
storage: "{{ guest_storage }}"
|
||||||
format: qcow2
|
format: qcow2
|
||||||
full: true
|
full: true
|
||||||
timeout: 500
|
timeout: 500
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Set default storage
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
guest_storage: "main"
|
||||||
|
|
||||||
|
- name: Prompt for guest storage with immediate validation
|
||||||
|
ansible.builtin.pause:
|
||||||
|
prompt: "Choose storage for root, available: main (HDD), local (PCIe NVMe SSD) [{{ guest_storage }}]"
|
||||||
|
register: storage_result
|
||||||
|
until: >
|
||||||
|
storage_result.user_input | length == 0 or
|
||||||
|
(
|
||||||
|
storage_result.user_input in ['main', 'local']
|
||||||
|
)
|
||||||
|
retries: 2
|
||||||
|
delay: 0
|
||||||
|
|
||||||
|
- name: Use user input only if provided, otherwise keep the default
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
guest_storage: "{{ storage_result.user_input }}"
|
||||||
|
when: storage_result.user_input | length > 0
|
||||||
Reference in New Issue
Block a user