Vmware cloud init centos 8

hi all,

@TimoGoebel :slight_smile:

my problem : i try to use cloud-init client with centos8 template, i have configured : 1 userdata template for the networks config and 1 cloud-init template for custom scripts post-install, and when my new vm boot, network config is ko, no ip configured, and if i use only userdata template its works ! any ideas ?

Template VMware
Vsphere: 6.7
OS : CentOS 8
kernel : 4.18.0-147.3.1
foreman: 1.24.2
cloud-init: 18.5-7.el8.noarch
openvmtools: 10.3.10-3.el8_1.1.x86_64

i follow this guide for configuring CloudInit : guide

rendered_cloudinit rendered_userdata hosts_template

I guess this doesn’t help you a lot, but this looks correct on first glance. Can you post the full cloud-init log? The messages in the screenshot are truncated.

hi @TimoGoebel !

here is the full log file for cloud-init :slight_smile:
I noticed that cloud-init overwrites the network config, in the eth0 file, there is a configuration in dhcp, but I am in static ip in foreman with userdata template

:bad_cfg_network_dhcp.log (167 Bytes) cloud-initlog.log (1.8 KB)

Does this solve the issue for you?

No the problem is not solved :frowning: I disabled the network part as described here but nothing helps

Does this help? https://bugs.launchpad.net/cloud-init/+bug/1712680

hi !

Not really, when i disabled the config network in /etc/cloud/cloud.cfg, the network configuration is no longer overwritten, my vm starts without network configuration, there is no file in “/etc/sysconfig/network-scripts/ifcfg- *”; it looks like the cloud-init service starts before vmtoolsd.service and suddenly nothing happens, very strange.

I advanced on my problem :), I found with this article, now that my network configuration is ok, it looks like Cloud-init can’t find the template from foreman, any ideas? I attach the log file

cloud-init.log (29.8 KB)

to complete, server foreman answers me:

