public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server] cloudinit: pass through hostname via fqdn field
@ 2023-05-23  7:14 Leo Nunner
  2023-06-07 17:33 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Leo Nunner @ 2023-05-23  7:14 UTC (permalink / raw)
  To: pve-devel

If no FQDN is provided, we simply set it to the current hostname. This
ensures that the hostname *really* gets set, since we encountered an
issue on Fedora and CentOS based systems where no hostname got set at
all.

When there's no FQDN set in the cloudinit config, this leads to the
following entry:

    127.0.1.1 <hostname> <hostname>

Which doesn't seem to cause any issues.

Tested on:
 - Ubuntu 23.04
 - CentOS 8
 - Fedora 38
 - Debian 11
 - SUSE 15.4

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
---
 PVE/QemuServer/Cloudinit.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index a0c3d60..88888d7 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -87,6 +87,8 @@ sub get_hostname_fqdn {
 	$hostname =~ s/\..*$//;
     } elsif (my $search = $conf->{searchdomain}) {
 	$fqdn = "$hostname.$search";
+    } else {
+	$fqdn = $hostname;
     }
     return ($hostname, $fqdn);
 }
@@ -120,7 +122,7 @@ sub cloudinit_userdata {
 
     $content .= "hostname: $hostname\n";
     $content .= "manage_etc_hosts: true\n";
-    $content .= "fqdn: $fqdn\n" if defined($fqdn);
+    $content .= "fqdn: $fqdn\n";
 
     my $username = $conf->{ciuser};
     my $password = $conf->{cipassword};
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH qemu-server] cloudinit: pass through hostname via fqdn field
  2023-05-23  7:14 [pve-devel] [PATCH qemu-server] cloudinit: pass through hostname via fqdn field Leo Nunner
@ 2023-06-07 17:33 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-06-07 17:33 UTC (permalink / raw)
  To: Proxmox VE development discussion, Leo Nunner

Am 23/05/2023 um 09:14 schrieb Leo Nunner:
> If no FQDN is provided, we simply set it to the current hostname. This
> ensures that the hostname *really* gets set, since we encountered an
> issue on Fedora and CentOS based systems where no hostname got set at
> all.
> 
> When there's no FQDN set in the cloudinit config, this leads to the
> following entry:
> 
>     127.0.1.1 <hostname> <hostname>
> 
> Which doesn't seem to cause any issues.
> 
> Tested on:
>  - Ubuntu 23.04
>  - CentOS 8
>  - Fedora 38
>  - Debian 11
>  - SUSE 15.4
> 
> Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
> ---
>  PVE/QemuServer/Cloudinit.pm | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-07 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23  7:14 [pve-devel] [PATCH qemu-server] cloudinit: pass through hostname via fqdn field Leo Nunner
2023-06-07 17:33 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal