diff --git a/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml b/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml index 75a6bf3..008ad80 100644 --- a/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml +++ b/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml @@ -12,7 +12,7 @@ vars_prompt: - name: lxc_hostname - prompt: "Hostname for the container" + prompt: "Hostname for the container (may only contain letters (a-z, A-Z), numbers (0-9), and hyphens)" private: false - name: lxc_root_password @@ -25,6 +25,14 @@ prompt: "IP address for the container (in x.x.x.x/x formant)" private: false + pre_tasks: + - name: Validate hostname + ansible.builtin.fail: + msg: | + Invalid hostname: "{{ lxc_hostname }}" + Hostname may only contain letters (a-z, A-Z), numbers (0-9), and hyphens (-). + when: not lxc_hostname is regex('^[a-zA-Z0-9-]+$') + run_once: true roles: - ../roles/deploy_lxc_on_proxmox