Skip to content

Instantly share code, notes, and snippets.

@jamesbeedy
Created September 17, 2015 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesbeedy/54ede31727f65d1664ad to your computer and use it in GitHub Desktop.
Save jamesbeedy/54ede31727f65d1664ad to your computer and use it in GitHub Desktop.

Cloud-Init How To

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

Local Provider - NoCloud

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment