feat(pb,role,task): adds storage validation and uses it in LXC and VM deployment

This commit is contained in:
2026-09-19 14:28:56 +04:00
parent 130fcb5069
commit 8530b93fea
5 changed files with 33 additions and 3 deletions
@@ -26,6 +26,9 @@
- name: Include input and validation for human admin user creation
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/deploy_lxc_on_proxmox
+3
View File
@@ -26,6 +26,9 @@
- name: Include input and validation for become method
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/deploy_vm_on_proxmox
+4 -2
View File
@@ -22,8 +22,10 @@
# This is minimal requirement for rootfs
# It might be resized later
size: 4 # 4GB rootfs
# We put rootfs on fast local storage (NVMe SSD)
storage: local
# We put rootfs on user-selected sotrage
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') }}"
netif:
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"
name: "{{ guest_hostname }}"
storage: main
storage: "{{ guest_storage }}"
format: qcow2
full: true
timeout: 500
+22
View File
@@ -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