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 ?
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.
here is the full log file for cloud-init
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
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
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.
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.
@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?
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 ?
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.