From 548fa65ac6db1f3b24944a106fa01872362fea17 Mon Sep 17 00:00:00 2001 From: Pavan Bidkar Date: Thu, 31 Oct 2019 14:02:52 +0530 Subject: [PATCH] VMware: Allow dash in Windows server dnsname (#64052) Fixes: #62810 --- .../62810-Vmware-Guest-Allow-DashInWindowsServerDNSName.yml | 2 ++ lib/ansible/modules/cloud/vmware/vmware_guest.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/62810-Vmware-Guest-Allow-DashInWindowsServerDNSName.yml diff --git a/changelogs/fragments/62810-Vmware-Guest-Allow-DashInWindowsServerDNSName.yml b/changelogs/fragments/62810-Vmware-Guest-Allow-DashInWindowsServerDNSName.yml new file mode 100644 index 00000000000..1f418164356 --- /dev/null +++ b/changelogs/fragments/62810-Vmware-Guest-Allow-DashInWindowsServerDNSName.yml @@ -0,0 +1,2 @@ +bugfixes: +- vmware_guest - Allow '-' (Dash) special char in windows DNS name. diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index a76fab86e36..53fd9341bee 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -1813,7 +1813,8 @@ class PyVmomiHelper(PyVmomi): ident.userData.computerName = vim.vm.customization.FixedName() # computer name will be truncated to 15 characters if using VM name default_name = self.params['name'].replace(' ', '') - default_name = ''.join([c for c in default_name if c not in string.punctuation]) + punctuation = string.punctuation.replace('-', '') + default_name = ''.join([c for c in default_name if c not in punctuation]) ident.userData.computerName.name = str(self.params['customization'].get('hostname', default_name[0:15])) ident.userData.fullName = str(self.params['customization'].get('fullname', 'Administrator')) ident.userData.orgName = str(self.params['customization'].get('orgname', 'ACME'))