Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
116 lines (109 sloc) 3.87 KB
---
- 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: "{{ ec2.zk_spot_price }}"
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 }} instance_type={{ item.1.instance_type }}
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: Install JDK on Zookeeper instances
hosts: zookeepernodes
remote_user: ubuntu
become: true
become_method: sudo
gather_facts: yes
roles:
- jdk
- name: Install and start Zookeeper
hosts: zookeepernodes
remote_user: ubuntu
become: true
become_method: sudo
gather_facts: yes
roles:
- zookeeper
- name: Create EC2 instances for Kafka brokers
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Launch instances
ec2:
key_name: "{{ ec2.key }}"
group: "{{ ec2.kafka_security_group }}"
instance_type: "{{ ec2.kafka_instance_type }}"
image: "{{ ec2.image }}"
wait: yes
region: "{{ ec2.region }}"
count: "{{ ec2.kafka_instance_count }}"
spot_price: "{{ ec2.kafka_spot_price }}"
spot_wait_timeout: 600
monitoring: yes
volumes:
- device_name: /dev/sdb
volume_type: io1
iops: 1000
volume_size: 100
delete_on_termination: true
register: kafkainstances
- name: Add new instances to a host group
add_host: name={{ item.1.public_dns_name }} groups=kafkanodes broker_id={{ item.0 + 1 }}
with_indexed_items: "{{ kafkainstances.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: "{{ kafkainstances.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: "{{ kafkainstances.instances }}"
register: k_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: "{{ k_ssh_known_host_results.results }}"
when: item.stdout == ""
- name: Configure file system and install JDK on Kafka instances
hosts: kafkanodes
remote_user: ubuntu
become: true
become_method: sudo
gather_facts: yes
roles:
- makefs
- jdk
- name: Install and start Kafka
hosts: kafkanodes
remote_user: ubuntu
become: true
become_method: sudo
gather_facts: yes
roles:
- kafka