Reputation: 21
I am trying to boot the instance with NoCloud datasource. But everytime the instance comes up it is try to connect to the network and metadata service.
logs: 2015-08-17 15:48:58,115 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [0/120s]: request error [HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /2009-04-04/meta-data/instance-id (Caused by : [Errno 111] Connection refused)]
I have created a drive with meta-data and user-data:
meta-data:
instance-id: iid-local01
local-hostname: cloudimg
user-data:
#cloud-config
write_files:
- path: /test.txt
content: |
Here is a line
But the file is not getting created. Can you help in solving this issue? Or in disabling the cloud-init from contacting the metadata services.
Upvotes: 2
Views: 6276
Reputation: 11
Old, But I hit the same kind of issue today because CentOS7 is still using cloud-init 18.2. Taking care of selecting correct version on the cloud-init doc (I did'nt first), I found that the label must be in lowercase "cidata".
If wrong or no label, your device will be ignored and cloud-init will fallback to network-based datasources (EC2,OS, etc...).
Feel free to use my sample script here as it will generate a vfat img containing your user-data and meta-data files. Then attach it to your VM.
Tested with current ubuntu and CentOS cloud images.
https://github.com/BrHal/CloudInit
Upvotes: 1
Reputation: 56
I suspect that your issue is that the attached disk is simply not being created correctly so that cloud-init will identify it. There is more information in the documentation.
cloud-localds is a pretty much stand-alone tool available from the cloud-utils package that can aid in making a usable NoCloud datasource. Its usage looks like this, provided a 'disk1.img' file that contains a image with cloud-init installed.
$ cat my-user-data
#cloud-config
password: passw0rd
chpasswd: { expire: False }
ssh_pwauth: True
$ echo "instance-id: $(uuidgen || echo i-abcdefg)" > my-meta-data
$ cloud-localds my-seed.img my-user-data my-meta-data
$ qemu-system-x86_64 -enable-kvm \
-net nic -net user,hostfwd=tcp::2222-:22 \
-drive file=disk1.img,if=virtio -drive file=my-seed.img,if=virtio
$ ssh -p 2222 ubuntu@localhost
If this is not working correctly for you, please file a bug
Upvotes: 0