-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-docker.yml
69 lines (59 loc) · 1.97 KB
/
create-docker.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Provision single docker node on Ubuntu
ec2:
key_name: misko
instance_type: '{{ item.type }}'
region: ap-southeast-2
image: ami-623c0d01
wait: yes
group: launch-wizard-1
count: 1
vpc_subnet_id: subnet-583d681e
assign_public_ip: yes
instance_tags:
hostname: '{{ item.hostname }}'
tags: '{{ item.tags }}'
with_items:
- { type: 't2.large', hostname: 'docker-1', tags: 'docker' }
register: ec2
- name: Add new instance(s) to host group
add_host: hostname={{ item.public_ip }} groupname=just-launched-docker
with_items: '{{ec2.results[0].instances}}'
- name: Create persistent storage volumes
ec2_vol:
instance: '{{ item[1] }}'
volume_size: 5
device_name: '{{ item[0] }}'
region: ap-southeast-2
with_nested:
- [sdd,sde,sdf]
- '{{ec2.results[0].instance_ids}}'
- name: Wait for SSH on the machine
local_action: wait_for port=22 host="{{ item.public_ip }}" search_regex=OpenSSH delay=10
with_items: '{{ec2.results[0].instances}}'
- name: Nasty hack to enable Ansible
shell: "ssh -o StrictHostKeyChecking=no ubuntu@{{item.public_ip}} sudo apt-get -y install python"
with_items: '{{ec2.results[0].instances}}'
- hosts: just-launched-docker
become: yes
tasks:
- name: create filesystem on volumes
filesystem: fstype=ext4 dev=/dev/{{item}}
with_items: [xvdd,xvde,xvdf]
- name: mount devices
mount: name=/mnt/kafka{{item.number}} src=/dev/{{item.device}} fstype=ext4 state=mounted
with_items:
- {number: 1, device: "xvdd"}
- {number: 2, device: "xvde"}
- {number: 3, device: "xvdf"}
- hosts: just-launched-docker
become: yes
roles:
- docker
- hosts: just-launched-docker
become: yes
roles:
- docker-kafka