Skip to content

Instantly share code, notes, and snippets.

@phillhocking
Created July 14, 2021 04:41
Show Gist options
  • Save phillhocking/4a792c1c048b31479de05429313f2f29 to your computer and use it in GitHub Desktop.
Save phillhocking/4a792c1c048b31479de05429313f2f29 to your computer and use it in GitHub Desktop.
cloudinit.yml file for phillhocking/aws-ubuntu-tig repo
#cloud-config
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- git
# apt-get update, instantiate production TIG stack pinned to stable versions as of 7/13/2021
runcmd:
- apt-get update -y
- chown -R ubuntu:ubuntu /home/ubuntu
- bash /home/ubuntu/tig.sh
# Enable ipv4 forwarding, required on CIS hardened machines
write_files:
- path: /etc/sysctl.d/enabled_ipv4_forwarding.conf
content: |
net.ipv4.conf.all.forwarding=1
- path: /home/ubuntu/tig.sh
permissions: '0755'
owner: ubuntu:ubuntu
content: |
sudo apt update ; sudo apt install -y build-essential net-tools curl git
wget https://dl.influxdata.com/telegraf/releases/telegraf_1.19.1-1_amd64.deb
sudo dpkg -i telegraf_1.19.1-1_amd64.deb
sudo systemctl enable --now telegraf
wget https://dl.influxdata.com/influxdb/releases/influxdb_1.8.6_amd64.deb
sudo dpkg -i influxdb_1.8.6_amd64.deb
sudo systemctl enable --now influxdb
influx -execute 'create database telegraf'
influx -execute "create user telegraf with password 'ExAmPl3PA55W0rD'"
influx -execute 'grant all on telegraf to telegraf'
sudo apt install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_8.0.5_amd64.deb
sudo dpkg -i grafana_8.0.5_amd64.deb
sudo systemctl daemon-reload ; sudo systemctl enable --now grafana-server
sudo mv /etc/telegraf/telegraf.conf{,.old}
sudo -i
telegraf config -input-filter cpu:mem:swap:system:processes:disk -output-filter influxdb > /etc/telegraf/telegraf.conf
sudo cat << EOF >> /etc/telegraf/telegraf.conf
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
urls = ["http://127.0.0.1:8086"]
database = "telegraf"
username = "telegraf"
password = "ExAmPl3PA55W0rD"
EOF
sudo systemctl restart telegraf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment