# Clone Debian Stretch template, set up IPs, hostname, ssh keys
apt update
apt -y dist-upgrade

##############################################################################
# Install Elasticsearch version 5
# Graylog 2 can only use Elasticsearch 5, not latest version 6
# Get key
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
# Install deps (should be installed already):
apt-get -y install apt-transport-https
# Set up repo for previous release 5.x (current is 6.x).
# Graylog 2 only works with 5.x. Graylog 3, due in 2018, works with elasticsearch 6.x

echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-5.x.list

# Disable apt-cache in /etc/apt/apt.conf, it doesn't work with https
apt update
apt install openjdk-8-jre-headless
apt install elasticsearch

# Configure a cluster name and answer on IP.
# Open firewall
# Allow elasticsearch
-A INPUT -p tcp --dport 9200 -j ACCEPT
-A INPUT -p tcp --dport 9300 -j ACCEPT

# Start on boot:
systemctl enable elasticsearch.service

### XXX Backups
### XXX Prometheus :)

##############################################################################
