#cloud-config
preserve_hostname: true
manage_etc_hosts: false
bootcmd:
 - cloud-init-per instance my_set_hostname sh -xc "echo "%s-$INSTANCE_ID" | sed -e 's/-i-/-/g' > /etc/hostname; hostname -F /etc/hostname"
 - cloud-init-per instance my_etc_hosts sh -xc "sed -i -e '/^127.0.1.1/d' /etc/hosts; echo 127.0.1.1 $(cat /etc/hostname).canary.us-west2.justin.tv $(cat /etc/hostname) >> /etc/hosts"
runcmd:
 - sleep 1
 - echo "cluster=%s" > /etc/facter/facts.d/cluster.txt
 - echo "clean=true" > /etc/facter/facts.d/clean.txt
 - echo "consul_environment=canary" > /etc/facter/facts.d/consul_environment.txt
 - echo "deploy_environment=canary" > /etc/facter/facts.d/deploy_environment.txt
 - puppet agent --test
 - for i in {1..10} ; do if [[ -e /opt/twitch/trace/current ]]; then break ; fi ; puppet agent --test ; sleep 60 ; done
 - puppet agent --test
