Compare commits

5 Commits

7 changed files with 43 additions and 11 deletions
@@ -23,9 +23,15 @@
- name: Include input and validation for LXC privilege
ansible.builtin.include_tasks: ../tasks/lxc_privileged_validation.yaml
- name: Include input and validation for OS template
ansible.builtin.include_tasks: ../tasks/os_template_validation.yaml
- 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
+6 -4
View File
@@ -13,8 +13,8 @@
cmode: "shell"
password: "{{ lxc_root_password }}"
hostname: "{{ guest_hostname }}"
ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz'
unprivileged: "{{ lxc_privileged }}"
ostemplate: "main:vztmpl/{{ guest_os_template }}-golden-image.tar.gz"
unprivileged: "{{ not lxc_privileged | bool }}"
memory: 2048
cores: 2
state: present
@@ -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
+1 -1
View File
@@ -25,5 +25,5 @@
- name: Use user input only if provided, otherwise keep the default (netmask)
ansible.builtin.set_fact:
guest_netmask: "{{ ip_result.user_input.split('/') | second }}"
guest_netmask: "{{ ip_result.user_input.split('/')[1] }}"
when: ip_result.user_input | length > 0
+3 -4
View File
@@ -9,15 +9,13 @@
prompt: "Enter your password [{{ lxc_root_password }}]"
echo: false
register: password_result_1
until: password_result_1.user_input | length == 0
retries: 2
delay: 0
- name: Prompt for password (confirmation)
- name: Prompt for password confirmation (only if a password was entered)
ansible.builtin.pause:
prompt: "Confirm your new password"
echo: false
register: password_result_2
when: password_result_1.user_input | length > 0
- name: Ensure passwords match
ansible.builtin.assert:
@@ -25,6 +23,7 @@
- password_result_1.user_input == password_result_2.user_input
fail_msg: "Passwords do not match!"
success_msg: "Password confirmed."
when: password_result_1.user_input | length > 0
- name: Use user input only if provided, otherwise keep the default
ansible.builtin.set_fact:
+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