From c783b8363651ed242fb4eef2f7c99a0cdb254d49 Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Tue, 11 Aug 2026 15:04:14 +0400 Subject: [PATCH] FEATURE: adds a hostname validation for lxc deployment playbook --- playbooks/deploy_and_set_up_lxc_on_proxmox.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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