Last active
May 23, 2016 15:26
-
-
Save meconlin/8efefb5362ffa46e46f8d1b1708908f1 to your computer and use it in GitHub Desktop.
This file contains 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
--- | |
- name: provision 3 instances for ES | |
hosts: localhost | |
connection: local | |
gather_facts: false | |
strategy: free | |
vars: | |
instance_name: "bcd2-elasticsearch" | |
aws_region: "{{ gg_aws_region }}" | |
tasks: | |
- include: ../common_tasks/scale_instance.yml | |
vars: | |
key_name: "prod_keypair" | |
type: "r3.xlarge" # 4 cores / 30.5 mem / 1 x 80 GB SSD | |
#type: "r3.2xlarge" # 8 cores / 61 mem / 1 x 160 GB SSD | |
#image: "ami-d00f15ba" # non HVM image | |
image: "ami-9a657ff0" # HVM image GoldenImage-2016-04-25-HVM | |
group: [ "ansible-bcd2-es", ] | |
region: "{{ gg_aws_region }}" | |
name: "{{ instance_name }}" | |
volumes: # these settings need to match the capabilities of your instance type selected above | |
- device_name: /dev/xvdb | |
device_type: standard | |
volume_size: 80 | |
ephemeral: ephemeral0 | |
with_items: | |
- { subnet: "{{ subnets.Prod_1c.id }}", count: 1 } | |
- { subnet: "{{ subnets.Prod_1d.id }}", count: 1 } | |
- { subnet: "{{ subnets.Prod_1e.id }}", count: 1 } | |
- name: prepare ansible list of hosts | |
add_host: hostname={{ item.private_dns_name }} groups="{{ instance_name }}" | |
with_items: "{{ ec2_instances.instances }}" | |
when: | |
ec2_instances | |
tags: provision | |
- name: mount additional volumes | |
hosts: "{{ instance_name }}" | |
become: true | |
strategy: free | |
tasks: | |
- include: ../common_tasks/ec2_volumes.yml | |
vars: | |
mountpoints: | |
xvdb: | |
dev: /dev/xvdb | |
point: /data0 | |
vars: | |
instance_name: "bcd2-elasticsearch" | |
tags: provision | |
- name: configure instances | |
hosts: "{{ instance_name }}" | |
become: true | |
gather_facts: true | |
strategy: free | |
pre_tasks: | |
- include: ../common_tasks/pre_tasks.yml | |
tags: always | |
roles: | |
- {name: common, tags: common} | |
- {name: java, tags: java, java_version: 8} | |
- {name: elasticsearch, tags: elasticsearch, es_data_dirs: "/data0/elasticsearch", es_instance_name: "es-master", | |
es_config: "{{ lookup('template', 'vars/es_master.j2')| from_yaml }}" | |
} | |
- {name: elasticsearch, tags: elasticsearch, es_data_dirs: "/data0/elasticsearch", es_instance_name: "es-data", | |
es_config: "{{ lookup('template', 'vars/es_data.j2')| from_yaml }}" | |
} | |
- {name: nginx, tags: nginx, nginx_config_path: templates/nginx-elasticsearch.j2, nginx_config_name: nginx-elasticsearch.conf} | |
tasks: | |
- name: add instances to ELB | |
ec2_elb: | |
instance_id: "{{ instance_info.ansible_facts.ansible_ec2_instance_id }}" | |
ec2_elbs: "bcd2-elasticsearch-elb" | |
state: present | |
aws_access_key: "{{ aws_access_key }}" | |
aws_secret_key: "{{ aws_secret_key }}" | |
region: us-east-1 | |
tags: elb | |
vars: | |
instance_name: "bcd2-elasticsearch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment