Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cc-set-hostname (hostname and fqdn) are not working on google cloud VMs Ubuntu 24.04 #6058

Open
rajannpatel opened this issue Feb 26, 2025 · 4 comments
Labels
incomplete Action required by submitter

Comments

@rajannpatel
Copy link

Bug report

The steps here do not seem to impact the hostname on google cloud VMs:
https://cloudinit.readthedocs.io/en/latest/reference/modules.html#mod-cc-set-hostname

Steps to reproduce the problem

This cloud-init.yaml file, when used to launch a virtual machine on Google Cloud, does not make any changes to the hostname.

## template: jinja
#cloud-init

{% set HOSTNAME = 'www' %}
{% set FQDN = 'www.example.com' %}

hostname: {{ HOSTNAME }}
fqdn: {{ FQDN }}
prefer_fqdn_over_hostname: true

This is tested with the hostname command, once the machine boots up.

Environment details

  • Cloud-init version: cloud-init 24.4-0ubuntu1~24.04.2
  • Operating System Distribution: Ubuntu 24.04.2
  • Cloud provider, platform or installer type: Google Cloud
@rajannpatel rajannpatel added bug Something isn't working correctly new An issue that still needs triage labels Feb 26, 2025
@TheRealFalcon
Copy link
Member

On Noble and above on GCE, setting the hostname also requires create_hostname_file: true. Does adding that change work for you?

@TheRealFalcon TheRealFalcon added incomplete Action required by submitter and removed bug Something isn't working correctly new An issue that still needs triage labels Feb 26, 2025
@rajannpatel
Copy link
Author

No, I tried with and without, and it doesn't set the hostname or fqdn either way

@TheRealFalcon
Copy link
Member

@rajannpatel , whoops, looks like your header is wrong. #cloud-init should be #cloud-config. Though we do have a related issue on Plucky, I don't think that this is a problem on Noble.

@rajannpatel
Copy link
Author

oh

That's embarassing. I guess it's working as intended, for posterity I'm including some outputs from tests which appear to be working. I don't understand why I'm seeing some akamai domains in the output, but perhaps that is a byproduct of me using "example.com"

If this looks right to you, we can close this ticket.

Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-1021-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Thu Feb 27 00:17:30 UTC 2025

  System load:  1.24              Processes:             112
  Usage of /:   23.6% of 8.65GB   Users logged in:       0
  Memory usage: 5%                IPv4 address for ens4: 10.128.0.42
  Swap usage:   0%

Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

rajannpatel@www:~$ cloud-init query -f "$(sudo cloud-init query userdata)"
## template: jinja
#cloud-config


hostname: www
fqdn: www.example.com
create_hostname_file: true
rajannpatel@www:~$ hostname --domain
rajannpatel@www:~$ hostname --fqdn
www
rajannpatel@www:~$ hostname --short
www
rajannpatel@www:~$ hostname --long
www
rajannpatel@www:~$ hostname --all-fqdns
instance-20250227-001455.us-central1-c.c.ubuntu-pbx.internal 
rajannpatel@www:~$ hostname --alias

rajannpatel@www:~$ hostname --yp
hostname: Local domain name not set
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-1021-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Thu Feb 27 00:25:56 UTC 2025

  System load:  1.21              Processes:             114
  Usage of /:   23.7% of 8.65GB   Users logged in:       0
  Memory usage: 6%                IPv4 address for ens4: 10.128.0.43
  Swap usage:   0%

Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

rajannpatel@www:~$ cloud-init query -f "$(sudo cloud-init query userdata)"
## template: jinja
#cloud-config


hostname: www
fqdn: www.example.com
create_hostname_file: true
prefer_fqdn_over_hostname: true
rajannpatel@www:~$ hostname --domain
dscr.akamai.net
rajannpatel@www:~$ hostname --fqdn
a1422.dscr.akamai.net
rajannpatel@www:~$ hostname --short
www
rajannpatel@www:~$ hostname --long
a1422.dscr.akamai.net
rajannpatel@www:~$ hostname --all-fqdns
fqdn.us-central1-c.c.ubuntu-pbx.internal 
rajannpatel@www:~$ hostname --alias
www.example.com www.example.com-v4.edgesuite.net
rajannpatel@www:~$ hostname --yp
hostname: Local domain name not set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete Action required by submitter
Projects
None yet
Development

No branches or pull requests

2 participants