From 42e721d9477afe45fb65c4036b73b1af93d33861 Mon Sep 17 00:00:00 2001 From: "tommaso.piccioli" Date: Wed, 11 Nov 2015 18:04:54 +0100 Subject: [PATCH] cassandra in library --- cassandra/defaults/main.yml | 9 +++++++++ cassandra/handlers/main.yml | 7 +++++++ cassandra/tasks/main.yml | 39 +++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 cassandra/defaults/main.yml create mode 100644 cassandra/handlers/main.yml create mode 100644 cassandra/tasks/main.yml diff --git a/cassandra/defaults/main.yml b/cassandra/defaults/main.yml new file mode 100644 index 0000000..3bb4295 --- /dev/null +++ b/cassandra/defaults/main.yml @@ -0,0 +1,9 @@ +--- +cassandra_install_from_external_repo: True +cassandra_install_packages: True +cassandra_latest_version: True +cassandra_start_server: 'no' +cassandra_cluster_enabled: False +cassandra_allowed_hosts: + - 127.0.0.1/8 + - '{{ ansible_default_ipv4.address }}/32' diff --git a/cassandra/handlers/main.yml b/cassandra/handlers/main.yml new file mode 100644 index 0000000..b4e5b3b --- /dev/null +++ b/cassandra/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: Update apt cache + apt: update_cache=yes + ignore_errors: true + +- name: Restart cassandra + service: name=cassandra state=restarted diff --git a/cassandra/tasks/main.yml b/cassandra/tasks/main.yml new file mode 100644 index 0000000..6c58763 --- /dev/null +++ b/cassandra/tasks/main.yml @@ -0,0 +1,39 @@ +--- +- name: Install the cassandra apt key + raw: apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 350200F2B999A372 + when: cassandra_install_from_external_repo + tags: cassandra + +- name: Install the cassandra repository + copy: content="deb http://debian.datastax.com/community stable main" dest=/etc/apt/sources.list.d/cassandra.sources.list owner=root group=root mode=044 + when: cassandra_install_from_external_repo + register: external_repo + tags: cassandra + +- name: Update the apt cache + apt: update_cache=yes + when: ( external_repo | changed ) + ignore_errors: True + tags: cassandra + +- name: Install the latest version of cassandra server + apt: pkg={{ item }} state=latest +with_items: + - cassandra + - cassandra-tools + when: + - cassandra_install_from_external_repo + - cassandra_install_packages + - cassandra_latest_version + tags: cassandra + +- name: Ensure mongodb is started + service: name=cassandra state=started enabled=yes + when: ( cassandra_start_server is defined ) and ( cassandra_start_server == 'yes' ) + tags: cassandra + +- name: Ensure cassandra is stopped and disabled + service: name=cassandra state=stopped enabled=no + when: ( cassandra_start_server is defined ) and ( cassandra_start_server == 'no' ) + tags: cassandra +