Skip to content

Commit

Permalink
Couchbase debian recipe (#162)
Browse files Browse the repository at this point in the history
* feat(debian): add recipe for couchbase

* feat(debian): add test definition for couchbase

* feat(debian): add test file containing ansible plays

* refactor(debian): decrease resources

* refactor(debian): try localhost

* refactor(debian): add pause after installing couchbase

* refactor(debian): increase memory

* refactor(debian): increase instance size

* refactor(debian): adapt cluster ramsize

* refactor(debian): change url

* refactor(debian): fix passing port variable to config

* refactor(debian): remove -a flag from tee command

* refactor(debian): fix config variables

* refactor(debian): change process match

* refactor(debian): fix username

* refactor(debian): modify process match

* refactor(debian): check different recipe construction

* refactor(debian): fix logmatch

* refactor(debian): change silent to false

* refactor(debian): fix variables

* refactor(debian): change silent to true

* chore: move to new ohi directory

* chore(nit): adjusting username and capitalization

Co-authored-by: Justin Eveland <[email protected]>
  • Loading branch information
JakubKotkowiak and jbeveland27 authored Feb 3, 2021
1 parent bdaefbe commit 3383809
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 0 deletions.
121 changes: 121 additions & 0 deletions recipes/newrelic/infrastructure/ohi/couchbase/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: couchbase-open-source-integration
displayName: Couchbase Open Source Integration
description: New Relic install recipe for default Couchbase Open Source on-host integration (via Infra-Agent)
repository: https://github.com/newrelic/nri-couchbase

installTargets:
- type: host
os: linux
platform: "debian"
- type: host
os: linux
platform: "ubuntu"

# keyword convention for dealing with search terms that could land someone on this instrumentation project
keywords:
- Infrastructure
- Integration
- couchbase

# CLI runs process detection; this is used to filter recipes that are appropriate for matched processes
processMatch:
- couchbase

# Matches partial list of the Log forwarding parameters
logMatch:
- name: Couchbase Error
file: /opt/couchbase/var/lib/couchbase/logs/error.log
- name: Couchbase General
file: /opt/couchbase/var/lib/couchbase/logs/couchdb.log

validationNrql: "SELECT count(*) from CouchbaseNodeSample where hostname like '{{.HOSTNAME}}%' FACET entityGuid SINCE 10 minutes ago"

inputVars:
- name: "NR_CLI_API_USERNAME"
prompt: "Couchbase Username"
- name: "NR_CLI_API_PASSWORD"
prompt: "Couchbase Password"
- name: "NR_CLI_API_HOSTNAME"
prompt: "Couchbase Hostname (default: localhost)"
default: "localhost"
- name: "NR_CLI_API_PORT"
prompt: "Couchbase Port (default: 8091)"
default: 8091
- name: "NR_CLI_API_QUERY_PORT"
prompt: "Couchbase Query Port (default: 8093)"
default: 8093
- name: "NR_CLI_API_USE_SSL"
prompt: "Use SSL to connect? (true/false)"
default: false
- name: "NR_CLI_API_CA_BUNDLE_DIR"
prompt: "SSL Certificate Directory (if applicable)"
- name: "NR_CLI_API_CA_BUNDLE_FILE"
prompt: "SSL Certificate File (if applicable)"

install:

version: "3"
silent: true

tasks:
default:
cmds:
- task: assert_pre_req
- task: setup

assert_pre_req:
cmds:
- |
SERVICE_EXIST=$(sudo systemctl status newrelic-infra.service | grep "Active" | wc -l)
if [ $SERVICE_EXIST -eq 0 ]; then
echo "The newrelic-infra agent service is NOT installed on the host, but is required to install this integration." >> /dev/stderr
exit 1
fi
setup:
label: "Installing couchbase integration..."
cmds:
- |
sudo mkdir -p "/etc/newrelic-infra/integrations.d"
- |
sudo apt-get update -y
- |
sudo apt-get install nri-couchbase -y
- |
if [ -f /etc/newrelic-infra/integrations.d/couchbase-config.yml ]; then
sudo rm /etc/newrelic-infra/integrations.d/couchbase-config.yml;
fi
sudo touch /etc/newrelic-infra/integrations.d/couchbase-config.yml;
- |
if [ {{.NR_CLI_API_USE_SSL}} == false ]; then
sudo tee -a /etc/newrelic-infra/integrations.d/couchbase-config.yml > /dev/null <<"EOT"
integration_name: com.newrelic.couchbase
instances:
- name: couchbase
command: all_data
arguments:
hostname: {{.NR_CLI_API_HOSTNAME}}
port: {{.NR_CLI_API_PORT}}
query_port: {{.NR_CLI_API_QUERY_PORT}}
username: {{.NR_CLI_API_USERNAME}}
password: {{.NR_CLI_API_PASSWORD}}
use_ssl: {{.NR_CLI_API_USE_SSL}}
EOT
else
sudo tee -a /etc/newrelic-infra/integrations.d/couchbase-config.yml > /dev/null <<"EOT"
integration_name: com.newrelic.couchbase
instances:
- name: couchbase
command: all_data
arguments:
hostname: {{.NR_CLI_API_HOSTNAME}}
port: {{.NR_CLI_API_PORT}}
query_port: {{.NR_CLI_API_QUERY_PORT}}
username: {{.NR_CLI_API_USERNAME}}
password: {{.NR_CLI_API_PASSWORD}}
use_ssl: {{.NR_CLI_API_USE_SSL}}
ca_bundle_dir: {{.NR_CLI_API_CA_BUNDLE_DIR}}
ca_bundle_file: {{.NR_CLI_API_CA_BUNDLE_FILE}}
EOT
fi
- sudo systemctl restart newrelic-infra.service
59 changes: 59 additions & 0 deletions test/definitions/ohi/linux/couchbase-debian.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"global_tags": {
"owning_team": "OpenSource",
"Environment": "development",
"Department": "Product",
"Product": "Virtuoso"
},

"resources": [{
"id": "host1",
"display_name": "Debian10InfraCouchbaseInstallHost",
"provider": "aws",
"type": "ec2",
"size": "t3.small",
"ami_name": "SupportedImages debian-10-amd64-*",
"user_name": "admin"
}],

"services": [{
"id": "couchbase1",
"destinations": ["host1"],
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/couchbase/install/debian/roles",
"port": 80,
"params":{
"create_env_var": true,
"initialize_cluster": true
}
}],

"instrumentations": {
"resources": [
{
"id": "nr_infra_couchbase",
"resource_ids": ["host1"],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/linux/newrelic-cli/install-recipe/roles",
"params": {
"recipe_content_url": [
"https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/infrastructure/debian.yml",
"https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/infrastructure/ohi/couchbase/debian.yml"
]
}
},
{
"id": "nr_infra_is_having_data",
"resource_ids": ["host1"],
"provider": "newrelic",
"source_repository": "https://github.com/newrelic/open-install-library.git",
"deploy_script_path": "test/deploy/assertions/recipe-is-valid/roles",
"params": {
"recipe_validation_nrql_url": "https://raw.githubusercontent.com/newrelic/open-install-library/main/recipes/newrelic/infrastructure/ohi/couchbase/debian.yml"
}
}
]
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
- debug:
msg: Install Couchbase

- name: Set default initialize_cluster (default not create)
set_fact:
initialize_cluster: "false"
when: initialize_cluster is undefined

- name: Set default create_env_var (default not create)
set_fact:
create_env_var: "false"
when: create_env_var is undefined

- name: Download the meta package
shell: curl -O https://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-amd64.deb

- name: Install the meta package
shell: dpkg -i ./couchbase-release-1.0-amd64.deb
become: true

- name: Reload local package database
shell: apt-get update -y
become: true

- name: Install latest release of couchbase-server-community
shell: apt-get install couchbase-server-community
become: true

- name: Wait for couchbase
pause:
seconds: 20

- block:
- name: Initialize cluster
shell: /opt/couchbase/bin/couchbase-cli cluster-init --cluster 127.0.0.1:8091 --cluster-name Test --cluster-username newrelic --cluster-password Virtuoso4all! --cluster-ramsize 1300 --cluster-analytics-ramsize 1024 --services data
when: initialize_cluster|bool

- block:
- name: Export NR_CLI_USERNAME
shell: "echo export NR_CLI_API_USERNAME=newrelic >> ~/.bashrc"
- name: Export NR_CLI_PASSWORD
shell: "echo export NR_CLI_API_PASSWORD=Virtuoso4all! >> ~/.bashrc"
- name: Export NR_CLI_API_PORT
shell: "echo export NR_CLI_API_PORT=8091 >> ~/.bashrc"
- name: Export NR_CLI_QUERY_PORT
shell: "echo export NR_CLI_API_QUERY_PORT=8093 >> ~/.bashrc"
- name: Export NR_CLI_HOSTNAME
shell: "echo export NR_CLI_API_HOSTNAME=localhost >> ~/.bashrc"
- name: Export USE_SSL
shell: "echo export NR_CLI_API_USE_SSL=false >> ~/.bashrc"
- name: Export CA_BUNDLE_DIR
shell: "echo export NR_CLI_API_CA_BUNDLE_DIR=notUsed >> ~/.bashrc"
- name: Export CA_BUNDLE_FILE
shell: "echo export NR_CLI_API_CA_BUNDLE_FILE=notUsed >> ~/.bashrc"
when: create_env_var|bool

0 comments on commit 3383809

Please sign in to comment.