library/roles/couchbase: Add a backup script to the couchbase role. It needs to be run on one node only.

d4science-ghn-cluster: couchbase, configure and install the backup script on couchbase06.
This commit is contained in:
Andrea Dell'Amico 2016-12-13 18:48:58 +01:00
parent 47b3f257d6
commit 228f85bc88
3 changed files with 34 additions and 12 deletions

View File

@ -41,6 +41,11 @@ couchbase_epmd_port: 4369
couchbase_dataExchangeFirst_port: 21100
couchbase_dataExchangeLast_port: 21299
couchbase_backup_enabled: False
couchbase_backup_dest_dir: /var/cache
couchbase_backup_command: /opt/couchbase/bin/cbbackup
couchbase_backup_type: full
couchbase_ganglia_plugin_enabled: True
#couchbase_ganglia_url_username:
#couchbase_ganglia_url_password:

View File

@ -13,14 +13,6 @@
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
when:
- couchbase_install_packages
- couchbase_install_from_repo
@ -31,6 +23,16 @@
- name: Get and install the specific Couchbase package
apt: deb={{ couchbase_direct_package_url }}
when:
- couchbase_install_packages
- not couchbase_install_from_repo
tags: couchbase
- block:
- name: Install the backup script when needed
template: src=couchbase_backup.j2 dest=/usr/local/bin/couchbase_backup owner=root group=root mode=0550
when: couchbase_backup_enabled
- name: Ensure couchbase is started and enabled
service: name=couchbase-server state=started enabled=yes
when: couchbase_start_server
@ -39,10 +41,9 @@
service: name=couchbase-server state=stopped enabled=no
when: not couchbase_start_server
when:
- couchbase_install_packages
- not couchbase_install_from_repo
tags: couchbase
when: couchbase_install_packages
tags: [ 'couchbase', 'couchbase_backup' ]
- block:
@ -55,5 +56,11 @@
- 'couchbase-server-community'
- 'couchbase-release'
- name: Remove the couchbase backup script and the couchbase non packaged files
file: dest={{ item }} state=absent
with_items:
- '/usr/local/bin/couchbase_backup'
- '/opt/couchbase'
when: not couchbase_install_packages
tags: couchbase

View File

@ -0,0 +1,10 @@
#!/bin/bash
LOG_FILE={{ couchbase_backup_dest_dir }}/couchbase_backup.log
COUCH_URL="http://{{ ansible_fqdn }}:{{ couchbase_console_port }}/"
{{ couchbase_backup_command }} $COUCH_URL {{ couchbase_backup_dest_dir }}/ -m {{ couchbase_backup_type }} -u {{ couchbase_backup_user }} -p {{ couchbase_backup_password }} > $LOG_FILE 2>&1
exit $?