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:hosts.inventory
Created March 28, 2018 11:16
ansibled : aurora : inventory (cluster)
# hosts.inventory
# ---
# the host and group list for this example "Ansibled" project
[elasticsearch]
big.elasticsearch.ansibled
small.elasticsearch.ansibled
[aurora.cluster]
cluster.aurora.ansibled
@tomwwright
tomwwright / ansibled:aurora:aurora.yml
Last active March 28, 2018 11:07
ansibled : aurora : inventory (cluster), group vars for Aurora clusters, host vars for example cluster, playbook
# 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 / ansibled:aurora:tasks:cluster.yml
Last active March 28, 2018 11:12
ansibled : aurora : tasks : setup cluster
# tasks/auroradb/setup.cluster.yml
# ---
# check if an Aurora DB cluster exists, and create it if it doesn't. Then update the VPC DNS
# look for an existing Aurora DB cluster for this host using the AWS CLI
- name: check for Aurora DB cluster
command: aws rds describe-db-clusters --filters Name=db-cluster-id,Values={{ aurora_cluster_name }} --region {{ aws_region }}
changed_when: false
register: aurora_cluster_query
@tomwwright
tomwwright / ansibled:aurora:tasks:parameter-group.yml
Last active March 28, 2018 10:18
ansibled : aurora : tasks : subnet group and default parameter group
# tasks/aurora/setup.parameter-group.yml
# ---
# use the AWS CLI to create a (default) parameter group for Aurora clusters
# list existing cluster parameter groups using the AWS CLI
- name: check for DB cluster parameter group
command: >
aws rds describe-db-cluster-parameter-groups
--no-paginate
--region {{ aws_region }}
@tomwwright
tomwwright / ansible:es:elasticsearch.yml
Last active March 19, 2018 11:42
ansible : elasticsearch : elasticsearch playbook
# elasticsearch.yml
# ---
# playbook that builds elasticsearch clusters: run our facts tasks for the VPC
# to define some necessary details, then run the setup tasks
- hosts: elasticsearch
environment:
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
AWS_REGION: "{{ aws_region }}"
@tomwwright
tomwwright / ansible:es:group_vars:elasticsearch.yml
Last active March 19, 2018 10:55
ansibled : es : group_vars : elasticsearch
# group_vars/elasticsearch.yml
# ---
# specify defaults for our Elasticsearch clusters
elasticsearch_version: 6.0
elasticsearch_instance_type: r4.large
elasticsearch_instance_count: 3
elasticsearch_dedicated_masters_enabled: false
@tomwwright
tomwwright / ansibled:es:hosts.inventory
Last active March 28, 2018 10:23
ansibled : es : hosts.inventory
# hosts.inventory
# ---
# the host and group list for this example "Ansibled" project
[elasticsearch]
big.elasticsearch.ansibled
small.elasticsearch.ansibled
[vpc]
vpc.ansibled
@tomwwright
tomwwright / ansibled:es:tasks:files:create-elasticsearch-domain.json.j2
Created March 19, 2018 09:44
ansibled : elasticsearch : tasks : setup cluster : configuration templates
{
"DomainName": "{{ elasticsearch_name }}",
"ElasticsearchVersion": "{{ elasticsearch_version }}",
"ElasticsearchClusterConfig": {
"InstanceType": "{{ elasticsearch_instance_type }}",
"InstanceCount": {{ elasticsearch_instance_count }},
"ZoneAwarenessEnabled": {{ (elasticsearch_instance_count == 1) | ternary('false', 'true') }},
"DedicatedMasterEnabled": {{ elasticsearch_dedicated_masters_enabled | lower }},
{% if elasticsearch_dedicated_masters_enabled %}
"DedicatedMasterType": "{{ elasticsearch_dedicated_masters_type }}",
@tomwwright
tomwwright / ansibled:es:tasks:setup.cluster.yml
Created March 19, 2018 09:42
ansibled : elasticsearch : tasks : setup cluster
# tasks/elasticsearch/setup.cluster.yml
# ---
# look up our Elasticsearch cluster, create it if necessary, wait for it to be
# available, then update the DNS record for it in Route 53
# use the AWS CLI to query for details about this cluster, if it exists
- name: check for existing Elasticsearch cluster
command: aws es describe-elasticsearch-domains --region {{ aws_region }} --domain-names {{ elasticsearch_name }}
changed_when: false
register: elasticsearch_cluster_query
@tomwwright
tomwwright / ansibled:es:tasks:setup.role.yml
Created March 19, 2018 09:40
ansibled : elasticsearch : tasks : setup role
# tasks/elasticsearch/setup.role.yml
# ---
# create the service-linked IAM role used by AWS Elasticsearch Service
# use the AWS CLI to retrieve a list of our IAM roles, store it in a variable
# using `register`
- name: list existing IAM roles
command: aws iam list-roles --no-paginate
changed_when: false
register: list_iam_roles