Skip to content

Instantly share code, notes, and snippets.

View pgporada's full-sized avatar
🕵️‍♂️
PKEye

Phil Porada pgporada

🕵️‍♂️
PKEye
View GitHub Profile
variable "env" {}
variable "instance_type" {}
variable "bastion_key_name" {}
variable "bastion_key_path" {}
variable "vpc_id" {}
variable "vpc_cidr" {}
variable "peered_vpc_cidr" {}
variable "subnet_ids" {}
variable "shell_username" {}
variable "public_zone_id" {}
@pgporada
pgporada / init.sh user_data script
Created January 25, 2017 21:21
terraform creating user_data for a server
#!/bin/bash
set -x
# Ensure dependencies are installed
yum install -y epel-release
yum update -y epel-release
yum install -y python-pip python-devel git openssl-devel libffi-devel
pip install --upgrade pip
pip install --upgrade setuptools
yum install -y awscli python-six ansible
---
mysql_build_cluster: false
mysql_verify_cluster: false
# It's always
mysql_
mysql_
mysql_
# It's never about MEsql
...
@pgporada
pgporada / gist:b846eb500db636a3a5f3118b1bea9463
Last active February 9, 2017 14:36
ASG + Launch Config
data "template_file" "kibana" {
template = "${file("${path.module}/init.sh")}"
vars {
TERRAFORM_env = "${var.env}"
TERRAFORM_user = "${var.shell_username}"
TERRAFORM_role = "kibana"
}
}
resource "aws_iam_role_policy" "instance_policy" {
name = xxxxxxx
role = "${aws_iam_role.instance_role.id}"
policy = xxxxxxx
# Allows the IAM role enough time to propagate through AWS
provisioner "local-exec" {
command = <<EOT
echo "Sleeping for 10 seconds to allow the IAM role enough time to propagate through AWS";
sleep 10;
@pgporada
pgporada / bats
Created February 21, 2017 04:06
Testing examples
#!/usr/bin/env bats
@test "Kibana is installed" {
run rpm -q kibana
[ "$status" -eq 0 ]
}
@test "Kibana is running" {
run systemctl is-active kibana
[ "$status" -eq 0 ]
@pgporada
pgporada / serverspec.sh
Created February 21, 2017 04:11
Script to run against a packer image
$ cat scripts/serverspec.sh
#!/bin/bash
# WHAT: Run serverspec tests that Packer copies up to the server. You'll need a ruby environment with bundler and gem.
cd /tmp/tests
/usr/local/bin/bundler install --no-deployment
/usr/local/bin/bundler exec rake spec
cd /tmp
rm -rf /tmp/tests
/*
other configs go here
*/
resource "aws_security_group" "elb" {
name = "${var.env}-${var.tier}-elasticsearch-elb-sg"
vpc_id = "${var.vpc_id}"
description = "Allow http and https inbound traffic through the ELB."
tags {
---
- name: Give 50% of all memory to the JVM
set_fact:
elasticsearch_java_initial_heap_size: "{{ (2|pow(((ansible_memtotal_mb|log(2))|round|int)) * 0.50)|int }}m"
elasticsearch_java_maximum_heap_size: "{{ (2|pow(((ansible_memtotal_mb|log(2))|round|int)) * 0.50)|int }}m"
...
@pgporada
pgporada / gist:817a1258a8ea60cc9750b6ae4edf20ff
Created March 3, 2017 18:28
Using rkt to run containers
$ sudo rkt --insecure-options=image run docker://redis
stage1: warning: no volume specified for mount point "volume-data", implicitly creating an "empty" volume. This volume will be removed when the pod is garbage-collected.
stage1: Docker converted image, initializing implicit volume with data contained at the mount point "volume-data".
stage1: warning: no volume specified for mount point "volume-data", implicitly creating an "empty" volume. This volume will be removed when the pod is garbage-collected.
stage1: Docker converted image, initializing implicit volume with data contained at the mount point "volume-data".
[20030.471072] redis[5]: 5:C 03 Mar 18:14:10.858 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[20030.471791] redis[5]: 5:M 03 Mar 18:14:10.859 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[20030.472056] redis[5]: 5:M 03 Mar 18:14:10.859 # Server can't set maximum open fil