feat(pb,task): moves input validation into separated tasks files. Play fails immediately if a validation fails

This commit is contained in:
2026-09-17 10:16:05 +04:00
parent 4789bbd850
commit 0696218eb6
6 changed files with 137 additions and 50 deletions
+20
View File
@@ -0,0 +1,20 @@
---
- name: Set default ip
ansible.builtin.set_fact:
lxc_ip_address: "192.168.0.90/24"
- name: Prompt for IP with immediate validation
ansible.builtin.pause:
prompt: "Enter ip in x.x.x.x/x format [192.168.0.90/24]"
register: ip_result
until: >
ip_result.user_input | length == 0 or
ip_result.user_input is regex('^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)/(3[0-2]|[12]?\\d)$')
retries: 2
delay: 0
- name: Use user input only if provided, otherwise keep the default
ansible.builtin.set_fact:
lxc_ip_address: "{{ ip_result.user_input }}"
when: ip_result.user_input | length > 0