This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hosts.inventory | |
# --- | |
# the host and group list for this example "Ansibled" project | |
[elasticsearch] | |
big.elasticsearch.ansibled | |
small.elasticsearch.ansibled | |
[aurora.cluster] | |
cluster.aurora.ansibled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hosts.inventory | |
# --- | |
# the host and group list for this example "Ansibled" project | |
[elasticsearch] | |
big.elasticsearch.ansibled | |
small.elasticsearch.ansibled | |
[vpc] | |
vpc.ansibled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 }}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |