heat_template_version: ocata

resources:

###################################################################################################
# NETWORKS
###################################################################################################

  soho_net:
    type: OS::Neutron::Net
    properties:
      name: soho_net

###################################################################################################
# SUBNETS
###################################################################################################

  # Single subnet implementation.
  # IP pools for soho: 192.168.0.0/24
  soho_subnet:
    type: OS::Neutron::Subnet
    depends_on: soho_net
    properties:
      name: soho_subnet
      cidr: 192.168.0.0/24
      dns_nameservers: [10.50.255.254,]
      network_id: { get_resource: soho_net }

#########################################################
# ROUTERS - one port & interface per subnet per router
#########################################################

  # SOHO ROUTER #########################################
  soho_router:
    type: OS::Neutron::Router
    properties:
      name: soho_router
      # External gateway added for internet access
      external_gateway_info: { network: public }

  soho_router_interface:
    type:  OS::Neutron::RouterInterface
    depends_on: soho_router
    properties:
      router_id: { get_resource: soho_router }
      subnet: { get_resource: soho_subnet }

###################################################################################################
# PORTS
###################################################################################################

  instance_port:
    type:  OS::Neutron::Port
    properties:
      network: { get_resource: soho_net }

###################################################################################################
# INSTANCES
###################################################################################################

  my_instance:
    type: OS::Nova::Server
    properties:
      name: my-comp
      image: Debian-Stretch
      flavor: cy.medium
      networks:
        - port: { get_resource: instance_port }
      user_data_format: RAW
      user_data: |
        #!/bin/bash
        echo "testtesttest1"
        # Establish root password
        echo "root:toor" | chpasswd
        echo "testtesttest2"
        # Establish a proximal proxy cache for faster downloads
        #PROXY_UP=`ping -c1 -W3 pkg-cache.bbh.cyberschool.army.mil >/dev/null 2>&1 ; echo $?`
        #if [ $PROXY_UP -lt 1 ]; then
            # Old (internal only): http://acng.bbh.cyberschool.army.mil:3142
        #    echo 'Acquire::http::proxy "http://pkg-cache.bbh.cyberschool.army.mil:3142";' > /etc/apt/apt.conf.d/02proxy
        #fi
        
        # Add Kali repo key to apt
        apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys 7D8D0BF6
        echo "testtesttest3"
        # Add Kali repos to source list
        echo deb http://http.kali.org/kali kali-rolling main contrib non-free >> /etc/apt/sources.list
        echo "testtesttest4"
        echo deb-src http://http.kali.org/kali kali-rolling main contrib non-free >> /etc/apt/sources.list
        echo "testtesttest5"
        
        # Get latest information from the repos
        apt-get -y update
        echo "testtesttest6"
        
        # Set non-interactive
        DEBIAN_FRONTEND=noninteractive
        echo "testtesttest7"
        
        # Preset configurations (for kali-linux-full and xfce)
        echo keyboard-configuration keyboard-configuration/variant "English (US)" | debconf-set-selections
        echo "testtesttest8"
        echo keyboard-configuration keyboard-configuration/layout "English (US)" | debconf-set-selections
        echo "testtesttest9"
        echo libc6/libraries libc6/libraries/restart-without-asking true | debconf-set-selections
        echo "testtesttest10"
        echo samba-common samba-common/dhcp false | debconf-set-selections
        echo "testtesttest11"
        echo macchanger macchanger/automatically_run false | debconf-set-selections
        echo "testtesttest12"
        echo wireshark-common wireshark-common/install-setuid false | debconf-set-selections
        echo "testtesttest13"
        echo kismet kismet/install-setuid true | debconf-set-selections
        echo "testtesttest14"
        echo kismet kismet/install-users "" | debconf-set-selections
        echo "testtesttest15"
        echo sslh sslh/inetd_or_standalone "standalone" | debconf-set-selections
        echo "testtesttest16"
        
        # Install desktop environment
        apt-get -y install kali-desktop-xfce 
        echo "testtesttest17"
        # Install Kali meta-package
        apt-get -y install kali-linux-full        # The Default Kali Linux Install
        echo "testtesttest18"
        # Upgrade old packages to the latest
        apt-get -y upgrade
        echo "testtesttest19"
        updatedb
        echo "testtesttest20"
        mandb
        echo "testtesttest21"
        reboot
        echo "testtesttest22"