2020-04-10T15:01:16 [I|app|33e5351d] Started GET “/userdata/meta-data” for 10.144.3.44 at 2020-04-10 15:01:16 +0200
2020-04-10T15:01:16 [I|app|33e5351d] Processing by UserdataController#metadata as TEXT
2020-04-10T15:01:16 [E|app|33e5351d] Could not find host for request 10.144.3.44
2020-04-10T15:01:16 [I|app|33e5351d] Rendering text template
2020-04-10T15:01:16 [I|app|33e5351d] Rendered text template (0.0ms)
2020-04-10T15:01:16 [I|app|33e5351d] Filter chain halted as :find_host rendered or redirected
2020-04-10T15:01:16 [I|app|33e5351d] Completed 404 Not Found in 31ms (Views: 1.0ms | ActiveRecord: 13.0ms)
2020-04-10T15:01:18 [I|app|e1a0bdfd] Started GET “/userdata/meta-data” for 10.144.3.44 at 2020-04-10 15:01:18 +0200
2020-04-10T15:01:18 [I|app|e1a0bdfd] Processing by UserdataController#metadata as TEXT
2020-04-10T15:01:18 [E|app|e1a0bdfd] Could not find host for request 10.144.3.44
2020-04-10T15:01:18 [I|app|e1a0bdfd] Rendering text template
2020-04-10T15:01:18 [I|app|e1a0bdfd] Rendered text template (0.0ms)
2020-04-10T15:01:18 [I|app|e1a0bdfd] Filter chain halted as :find_host rendered or redirected
2020-04-10T15:01:18 [I|app|e1a0bdfd] Completed 404 Not Found in 32ms (Views: 1.0ms | ActiveRecord: 11.9ms)
2020-04-10T15:01:20 [I|app|be1373fb] Started GET “/userdata/meta-data” for 10.144.3.44 at 2020-04-10 15:01:20 +0200
2020-04-10T15:01:20 [I|app|be1373fb] Processing by UserdataController#metadata as TEXT
2020-04-10T15:01:20 [E|app|be1373fb] Could not find host for request 10.144.3.44
2020-04-10T15:01:20 [I|app|be1373fb] Rendering text template
2020-04-10T15:01:20 [I|app|be1373fb] Rendered text template (0.1ms)
2020-04-10T15:01:20 [I|app|be1373fb] Filter chain halted as :find_host rendered or redirected
2020-04-10T15:01:20 [I|app|be1373fb] Completed 404 Not Found in 35ms (Views: 1.1ms | ActiveRecord: 14.9ms)
2020-04-10T15:01:22 [I|app|368d9d39] Started GET “/userdata/meta-data” for 10.144.3.44 at 2020-04-10 15:01:22 +0200
2020-04-10T15:01:22 [I|app|368d9d39] Processing by UserdataController#metadata as TEXT
2020-04-10T15:01:22 [E|app|368d9d39] Could not find host for request 10.144.3.44
2020-04-10T15:01:22 [I|app|368d9d39] Rendering text template
2020-04-10T15:01:22 [I|app|368d9d39] Rendered text template (0.0ms)
2020-04-10T15:01:22 [I|app|368d9d39] Filter chain halted as :find_host rendered or redirected
2020-04-10T15:01:22 [I|app|368d9d39] Completed 404 Not Found in 39ms (Views: 1.0ms | ActiveRecord: 18.0ms)
2020-04-10T15:01:24 [I|app|9aff333b] Started GET “/userdata/meta-data” for 10.144.3.44 at 2020-04-10 15:01:24 +0200
2020-04-10T15:01:24 [I|app|9aff333b] Processing by UserdataController#metadata as TEXT
2020-04-10T15:01:24 [E|app|9aff333b] Could not find host for request 10.144.3.44
2020-04-10T15:01:24 [I|app|9aff333b] Rendering text template
2020-04-10T15:01:24 [I|app|9aff333b] Rendered text template (0.0ms)
2020-04-10T15:01:24 [I|app|9aff333b] Filter chain halted as :find_host rendered or redirected
2020-04-10T15:01:24 [I|app|9aff333b] Completed 404 Not Found in 30ms (Views: 1.1ms | ActiveRecord: 11.0ms)

So the 404 means that userdata endpoint is not able to pair your host. Since cloud-init does not allow any payload, the way this is implemented is that IP of the provisioning interface is matched against the HTTP(s) REMOTE IP.

Therefore you need to make sure that the IP address in Foreman database matches the real IP address the host is connecting from. If you use NAT, then this will not work.

1 Like

Hi lzap !

thank you for your reply, however it is not very clear to me, my client has an ip address known to foreman (provisioning address) and my server has his own ip address, both are in the same lan and accessible, so my client and my server don’t have the same ip.

By client I mean cloud-init who is talking to Foreman. It’s IP address must match provisioning IP of the host otherwise it will be 404.

Hi :grinning:,

the problem came from my haproxy configuration, by making a curl to my instance of foreman directly here :), I see the template

thanks :stuck_out_tongue_winking_eye:

2 Likes

@orelops: Yep, it’s a bummer that we can just use the source IP address of the request to identify which host is calling Foreman in order to find the correct template.
In your research have you found another solution that we could use to identify the calling system?

@TimoGoebel,

I cannot work around the problem, I use haproxy in frontend, but the problem is that my servers which are not in the same lan, that does not work, that is why I pass by haproxy … why is we do not use HTTP Headers? is there a workaround ?

Do you mean using some headers injected by haproxy to figure out the actual remote IP address? What headers do you mean?

@TimoGoebel,

what i mean is that foreman is based on the tcp socket not the http headers, do you have a workaround? because we are in front of haproxy which are not on the same network.

ok i found, I had to add the ips in my haproxy servers in the settings of foreman provisioning tab and put the ips in remote address.

1 Like

Great, share your configuration bits here if you can for googlers.

1 Like