The following command will create a cassdb cluster using ansible.
#####
---
- hosts: all
tasks:
- name: coping the file to all the docker server
template: src=cassandra.yaml.j2 dest=/tmp/cassandra.yaml
- name: running some command
raw: sudo docker run -i -t -d --name cassdb --net host -v /cassdata:/var/lib/cassandra cassdb /bin/bash; containerID=`sudo docker inspect -f '{{.Id}}' cassdb`; sudo cp /tmp/cassandra.yaml /var/lib/docker/aufs/mnt/$containerID/etc/cassandra/cassandra.yaml; sudo docker exec cassdb rm -rf /var/lib/cassandra/*; sudo docker exec cassdb /etc/init.d/cassandra start
#####
command would be:
ansible-playbook docker-inventory_hosts install_cassandra_playbook.yml
########
NOTE: Following is the variable that I have added in the "cassandra.yaml.j2" file, that need to be interpolated, dynamically.
cluster_name: {{ cluster_name }}
- seeds: {{ hostvars[groups['docker-akamai'][0]]['ansible_eth0']['ipv4']['address'] }}
listen_address: {{ ansible_default_ipv4.address }}
broadcast_rpc_address: {{ ansible_default_ipv4.address }}
### my cassdb docker image:
docker pull amitmund/cassdb:latest
#######
$ sudo docker exec cassdb nodetool status
Note: Ownership information does not include topology; for complete information, specify a keyspace
Datacenter: BLR
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns Host ID Rack
UN 192.168.1.10 54.93 KB 256 37.4% e7915e97-babf-49fd-bcdf-4434b4443fba R1
UN 192.168.1.11 261.03 KB 256 32.7% a0589928-f5eb-496f-8456-5018fabb75ca R1
UN 192.168.1.12 169.35 KB 256 29.9% 219d1439-fd0d-4ea9-ae03-4d25fe0334fc R1