Search code examples
amazon-ec2timeoutpackercloud-init

Cloud-init datasource setting timeout doesn't work


I tried to setting up cloud-init so it waits less time if fails to fetch the meta-data. It would be usefull for validating when instance is created with packer. Then provisioner can change back the timeout.

[  134.162079] cloud-init[475]: 2016-12-05 12:33:22,851 - DataSourceEc2.py[CRITICAL]: Giving up on md from ['http://169.254.169.254/2009-04-04/meta-data/instance-id'] after 120 seconds 

I used the example from here /usr/share/doc/cloud-init/examples/cloud-config-datasources.txt

and applied at the end of /etc/cloud/cloud.cfg

datasource:
  Ec2:
    timeout: 5
    max_wait: 10

But it simply doesn't work, the timeout is still 50s and max_wait 120s. My OS Red Hat 6, cloud-init Version: 0.7.4

EDIT:

attached cloud.cfg cloud-init.log


Solution

  • Ok, after a few trials, it appeared that I need to explicitly specify datasource_list. Like in example:

    datasource_list: [ Ec2, None ]
    

    Then the options timeout and max_wait applied for Ec2 are working.

    You can put them under /etc/cloud/cloud.cfg.d/99-datasource.cfg.