forked from sleighzy/ansible-zookeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.yaml
55 lines (50 loc) · 1.74 KB
/
test.yaml
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
---
- hosts: localhost
tasks:
# Create a Docker network that the containers will connect to. This will enable the
# containers to be able to see and access each other.
# This requires Ansible 2.2 for this docker_network module.
- name: Create Docker network
docker_network:
name: zookeeper
ipam_options:
subnet: '172.25.0.0/16'
# The centos/systemd image used to create these containers is required so
# that systemd is available. This is used for the systemctl commands to
# install and run the zookeeper services for this role. The privileged container
# and "/sys/fs/cgroup" volume mount is also requird for systemd support.
# Port 2181 is exposed as the ZooKeeper port.
# The container needs to be started with the "/usr/lib/systemd/systemd" so that
# this service is initialized.
- name: Create Docker containers
docker_container:
name: '{{ item.1 }}'
hostname: '{{ item.1 }}'
image: centos/systemd
state: started
privileged: yes
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
networks:
- name: zookeeper
ipv4_address: 172.25.10.{{ item.0 + 1 }}
purge_networks: yes
exposed_ports:
- 2181
- 2888
- 3888
etc_hosts:
zookeeper-1: 172.25.10.1
zookeeper-2: 172.25.10.2
zookeeper-3: 172.25.10.3
command: /usr/lib/systemd/systemd
with_indexed_items: "{{ groups['zookeeper-nodes'] }}"
# Install Java and ZooKeeper on all nodes.
- hosts: zookeeper-nodes
pre_tasks:
- name: Install Java 8 (OpenJDK)
yum:
name: java-1.8.0-openjdk
state: installed
roles:
- ansible-zookeeper