#!/bin/bash
curl -L -o /tmp/kibana-5.6.6-amd64.deb https://artifacts.elastic.co/downloads/kibana/kibana-5.6.6-amd64.deb
dpkg -i /tmp/kibana-5.6.6-amd64.deb
echo 'elasticsearch.url: "http://${es_elb}:9200"' > /etc/kibana/kibana.yml
echo 'server.host: "127.0.0.1"' >> /etc/kibana/kibana.yml

systemctl stop kibana || true
systemctl start kibana

echo "twitch_environment=${puppet_environment}" > /etc/facter/facts.d/twitch_environment.txt
echo "twitch_role=${puppet_twitch_role}" > /etc/facter/facts.d/twitch_role.txt
echo "cluster=${puppet_cluster}" > /etc/facter/facts.d/cluster.txt
echo "clean=true" > /etc/facter/facts.d/clean.txt
echo "twitch_team=systems" > /etc/facter/facts.d/twitch_team.txt
puppet agent --test --server=puppet.internal.justin.tv
