cloud-init is configured with hardcoded manage_etc_hosts: true

Jacolex

Active Member
Aug 8, 2019
3
1
43
48
Hello
I'm struggling with issue, that loud-init is configured with hardcoded manage_etc_hosts: true, which causes rewriting of /etc/hosts file every reboot (Centos 8). I don't know, why cloud init configuration was patched to do so:
https://lists.proxmox.com/pipermail/pve-devel/2018-March/030988.html
I think it should be configurable or disabled. Spent many days to find out, why /etc/hosts files on my servers re always rewriting, even when manage_etc_hosts was set to false in cloud.cfg configuration.
 
i found it's hardcoded in `/usr/share/perl5/PVE/QemuServer/Cloudinit.pm`, modify the config in this file, then everything is ok for me~
 
Sorry to resurrect an old thread, but we're running into the same problem.

Would be nice if this could be turned off in the UI or in a config file, as opposed to by editing a random script which could get overwritten during an update.
 
  • Like
Reactions: f00l and maksimsamt
The post is quite old, but as I had the same problem today, I post the workaround I found.
You can delete the line:

`update_etc_hosts` in file `/etc/cloud/cloud.cfg` as it interely disable the module without worried about hardcoded userdata
 
  • Like
Reactions: f00l and maksimsamt
Sorry to resurrect an old thread, but we're running into the same problem.

Would be nice if this could be turned off in the UI or in a config file, as opposed to by editing a random script which could get overwritten during an update.
+1
 
  • Like
Reactions: Jacolex
I've resorted to using ansible to customize the /etc/cloud-init/templates/hosts.debian.tmpl instead, since both Amazon EC2 and Proxmox seem to go out of their way to make cloud-init even more intrustive than Canonical designed it to be. I'm beginning to really loath cloud-init.
 
I've resorted to using ansible to customize the /etc/cloud-init/templates/hosts.debian.tmpl instead, since both Amazon EC2 and Proxmox seem to go out of their way to make cloud-init even more intrustive than Canonical designed it to be. I'm beginning to really loath cloud-init.
Do you have a sample of your configuration here?
 
Hi,

I have the same issues.

I have been using oVirt for over 10 years and I was really surprised, that Proxmox is setting this by default, which is not enabled by default in oVirt nor it is intended in Ubuntu cloud-image.

Dear Proxmox-Team, would it be possible to make this option optional and configurable in GUI and command line?
 
Hi,

I have the same issues.

I have been using oVirt for over 10 years and I was really surprised, that Proxmox is setting this by default, which is not enabled by default in oVirt nor it is intended in Ubuntu cloud-image.

Dear Proxmox-Team, would it be possible to make this option optional and configurable in GUI and command line?
Of course, it would be nice if we could manage more cloud-init options directly via the UI or maybe even insert a custom config into a text field, as is the case with various VPS providers.

However, I don't understand the argument that manage_etc_hosts is not intended to be used with Ubuntu cloud images. I mean, why would they provide that module in the first place if you're not supposed to use it? Whether it should be enabled by default in Proxmox is, of course, another question. ;)

Either way, for now, the cleanest solution, imho, is to edit the /etc/cloud/templates/hosts.debian.tmpl file instead of the /etc/hosts file directly, as stated in the cloud-init docs: https://cloudinit.readthedocs.io/en/latest/reference/modules.html#update-etc-hosts.

Btw, it also says what to do in the/etc/hosts file diretcly: ;)

Code:
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
 
Last edited:
  • Like
Reactions: Johannes S
...

However, I don't understand the argument that manage_etc_hosts is not intended to be used with Ubuntu cloud images. I mean, why would they provide that module in the first place if you're not supposed to use it? Whether it should be enabled by default in Proxmox is, of course, another question. ;)

Either way, for now, the cleanest solution, imho, is to edit the /etc/cloud/templates/hosts.debian.tmpl file instead of the /etc/hosts file directly, as stated in the cloud-init docs: https://cloudinit.readthedocs.io/en/latest/reference/modules.html#update-etc-hosts.

...

ok, this was maybe a bit harsh.
In my opinion, this goes a bit too far. Most users are managing their VMs by ansible or terraform, but not by cloud-init.
Cloud-init is important for first provisioning, but later on, I think it is rarely used.

Sure, it is stated in the file itself, but as I wrote above, my VMs are managed by ansible and therefore, I don't check those files very often.