From ac78a1a272998c1e67aea0882c0d7e10d51b8bdd Mon Sep 17 00:00:00 2001 From: Egon Rijpkema Date: Tue, 13 Jun 2017 12:08:41 +0200 Subject: [PATCH] Added cassandra together with Wim --- cassandra.yml | 7 +++++++ hosts | 17 +++++++++++------ roles/cassandra/tasks/main.yml | 16 ++++++++++++++++ roles/cassandra/templates/cassandra.service | 19 +++++++++++++++++++ 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 cassandra.yml create mode 100644 roles/cassandra/tasks/main.yml create mode 100644 roles/cassandra/templates/cassandra.service diff --git a/cassandra.yml b/cassandra.yml new file mode 100644 index 0000000..c30c999 --- /dev/null +++ b/cassandra.yml @@ -0,0 +1,7 @@ +--- +# Run all plays as root. +- hosts: cassandra + become: True + roles: + - common + - cassandra diff --git a/hosts b/hosts index 43d6e0b..b8dc595 100644 --- a/hosts +++ b/hosts @@ -8,9 +8,14 @@ openstack01-node01 ansible-test ansible-test-2 ansible-test-3 - - - - - - +[cassandra] +openstack01-node[01:03] +[first_cassandra] +openstack01-node01 +[next_cassandra] +openstack01-node02 +openstack01-node03 +[first_cassandra:vars] +run_options="" +[next_cassandra:vars] +run_options="-e CASSANDRA_SEEDS=172.23.41.1" diff --git a/roles/cassandra/tasks/main.yml b/roles/cassandra/tasks/main.yml new file mode 100644 index 0000000..52d70c4 --- /dev/null +++ b/roles/cassandra/tasks/main.yml @@ -0,0 +1,16 @@ +# Install a docker based cassandra cluster. +--- +- include: ../common/tasks/docker.yml +- name: install service file. + template: + src: templates/cassandra.service + dest: /etc/systemd/system/cassandra.service + mode: 644 + owner: root + group: root +- name: install service file + command: systemctl daemon-reload +- name: make sure service is started + systemd: + name: cassandra.service + state: started diff --git a/roles/cassandra/templates/cassandra.service b/roles/cassandra/templates/cassandra.service new file mode 100644 index 0000000..d8f173e --- /dev/null +++ b/roles/cassandra/templates/cassandra.service @@ -0,0 +1,19 @@ +[Unit] +Description=Cassandra Container +After=docker.service +Requires=docker.service + +[Service] +TimeoutStartSec=0 +Restart=always +ExecStartPre=-/usr/bin/docker stop %n +ExecStartPre=-/usr/bin/docker rm %n +ExecStartPre=/usr/bin/docker pull cassandra:3.10 +ExecStart=/usr/bin/docker run --name %n -v /srv/lib/cassandra:/var/lib/cassandra \ + -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 \ + -e CASSANDRA_BROADCAST_ADDRESS={{ansible_default_ipv4.address}} \ + -e CASSANDRA_START_RPC=True \ + {{run_options}} cassandra:3.10 + +[Install] +WantedBy=multi-user.target