Skip to content

Instantly share code, notes, and snippets.

@tom-butler
Created August 20, 2017 23:59
Show Gist options
  • Save tom-butler/dc88baef6ff1d4f34fd8d71f2bb1e49c to your computer and use it in GitHub Desktop.
Save tom-butler/dc88baef6ff1d4f34fd8d71f2bb1e49c to your computer and use it in GitHub Desktop.
goss implementation
*/5 * * * * cd /opt/healthz && /bin/echo "`date +'\%Y-\%m-\%dT\%H:\%M:\%SZ'` `/usr/local/bin/goss validate -f nagios_verbose`" >> healthz.log
package:
apache2:
installed: true
service:
apache2:
enabled: true
running: true
tomcat8:
enabled: true
running: true
ufw:
enabled: true
running: true
command:
sudo ufw status verbose:
# required attributes
exit-status: 0
# optional attributes
stdout:
- /22 +ALLOW IN/
- /8080 +ALLOW IN/
- /8005 +DENY IN/
file:
/etc/fstab:
exists: true
contains:
- /tmpfs +\/run\/shm +tmpfs +defaults,noexec,nosuid +0 +0/
/etc/logrotate.d/tomcat8:
exists: true
contains:
- size 5M
- rotate 14
/etc/logrotate.d/apache2:
exists: true
contains:
- size 5M
- rotate 14
/usr/share/tomcat8/bin/setenv.sh:
exists: true
contains:
- -Xms256m
- -Xmx1024m
/opt/aws-scripts-mon/mon-put-instance-data.pl:
exists: true
#!/bin/bash
#Put this in your packer to install and run gossfile on packer build.
# Install goss for testing
# See https://github.com/aelsabbahy/goss/releases for release versions
sudo curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.2/goss-linux-amd64 -o /usr/local/bin/goss
sudo chmod +rx /usr/local/bin/goss
sudo mkdir /opt/healthz
sudo chown ubuntu:ubuntu /opt/healthz
cp /tmp/files/goss.yaml /opt/healthz
cd /opt/healthz
# Run tests
goss validate
cd /opt/healthz
# let the elb monitor health
nohup goss serve -f nagios_verbose 2> /dev/null &
@tom-butler
Copy link
Author

tom-butler commented Aug 21, 2017

goss.yaml file is pushed to the /tmp directory by packer (also seperate)

I install and run goss during the packer build to validate the build worked

The userdata.sh creates a background process to serve the goss healthcheck to the elb. (:8080/healthz is default)
You will need to open ELB security groups and point a HTTP check to :8080/healthz

crontab is used to create a logfile of the goss tests (I send them to cloudwatch logs separately) So when it falls over you can check why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment