From 7fb43eae37e30dbf988cd1f6380128f37dc0a1c7 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 13 Dec 2016 13:11:27 +0100 Subject: [PATCH] library/roles/couchbase: Install a specific version if not explicitly specified that we want the latest package from the repository. --- couchbase/defaults/main.yml | 11 +++--- couchbase/tasks/couchbase.yml | 72 +++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/couchbase/defaults/main.yml b/couchbase/defaults/main.yml index bcbf238..2cde31e 100644 --- a/couchbase/defaults/main.yml +++ b/couchbase/defaults/main.yml @@ -1,9 +1,13 @@ --- -couchbase_install_packages: True +couchbase_install_packages: False couchbase_start_server: True +couchbase_install_from_repo: False couchbase_repo_pkg: couchbase-release-1.0-2-amd64.deb couchbase_repo_pkg_url: 'http://packages.couchbase.com/releases/couchbase-release/{{ couchbase_repo_pkg }}' +couchbase_pkg_file: 'couchbase-server-community_4.0.0-ubuntu14.04_amd64.deb' +couchbase_direct_package_url: 'http://packages.couchbase.com/releases/4.0.0/{{ couchbase_pkg_file }}' + couchbase_default_host: localhost couchbase_console_port: 8091 couchbase_xdcr_port: 8092 @@ -37,11 +41,6 @@ couchbase_epmd_port: 4369 couchbase_dataExchangeFirst_port: 21100 couchbase_dataExchangeLast_port: 21299 -couchbase_allowed_hosts: - - '{{ network.isti }}' - - '{{ network.nmis }}' - - '{{ ansible_default_ipv4.address }}/32' - couchbase_ganglia_plugin_enabled: True #couchbase_ganglia_url_username: #couchbase_ganglia_url_password: diff --git a/couchbase/tasks/couchbase.yml b/couchbase/tasks/couchbase.yml index 21e15ad..5a55a56 100644 --- a/couchbase/tasks/couchbase.yml +++ b/couchbase/tasks/couchbase.yml @@ -1,29 +1,59 @@ --- -- name: Get the meta package for the couchbase repository - get_url: url={{ couchbase_repo_pkg_url }} dest=/root/{{ couchbase_repo_pkg }} - register: couchbase_repository - tags: couchbase +- block: + - name: Install the package source and the Couchbase public keys + apt: deb={{ couchbase_repo_pkg_url }} + register: couchbase_repo_pkg -- name: Install the package source and the Couchbase public keys - shell: /usr/bin/dpkg -i /root/couchbase-release-1.0-2-amd64.deb - when: ( couchbase_repository | changed ) - tags: couchbase + - name: Update the apt cache if needed + apt: update_cache=yes + when: ( couchbase_repo_pkg | changed ) + + - name: Install the couchbase community server package + apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 + with_items: + - couchbase-server-community + + - name: Ensure couchbase is started and enabled + service: name=couchbase-server state=started enabled=yes + when: couchbase_start_server + + - name: Ensure couchbase is stopped and disabled + service: name=couchbase-server state=stopped enabled=no + when: not couchbase_start_server -- name: Install the latest version of couchbase community server - apt: pkg={{ item }} state=latest update_cache=yes - with_items: - - couchbase-server-community when: - couchbase_install_packages - tags: couchbase + - couchbase_install_from_repo + tags: couchbase -- name: Ensure couchbase is started and enabled - service: name=couchbase-server state=started enabled=yes - when: couchbase_start_server - tags: couchbase -- name: Ensure couchbase is stopped and disabled - service: name=couchbase-server state=stopped enabled=no - when: not couchbase_start_server - tags: couchbase +- block: + - name: Get and install the specific Couchbase package + apt: deb={{ couchbase_direct_package_url }} + - name: Ensure couchbase is started and enabled + service: name=couchbase-server state=started enabled=yes + when: couchbase_start_server + + - name: Ensure couchbase is stopped and disabled + service: name=couchbase-server state=stopped enabled=no + when: not couchbase_start_server + + when: + - couchbase_install_packages + - not couchbase_install_from_repo + tags: couchbase + + +- block: + - name: Ensure couchbase is stopped and disabled + service: name=couchbase-server state=stopped enabled=no + + - name: Remove the couchbase server package + apt: pkg={{ item }} state=absent update-cache=yes purge=yes + with_items: + - 'couchbase-server-community' + - 'couchbase-release' + + when: not couchbase_install_packages + tags: couchbase