Home > Others > Ansible Playbook – Setup Zookeeper Using tarball.

Ansible Playbook – Setup Zookeeper Using tarball.

Ansible Playbook – Setup Zookeeper Using tarball.

This is a simple zookeeper playbook, to quickly start zookeeper running on a single or more nodes, in a clustered mode.
Here is the Script Location on Github: http://ift.tt/1KhoXzF
Below are the steps to get started.

Before we start.

Please download zookeeper-3.4.5-cdh5.1.2.tar.gz and store it in file_archives directory.**

Get the script from Github.

Below is the command to clone.
ahmed@ahmed-server ~]$ git clone http://ift.tt/1KhoXzF

Step 1. Update below variables as per requirement.

Variables are located in roles/zookeeper_install_tarball/default/main.yml.
# Zookeeper Version.
zookeeper_version: zookeeper-3.4.5-cdh5.1.2

# Zookeeper Storage and Logging.
zookeeper_data_store: /data/ansible/zookeeper
zookeeper_logging: /data/ansible/zookeeper_logging
Global Vars can be found in the location group_vars/all.
# --------------------------------------
# --------------------------------------

zookeeper_user: zkadmin
zookeeper_group: zkadmin
zookeeper_password: $6$rounds=40000$1qjG/hovLZOkcerH$http://ift.tt/1KhoXzH

# Common Location information.
  install_base_path: /usr/local
  soft_link_base_path: /opt

Step 2. User information come from global_vars.

Username can be changed in the Global Vars, zookeeper_user.
Currently the password is hdadmin@123
Password can be generated using the below python snippet.
# Password Generated using python command below.
python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.encrypt(getpass.getpass())"
Here is the execution. After entering the password you will get the encrypted password which can be used in the user creation.
ahmed@ahmed-server ~]$ python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.encrypt(getpass.getpass())"
Enter Password: *******
ahmed@ahmed-server ~]$

Step 3. Update playbook.

Update file called ansible_zookeeper.yml (if required) with hosts file in root of the directory structure.
Below is the sample directory structure.
  --> all
  --> zookeeper-3.4.5-cdh5.1.2.tar.gz
  --> ...
  --> zookeeper_install_tarball
  --> ...
Below are the contents for ansible_zookeeper.yml

- hosts: zookeepernodes
  remote_user: root
    - zookeeper_install_tarball
Steps used in zookeeper_install_tarball role.
  1. Create a user to running zookeeper service. NOTE: user information in global_vars.
  2. Copy tgz file and extract in destination.
  3. Changing permission to directory, setting zookeeper_user as the new owner.
  4. Creating Symbolic link. NOTE: soft_link_base_path information in global_vars.
  5. Updating Configuration File in Zookeeper.
  6. Creating directory for Zookeeper.
  7. Initializing myid file for Zookeeper.
  8. Starting Zookeeper Service.
Here are the contents of hosts file.
In hosts file zookeeper_id will be used to create an id in myid file, for each zookeeper running as a cluster.
# zookeeper cluster

[zookeepernodes] zookeeper_id=1 zookeeper_id=2 zookeeper_id=3

Step 4. Executing yml.

Execute below command.
ansible-playbook ansible_zookeeper.yml -i hosts --ask-pass

from Blogger http://ift.tt/1JWexlG

Categories: Others Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: