1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
2
Hello.
Try changing your user data script to something like this:
I think you should set "preserve_hostname:true" in cloud-init and run the "hostnamectl" command to set the host name.
#!/bin/bash
sed -i '$a(preserve_hostname:true)' /etc/cloud/cloud.cfg
hostnamectl set-hostname test7
I actually tried running it with my AWS account, and I was able to confirm that the host name had been changed as shown below.
[fedora@test7 ~]$ cat /etc/hostname
test7
Conteúdo relevante
- AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há 2 anos
- AWS OFICIALAtualizada há 2 anos
When starting with AWS CLI, you can set the user data as follows.
Thank you, that does indeed work, but it seems like something of a workaround. Is there a reason why the conventional method which works for me on Ubuntu fails on Fedora?
As shown below, the hostname itself appears to be reflected, but since the FQDN is not reflected, it appears that the hostname is not reflected.
Here, when I set the hostname in fqdn format, it was reflected in the hostname.
It is unclear whether this is a cloud-init specification or a bug, but I found someone reporting a similar problem at the URL below. https://github.com/canonical/cloud-init/issues/4656
I think the loading order and behavior of cloud-init are probably different between Ubuntu and Fedora. https://github.com/canonical/cloud-init/issues/4656#issuecomment-1854484271
Looking at the script below, it seems to work the same as RHEL because it imports rhel. https://github.com/canonical/cloud-init/blob/d29b744e742d12e41e9490fb05e74537b4b768d7/cloudinit/distros/fedora.py
In other words, I think that the same thing as explained in the URL below is also happening in Fedora's cloud-init. https://github.com/canonical/cloud-init/issues/4656#issuecomment-1854484271
Thank you for looking into this issue Riku_Kobayashi, I will review the information supplied.