dikaio
8/21/2016 - 2:12 PM

Cloud Init Example

Cloud Init Example

#cloud-config
package_upgrade: true
packages:
  - zsh
  - tmux
  - nmap
  - curl
  - wget
  - git
  - htop
  - iperf
  - fail2ban
  - vim
hostname: web01
fqdn: web01.example.com
users:
  - name: myuser
    groups: sudo
    shell: /bin/zsh
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    ssh-authorized-keys:
      - ssh-rsa AAAAB3NzaC... 
runcmd:
  - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
  - sed -i 's|[#]*PasswordAuthentication yes|PasswordAuthentication no|g' /etc/ssh/sshd_config
  - sed -i 's|UsePAM yes|UsePAM no|g' /etc/ssh/sshd_config
  - restart ssh
  - curl -L https://omnitruck.chef.io/install.sh | bash
final_message: "The system is finally up, after $UPTIME seconds"
# CentOS on Digital Ocean not working for some reason but Ubuntu 14.04 does
# cloud-init logs: /var/log/cloud-init.log and /var/log/cloud-init-output.log
# References:
# - https://cloudinit.readthedocs.io/en/latest/
# - https://help.ubuntu.com/community/CloudInit
# - https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/4/html/End_User_Guide/user-data.html
# - https://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/files/head:/doc/examples/