#cloud-config
bootcmd:
 - apt-get remove --purge -y resolvconf || true
 - echo 'prepend domain-name-servers {nameserver};' | tee -a /etc/dhcp/dhclient.conf
 - echo 'supersede domain-name "{lab_domain}";' | tee -a /etc/dhcp/dhclient.conf
 - ifdown -a ; ifup -a
 - grep --quiet {nameserver} /etc/resolv.conf || ( echo 'nameserver {nameserver}' ; echo 'search {lab_domain}' ) | tee /etc/resolv.conf
 - ( wget -qO - http://169.254.169.254/2009-04-04/meta-data/hostname | sed -e 's/[\.-].*//' ; eval printf "%03d%03d%03d%03d.{lab_domain}" $(wget -qO - http://169.254.169.254/2009-04-04/meta-data/local-ipv4 | tr . ' ' ) ) | tee /etc/hostname
 - hostname $(cat /etc/hostname)
 - echo "MaxSessions 1000" >> /etc/ssh/sshd_config
manage_etc_hosts: true
preserve_hostname: true
system_info:
  default_user:
    name: {username}
packages:
 - python
 - wget
 - git
 - ntp
final_message: "{up}, after $UPTIME seconds"
