For the purpose of testing cloud-init local datasource, we can use vagrant to get a bare bones trusty box quick.
Look here for examples: https://cloudinit.readthedocs.org/en/latest/topics/examples.html
mkdir -p cloud-init/local-provider/vagrant
cd cloud-init/local-provider/vagrant
vagrant init ubuntu/trusty64; vagrant up --provider virtualbox
Ssh into the vagrant vm
vagrant ssh
Remove cloud-init files so node is in uninitialized state
rm -rf /var/lib/cloud/instance/*
rm -rf /var/lib/cloud/seed/nocloud-net/user-data
Create the user-data file in /var/lib/cloud/seed/nocloud-net/user-data with the contents
#cloud-config
runcmd:
- echo "testtest" > /testfile.txt
Next run the commands to cloud-init your local instance
sudo cloud-init init --local
sudo cloud-init --debug modules -–mode config
sudo cloud-init --debug modules -–mode final