From 368f174d8fa540be8c4aa9812924b042b8200b47 Mon Sep 17 00:00:00 2001 From: Gerben Oostra Date: Tue, 13 Dec 2016 20:47:21 +0100 Subject: [PATCH 1/5] added cql-box --- cql-box/Vagrantfile | 35 ++++++++++++++++++++++++ cql-box/ansible.cfg | 2 ++ cql-box/components/cql/defaults/main.yml | 4 +++ cql-box/components/cql/tasks/main.yml | 23 ++++++++++++++++ cql-box/example-inventory/dev | 7 +++++ cql-box/provision.yml | 12 ++++++++ 6 files changed, 83 insertions(+) create mode 100755 cql-box/Vagrantfile create mode 100644 cql-box/ansible.cfg create mode 100644 cql-box/components/cql/defaults/main.yml create mode 100644 cql-box/components/cql/tasks/main.yml create mode 100644 cql-box/example-inventory/dev create mode 100755 cql-box/provision.yml 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..2a2f8fe --- /dev/null +++ b/cql-box/components/cql/defaults/main.yml @@ -0,0 +1,4 @@ +--- +cql_version: 1.2.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..057252b --- /dev/null +++ b/cql-box/components/cql/tasks/main.yml @@ -0,0 +1,23 @@ +--- + +- name: Ensure Java 8 is installed + package: name=java-1.8.0-openjdk state=present + become: yes + +- name: Get latest ccm version + git: + repo: https://github.com/pcmanus/ccm.git + dest: ~/checkouts/ccm + update: no + +- name: Install ccm + 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 From 78f79e2901f2d2675d094f77b756f8d0941cca1a Mon Sep 17 00:00:00 2001 From: Gerben Oostra Date: Tue, 13 Dec 2016 22:24:31 +0100 Subject: [PATCH 2/5] fixed sudo rights in cql-box tasks --- cql-box/components/cql/tasks/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cql-box/components/cql/tasks/main.yml b/cql-box/components/cql/tasks/main.yml index 057252b..e149c27 100644 --- a/cql-box/components/cql/tasks/main.yml +++ b/cql-box/components/cql/tasks/main.yml @@ -5,12 +5,14 @@ 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 From 66435b8b1b398375f1f58c08821b84518bcb416c Mon Sep 17 00:00:00 2001 From: Gerben Oostra Date: Wed, 14 Dec 2016 13:57:14 +0100 Subject: [PATCH 3/5] updated cassandra version in cql-box --- cql-box/components/cql/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cql-box/components/cql/defaults/main.yml b/cql-box/components/cql/defaults/main.yml index 2a2f8fe..ba0b044 100644 --- a/cql-box/components/cql/defaults/main.yml +++ b/cql-box/components/cql/defaults/main.yml @@ -1,4 +1,4 @@ --- -cql_version: 1.2.0 +cql_version: 3.0.0 cql_nodecount: 3 cql_clustername: test From 20d87ee98af8d7fc0c3093ebf06b6ad712a6dc7e Mon Sep 17 00:00:00 2001 From: Gerben Oostra Date: Sat, 17 Dec 2016 13:31:41 +0100 Subject: [PATCH 4/5] Simplified setting up the cql box --- cql-box/README.md | 15 +++++++++++++++ cql-box/vagrant_start.sh | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 cql-box/README.md create mode 100755 cql-box/vagrant_start.sh 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/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 From b684e0cb82c66f40b1b716311cb040e9004fb74c Mon Sep 17 00:00:00 2001 From: Gerben Oostra Date: Sat, 17 Dec 2016 15:50:43 +0100 Subject: [PATCH 5/5] added cql-box to travis --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) 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: