forked from milinda/KafkaOnEC2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zookeeper.yml
46 lines (44 loc) · 1.63 KB
/
zookeeper.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
- name: Create EC2 instances for Zookeeper
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Launch instances
ec2:
key_name: "{{ ec2.key }}"
group: "{{ ec2.zookeeper_security_group }}"
instance_type: "{{ ec2.zookeeper_instance_type }}"
image: "{{ ec2.image }}"
wait: yes
region: "{{ ec2.region }}"
count: "{{ ec2.zookeeper_instance_count }}"
spot_price: 0.2
spot_wait_timeout: 600
register: zookeeperinstances
- name: Add new instances to a host group
add_host: name={{ item.1.public_dns_name }} groups=zookeepernodes zid={{ item.0 + 1 }} private_ip={{ item.1.private_ip }}
with_indexed_items: zookeeperinstances.instances
- name: Wait for SSH to come up
wait_for: host={{ item.public_dns_name }} port=22 delay=60 timeout=360 state=started
with_items: zookeeperinstances.instances
- name: Make sure the known hosts file exists
file: "path={{ ssh_known_hosts_file }} state=touch"
- name: Check host name availability
shell: "ssh-keygen -f {{ ssh_known_hosts_file }} -F {{ item.public_dns_name }}"
with_items: zookeeperinstances.instances
register: z_ssh_known_host_results
ignore_errors: yes
- name: Scan the public key
shell: "{{ ssh_known_hosts_command}} {{ item.item.public_dns_name }} >> {{ ssh_known_hosts_file }}"
with_items: z_ssh_known_host_results.results
when: item.stdout == ""
- name: Configure Zookeeper instances
hosts: zookeepernodes
remote_user: ubuntu
become: yes
become_method: sudo
gather_facts: yes
roles:
- jdk
- collectd