[FEATURE]: Immediate stop if an incorrect value is passed #38

Closed
opened 2026-09-16 18:05:40 +04:00 by max · 8 comments
Owner

🎯 Problem Statement

I'm always frustrated when I make a small mistake in some prompt and can't see it until I enter all

💡 Proposed Solution

Instead of 'ask all -> check all' approach, it would be better to ask one value and check it immediately and fail if it's wrong

🔄 Alternatives Considered

No response

📸 Screenshots

No response

⚙️ Technical Approach

  • Only deployment playbooks would be affected
  • Instead of vars_prompt and pre_tasks ansible.builtin.pause may be used
  • Each variable has it's own ansible.builtin.pause with 'until'

✅ Acceptance Criteria

  • Single wrong value causes fail immediately

🤝 Are you willing to contribute this feature?

Yes, I can contribute

✅ Submission Checklist

  • I have searched for existing issues (open and closed) that request the same feature
  • I have explained the problem this feature solves
  • I have described a concrete solution or direction
  • I have considered alternatives and explained why they fall short
### 🎯 Problem Statement I'm always frustrated when I make a small mistake in some prompt and can't see it until I enter all ### 💡 Proposed Solution Instead of 'ask all -> check all' approach, it would be better to ask one value and check it immediately and fail if it's wrong ### 🔄 Alternatives Considered _No response_ ### 📸 Screenshots _No response_ ### ⚙️ Technical Approach - Only deployment playbooks would be affected - Instead of vars_prompt and pre_tasks ansible.builtin.pause may be used - Each variable has it's own ansible.builtin.pause with 'until' ### ✅ Acceptance Criteria - [x] Single wrong value causes fail immediately ### 🤝 Are you willing to contribute this feature? Yes, I can contribute ### ✅ Submission Checklist - [x] I have searched for existing issues (open and closed) that request the same feature - [x] I have explained the problem this feature solves - [x] I have described a concrete solution or direction - [ ] I have considered alternatives and explained why they fall short
max added the enhancement label 2026-09-16 18:05:40 +04:00
Author
Owner

Here is an example for hostname validation AND default value:

  tasks:
    - name: Set default hostname
      ansible.builtin.set_fact:
        lxc_hostname: "default-hostname"

    - name: Prompt for hostname with immediate validation
      ansible.builtin.pause:
        prompt: "Enter hostname [default-hostname] (letters, digits, hyphens, dots; max 253 chars). Press Enter to keep the default."
      register: hostname_result
      until: >
        hostname_result.user_input | length == 0 or
        (
          hostname_result.user_input | length <= 253 and
          hostname_result.user_input is regex('^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$')
        )
      retries: 3
      delay: 0

    - name: Use user input only if provided, otherwise keep the default
      ansible.builtin.set_fact:
        lxc_hostname: "{{ hostname_result.user_input }}"
      when: hostname_result.user_input | length > 0
Here is an example for hostname validation AND default value: ``` tasks: - name: Set default hostname ansible.builtin.set_fact: lxc_hostname: "default-hostname" - name: Prompt for hostname with immediate validation ansible.builtin.pause: prompt: "Enter hostname [default-hostname] (letters, digits, hyphens, dots; max 253 chars). Press Enter to keep the default." register: hostname_result until: > hostname_result.user_input | length == 0 or ( hostname_result.user_input | length <= 253 and hostname_result.user_input is regex('^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$') ) retries: 3 delay: 0 - name: Use user input only if provided, otherwise keep the default ansible.builtin.set_fact: lxc_hostname: "{{ hostname_result.user_input }}" when: hostname_result.user_input | length > 0 ```
Author
Owner

daa5826573 adds the requested support, but for LXCs only for now

[daa5826573](https://git.vmn.su/max/vmn-ansible/commit/daa582657340c45faa7d61109c62eb61dbe86142) adds the requested support, but for LXCs only for now
Author
Owner

Since new tasks are highly modular, they can be used in VMs deployment as well. Although, slight renaming would be required to make the tasks independent of the guest type (VM or LXC). Also renaming in LXC role would be necessary.

Since new tasks are highly modular, they can be used in VMs deployment as well. Although, slight renaming would be required to make the tasks independent of the guest type (VM or LXC). Also renaming in LXC role would be necessary.
Author
Owner

Since new tasks are highly modular, they can be used in VMs deployment as well. Although, slight renaming would be required to make the tasks independent of the guest type (VM or LXC). Also renaming in LXC role would be necessary.

f29de42397 implements it. Now only VM deployment playbook needs to be updated

> Since new tasks are highly modular, they can be used in VMs deployment as well. Although, slight renaming would be required to make the tasks independent of the guest type (VM or LXC). Also renaming in LXC role would be necessary. [f29de42397](https://git.vmn.su/max/vmn-ansible/commit/f29de423973a918a231bf2cb265a031d3ce4eff6) implements it. Now only VM deployment playbook needs to be updated
Author
Owner

2fccf20768 updates VM deployment playbook, it uses shared validation pre_tasks and shares os_template and become_method tasks. Tested with debian-13, it needs alpine tests

[2fccf20768](https://git.vmn.su/max/vmn-ansible/commit/2fccf207682547fc0b90db7d694311d21db08710) updates VM deployment playbook, it uses shared validation pre_tasks and shares os_template and become_method tasks. Tested with debian-13, it needs alpine tests
Author
Owner

Tests with Alpine are passed. Minor naming fixes are necessary

Tests with Alpine are passed. Minor naming fixes are necessary
Author
Owner

Naming fixes are in place (93cee75), but password validation is just a copy-paste of hostname validation, password allows, in fact it requires, more complex combinations and special characters. New password validation is required.

Naming fixes are in place (93cee75), but password validation is just a copy-paste of hostname validation, password allows, in fact it requires, more complex combinations and special characters. New password validation is required.
Author
Owner

130fcb5069 allows the use of more complex passwords

[130fcb5069](https://git.vmn.su/max/vmn-ansible/commit/130fcb5069530c5b593927e9adad6678a9340045) allows the use of more complex passwords
max closed this issue 2026-09-17 19:53:47 +04:00
Sign in to join this conversation.