我有一个 AWS EC2 映像,我已将其转换为 VirtualBox 并在本地运行。它运行良好,只是我不知道如何在启动时禁用对 AWS 元数据服务的调用:
2015-09-25 19:29:29,932 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [50/120s]: request error [(<urllib3.connectionpool.HTTPConnectionPool object at 0x7fb78650efd0>, 'Connection to 169.254.169.254 timed out. (connect timeout=50.0)')]
2015-09-25 19:30:20,987 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [101/120s]: request error [(<urllib3.connectionpool.HTTPConnectionPool object at 0x7fb78652cb90>, 'Connection to 169.254.169.254 timed out. (connect timeout=50.0)')]
2015-09-25 19:30:39,011 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [119/120s]: request error [(<urllib3.connectionpool.HTTPConnectionPool object at 0x7fb78650ee10>, 'Connection to 169.254.169.254 timed out. (connect timeout=17.0)')]
2015-09-25 19:30:40,015 - DataSourceEc2.py[CRITICAL]: Giving up on md from ['http://169.254.169.254/2009-04-04/meta-data/instance-id'] after 120 seconds
2015-09-25 19:31:43,509 - util.py[WARNING]: Failed to fetch password from virtual router 192.168.128.1
我可以在 cloud-init 的哪里禁用这些?这些调用最终会超时,但会导致 VirtualBox 映像的启动需要超过 2 分钟。
答案1
答案2
对于一次性的 virtualbox,@ching 的答案很好。但是,如果您正在制作模板并且需要 cloud-init 为您配置内容,那么执行此操作的“正确”方法是在 中创建一个覆盖文件/etc/cloud/cloud.cfg.d/
。 中的文件/etc/cloud/cloud.cfg.d/
将覆盖 中的值/etc/cloud.cfg
。
例子:
值/etc/cloud/cloud.cfg
datasource_list: [ Ec2, None ]
新文件/etc/cloud/cloud.cfg.d/99_overrides.cfg
datasource_list: [ None ]
您可以在此处添加其他提供程序(而不是 Ec2)-VMware、ConfigDrive 等,它们对于像使用 EC2 元数据那样配置内容非常方便。
看:https://cloudinit.readthedocs.io/en/latest/topics/datasources.html
答案3
systemctl disable cloud-config.service
systemctl disable cloud-final.service
systemctl disable cloud-init.service
systemctl disable cloud-init-local.service