Skip to content

Commit

Permalink
Feature/cql box (#28)
Browse files Browse the repository at this point in the history
* added cql-box

* fixed sudo rights in cql-box tasks

* updated cassandra version in cql-box

* Simplified setting up the cql box

* added cql-box to travis
  • Loading branch information
gerbenoostra authored and stefanvanwouw committed Dec 20, 2016
1 parent e260762 commit ef6f33c
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ env:
inventory: example-inventory/dev
working_dir: search-box
IP: 10.0.0.21
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro
playbook: provision.yml
inventory: example-inventory/dev
working_dir: cql-box
IP: 10.0.0.45
services:
- docker
before_install:
Expand Down
15 changes: 15 additions & 0 deletions cql-box/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CQL box

Here we provide an easy setup of a small 3 node cassandra cluster on a centos/7 box using vagrant and ansible.

With the currently used centos/7 base box, we faced some issues with the installation of the guest additions on it.
This failed, such that the ansible directory could not be mounted in the guest os, such that we couldn't provision the box using ansible.

We've worked around it using a simple `yum update`, but it does require multiple `vagrant provision` and a `vagrant reload` call.

TLDR;
To get a centos box with a 3 node cassandra cluster on it, just run

```bash
./vagrant_start.sh
```
35 changes: 35 additions & 0 deletions cql-box/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# required: vagrant plugin install vagrant-vbguest
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.box_version = "<=1608.02"
config.ssh.insert_key = false
config.vbguest.auto_update = true

config.vm.provision "shell", inline: "sudo yum update -y && sudo yum install -y kernel-devel"
config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "provision.yml"
ansible.inventory_path = "example-inventory/dev"
ansible.provisioning_path = "/vagrant/cql-box"
ansible.raw_arguments = ['-u vagrant']
end

config.vm.synced_folder "..", "/vagrant", type: "virtualbox"

#config.vm.network :forwarded_port, guest: 22, host: 2223

config.vm.define "bdr-cql-box", autostart: true do |vm|
vm.vm.hostname = "cql-box"
vm.vm.network "private_network", ip: "10.0.0.45"
# to mount other folders: vm.vm.synced_folder "../../", "/home/vagrant/projects", :mount_options => ["dmode=644,fmode=644"]

# Provision virtualbox:
vm.vm.provider "virtualbox" do |vb|
vb.memory = 5096
vb.cpus = 4
vb.customize ["modifyvm", :id, "--usb", "off"]
vb.customize ["modifyvm", :id, "--usbehci", "off"]
end
end


end
2 changes: 2 additions & 0 deletions cql-box/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
roles_path = network:platform:components:../common/network:../common/platform:../common/components
4 changes: 4 additions & 0 deletions cql-box/components/cql/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
cql_version: 3.0.0
cql_nodecount: 3
cql_clustername: test
25 changes: 25 additions & 0 deletions cql-box/components/cql/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---

- name: Ensure Java 8 is installed
package: name=java-1.8.0-openjdk state=present
become: yes

- name: Get latest ccm version
become: yes
git:
repo: https://github.com/pcmanus/ccm.git
dest: ~/checkouts/ccm
update: no

- name: Install ccm
become: yes
command: ./setup.py install
args:
chdir: ~/checkouts/ccm
creates: /usr/bin/ccm

- name: Initiate cluster
command: "ccm create --version {{cql_version}} --nodes {{cql_nodecount}} --start {{cql_clustername}}"
args:
creates: "~/.ccm/{{cql_clustername}}"

7 changes: 7 additions & 0 deletions cql-box/example-inventory/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bdr-cql-box ansible_connection=local advertised_host=10.0.0.45

[bdr-cql-box]
bdr-cql-box

[cql]
bdr-cql-box
12 changes: 12 additions & 0 deletions cql-box/provision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- hosts: all
become: yes
roles:
- repositories
tasks:
- package: name=python-pip state=present
- package: name=git state=present

- hosts: cql
roles:
- cql
7 changes: 7 additions & 0 deletions cql-box/vagrant_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# sets up the vagrant box, working around failing guest additions cuasing failed mapped folders
vagrant plugin install vagrant-vbguest && \
vagrant up && \
vagrant provision --provision-with shell && \
vagrant reload && \
vagrant provision --provision-with ansible_local

0 comments on commit ef6f33c

Please sign in to comment.