From f74cd17a231912187b335ab90ca259c5efa91abe Mon Sep 17 00:00:00 2001 From: James Antill Date: Tue, 25 Mar 2025 20:36:02 -0400 Subject: [PATCH] Add regexp to drop spaces from hostnames in prompts, for add_host. Signed-off-by: James Antill --- playbooks/vhost_reboot.yml | 3 ++- playbooks/vhost_update.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/playbooks/vhost_reboot.yml b/playbooks/vhost_reboot.yml index 3a4a658124..0396573a4e 100644 --- a/playbooks/vhost_reboot.yml +++ b/playbooks/vhost_reboot.yml @@ -40,7 +40,8 @@ with_items: "{{ vmlist.list_vms }}" - name: add the vmhost to target group - local_action: add_host hostname={{ target }} groupname=target + # Use a simple regexp to ignore spaces people might accidentally paste. + local_action: add_host hostname={{ target | regex_search('[-a-z0-9.]+') }} groupname=target # Call out to another playbook. Disable any proxies that may live here - name: update proxy dns if needed diff --git a/playbooks/vhost_update.yml b/playbooks/vhost_update.yml index d43a86773b..6a7267ecf1 100644 --- a/playbooks/vhost_update.yml +++ b/playbooks/vhost_update.yml @@ -25,7 +25,8 @@ with_items: '{{vmlist.list_vms}}' - name: Add the vmhost to target group - local_action: add_host hostname={{ target }} groupname=target + # Use a simple regexp to ignore spaces people might accidentally paste. + local_action: add_host hostname={{ target | regex_search('[-a-z0-9.]+') }} groupname=target # Call out to another playbook. Disable any proxies that may live here # - include_playbook: update-proxy-dns.yml status=disable proxies=myvms_new:&proxies