feat(pb,task): moves input validation into separated tasks files. Play fails immediately if a validation fails
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user