diff --git a/.travis.yml b/.travis.yml index 99418a5..bd77029 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/cql-box/README.md b/cql-box/README.md new file mode 100644 index 0000000..7cd7971 --- /dev/null +++ b/cql-box/README.md @@ -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 +``` \ No newline at end of file diff --git a/cql-box/Vagrantfile b/cql-box/Vagrantfile new file mode 100755 index 0000000..c8e3cc7 --- /dev/null +++ b/cql-box/Vagrantfile @@ -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 diff --git a/cql-box/ansible.cfg b/cql-box/ansible.cfg new file mode 100644 index 0000000..33d5ce6 --- /dev/null +++ b/cql-box/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +roles_path = network:platform:components:../common/network:../common/platform:../common/components diff --git a/cql-box/components/cql/defaults/main.yml b/cql-box/components/cql/defaults/main.yml new file mode 100644 index 0000000..ba0b044 --- /dev/null +++ b/cql-box/components/cql/defaults/main.yml @@ -0,0 +1,4 @@ +--- +cql_version: 3.0.0 +cql_nodecount: 3 +cql_clustername: test diff --git a/cql-box/components/cql/tasks/main.yml b/cql-box/components/cql/tasks/main.yml new file mode 100644 index 0000000..e149c27 --- /dev/null +++ b/cql-box/components/cql/tasks/main.yml @@ -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}}" + diff --git a/cql-box/example-inventory/dev b/cql-box/example-inventory/dev new file mode 100644 index 0000000..0497cf0 --- /dev/null +++ b/cql-box/example-inventory/dev @@ -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 diff --git a/cql-box/provision.yml b/cql-box/provision.yml new file mode 100755 index 0000000..831143d --- /dev/null +++ b/cql-box/provision.yml @@ -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 diff --git a/cql-box/vagrant_start.sh b/cql-box/vagrant_start.sh new file mode 100755 index 0000000..4e7d0c3 --- /dev/null +++ b/cql-box/vagrant_start.sh @@ -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 \ No newline at end of file