forked from sleighzy/ansible-zookeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added functionality for installing and clustering multiple ZooKeepe…
…r nodes. This will now install ZooKeeper and configure clustering properties for all hosts listed in the “zookeeper-nodes” group by default. - Added checks for download and unpack to ensure role is idempotent. - Changed reload of systemd configuration to use a handler instead of task to ensure that the role is idempotent. - Added variable and configuration for the “dataLogDir” which allows disk separation between the snapshots and transactional logs. - Create Docker network and 3 containers to run cluster tests. The Ansible modules used for Docker require at least Ansible 2.2
- Loading branch information
Simon
authored and
Simon
committed
Mar 6, 2017
1 parent
26a8deb
commit 2dfb06f
Showing
9 changed files
with
198 additions
and
27 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ zookeeper_id }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
localhost | ||
zookeeper-1 ansible_host=zookeeper-1 ansible_connection=docker | ||
zookeeper-2 ansible_host=zookeeper-2 ansible_connection=docker | ||
zookeeper-3 ansible_host=zookeeper-3 ansible_connection=docker | ||
|
||
[zookeeper-nodes] | ||
zookeeper-1 zookeeper_id=1 | ||
zookeeper-2 zookeeper_id=2 | ||
zookeeper-3 zookeeper_id=3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,66 @@ | ||
--- | ||
|
||
- hosts: localhost | ||
remote_user: root | ||
# Set the python interpreter to use as we need to run commands from | ||
# the python virtualenv (/tmp/ansible-env) created below. | ||
# If this is not done then the host's python interpreter is used and | ||
# we will be using different versions of python packages than we require. | ||
vars: | ||
ansible_python_interpreter: /tmp/ansible-env/bin/python | ||
|
||
tasks: | ||
|
||
# Install docker-py required for the docker_network and docker_container modules. | ||
# This installs this in a virtualenv as the required version must be at minimum 1.7 | ||
# and due to a version matching bug 1.10 and above are evaluated as being less than 1.7. | ||
- name: Install docker-py | ||
pip: | ||
name: docker-py | ||
version: 1.9.0 | ||
virtualenv: /tmp/ansible-env | ||
|
||
# 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 | ||
roles: | ||
- java | ||
- ansible-zookeeper |