Skip to content

Instantly share code, notes, and snippets.

View tomwwright's full-sized avatar
🎯
Focusing

Tom Wright tomwwright

🎯
Focusing
View GitHub Profile
@tomwwright
tomwwright / ansibled:aurora:tasks:files:create-db-instance.json.j2
Created March 28, 2018 11:24
ansibled : aurora : tasks : aurora database instance
{
"DBInstanceIdentifier": "{{ aurora_db_name }}",
"DBInstanceClass": "{{ aurora_instance_type }}",
"Engine": "aurora-mysql",
"AvailabilityZone": "{{ aurora_availability_zone }}",
"DBSubnetGroupName": "{{ aurora_cluster_name }}-subnets",
"PreferredMaintenanceWindow": "mon:11:00-mon:11:30",
"MultiAZ": false,
"AutoMinorVersionUpgrade": true,
"LicenseModel": "general-public-license",
@tomwwright
tomwwright / ansibled:aurora:host_vars:dba.aurora.ansibled.yml
Created March 28, 2018 11:35
ansibled : aurora : inventory (cluster and instances), host vars for aurora instances
# host_vars/dba.aurora.ansibled.yml
# ---
# specific configuration for one of our Aurora DBs
aurora_cluster_name: ansibled-aurora-cluster
aurora_db_name: ansibled-aurora-a
aurora_instance_type: db.t2.small
aurora_availability_zone: "{{ aws_region }}a"
aurora_promotion_tier: 1
@tomwwright
tomwwright / ansibled:aurora:aurora.yml
Created March 28, 2018 11:39
ansibled : aurora : aurora playbook (cluster and instances)
# aurora.yml
# ---
# playbook that builds Aurora clusters and Aurora DB instances
# first run a play for any cluster hosts to create them
- hosts: aurora.cluster
environment:
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
AWS_REGION: "{{ aws_region }}"
@tomwwright
tomwwright / docker-compose.yml
Created July 30, 2018 05:42
ansibled:logentries:docker-compose
logentries-very-important-service:
container_name: logentries_very_important_service
image: logentries/docker-logentries
command: -t ${LOGENTRIES_VERY_IMPORTANT_SERVICE} --no-stats --matchByName very_important_service
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
@tomwwright
tomwwright / ansibled:logentries:group_vars:project.ansibled.yml
Created July 30, 2018 06:44
ansibled:logentries:group_vars:project.ansibled
# group_vars/project.ansibled.yml
# Logentries REST API key -- read/write
logentries_api_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
62336430323434343665653736376339333661356535336132326634353934356634666338316333
6264376536343862303962383638303037366634343137350a346364663835663964333136366330
37333564373232393966616164643539373534393761303332306438353562663434636466353431
3430373764336439330a386339636234323566653436393136313762356537343637326239356139
6332
@tomwwright
tomwwright / ansibled:logentries:tasks:main.yml
Created July 30, 2018 06:54
ansibled:logentries:tasks:main
# pull down the current state of our Logentries logs from the REST API
- name: retrieve Logsets info from Logentries
uri:
url: https://rest.logentries.com/management/logsets
headers:
x-api-key: "{{ logentries_api_key }}"
method: GET
return_content: yes
register: logentries_logsets_info
@tomwwright
tomwwright / ansibled:logentries:tasks:logs.create.yml
Last active July 30, 2018 06:58
ansibled:logentries:tasks:logs
# POST to Logentries and create the new log, note:
# - provide our API key in the `x-api-key` header
# - Logentries API responds with a 201, so that is a successful response (status_code)
# - provide our Logset id so that our new log will be created in it
- name: create Log in Logentries if it doesn't exist - {{ item }}
uri:
url: https://rest.logentries.com/management/logs
headers:
x-api-key: "{{ logentries_api_key }}"
method: POST
@tomwwright
tomwwright / ansibled:logentries:docker-compose-env-example.yml
Last active July 30, 2018 07:08
ansibled : logentries : docker compose env example
- name: add each Logentries token to Docker Compose .env settings
lineinfile:
dest: "{{ docker_compose_directory }}/.env"
regexp: "^LOGENTRIES_{{ item.key | upper }}=.*"
line: "LOGENTRIES_{{ item.key | upper }}={{ item.value }}"
create: yes
with_dict : "{{ logentries_log_tokens }}"
- hosts: localhost
tasks:
- name: create an S3 bucket -- we'll see this one is 'changed'
s3_bucket:
name: mysupercoolexamplebucket
region: ap-southeast-2
state: present
- hosts: localhost
vars:
aurora_cluster_name: mycoolauroracluster
aurora_cluster_engine: aurora-mysql
aurora_cluster_version: 5.7.12
aws_region: ap-southeast-2
tasks:
- name: create Aurora Cluster with the AWS CLI
command: >