Skip to content
Permalink
Browse files

Merge pull request #146 from killbill/kpm-diagnostic-docker

Integrate kpm diagnostic in Docker
  • Loading branch information...
pierre committed May 2, 2019
2 parents 84b79d0 + 3b1db56 commit 211b37baeec0da4f8f74c81ed7a50b11d9fad105
@@ -0,0 +1,21 @@
---
- name: Gather diagnostics
hosts: all
tasks:
- name: setup Ruby
import_tasks: roles/common/tasks/main.yml
- name: setup KPM
import_tasks: roles/kpm/tasks/main.yml
- name: gather diagnostics
killbill_diagnostics:
kpm_path: "{{ kpm_path }}"
killbill_url: "{{ killbill_url|default('http://127.0.0.1:8080') }}"
killbill_web_path: "{{ catalina_base }}/webapps/ROOT.war"
killbill_user: "{{ killbill_user|default('admin') }}"
killbill_password: "{{ killbill_password|default('password') }}"
killbill_api_key: "{{ killbill_api_key|default('bob') }}"
killbill_api_secret: "{{ killbill_api_secret|default('lazar') }}"
killbill_account: "{{ killbill_account|default('') }}"
bundles_dir: "{{ kb_plugins_dir }}"
log_dir: "{{ catalina_base }}/logs"
tags: diagnostics
@@ -0,0 +1,50 @@
#!/usr/bin/ruby
# WANT_JSON

require 'json'
require 'logger'
require 'pathname'
require 'set'
require 'uri'
require 'yaml'

data = {}
File.open(ARGV[0]) do |fh|
data = JSON.parse(fh.read())
end

unless data['kpm_path'].nil?
ENV['GEM_PATH']="#{data['kpm_path']}/lib/vendor/ruby/2.2.0"
Gem.clear_paths
end
require 'kpm'
require 'kpm/version'

logger = Logger.new(STDOUT)
logger.level = Logger::INFO

killbill_api_credentials = [data['killbill_api_key'], data['killbill_api_secret']]
killbill_credentials = [data['killbill_user'], data['killbill_password']]

diagnostic = KPM::DiagnosticFile.new(nil,
killbill_api_credentials,
killbill_credentials,
data['killbill_url'],
nil,
nil,
nil,
nil,
data['kaui_web_path'],
data['killbill_web_path'],
data['bundles_dir'],
logger)

killbill_account = data['killbill_account'].empty? ? nil : data['killbill_account']
diagnostic_file = diagnostic.export_data(killbill_account, data['log_dir'])

result = {
'changed' => true,
'diagnostic_file' => diagnostic_file
}

print JSON.dump(result)
@@ -28,6 +28,17 @@ ENV KPM_INSTALL_CMD ansible-playbook $ANSIBLE_OPTS \
-e catalina_base=$CATALINA_BASE \
$KILLBILL_CLOUD_ANSIBLE_ROLES/killbill.yml

ENV KPM_DIAGNOSTIC_CMD ansible-playbook $ANSIBLE_OPTS \
-e kpm_install_dir=$KPM_INSTALL_DIR \
-e kpm_version=$KPM_VERSION \
-e kpm_yml=$KILLBILL_INSTALL_DIR/kpm.yml \
-e kb_config_dir=$KILLBILL_INSTALL_DIR \
-e kb_plugins_dir=$KILLBILL_INSTALL_DIR/bundles \
-e tomcat_owner=$TOMCAT_OWNER \
-e tomcat_group=$TOMCAT_GROUP \
-e catalina_base=$CATALINA_BASE \
$KILLBILL_CLOUD_ANSIBLE_ROLES/diagnostic.yml

ENV MIGRATIONS_CMD ansible-playbook $ANSIBLE_OPTS \
-e kpm_install_dir=$KPM_INSTALL_DIR \
-e kpm_version=$KPM_VERSION \
@@ -66,6 +66,7 @@ def export_data(account_id = nil, log_dir = nil)

@logger.info "\e[32mDiagnostic data exported under #{zip_file_name} \e[0m"

return zip_file_name
else
raise Interrupt, 'Account id or configuration file not found'
end

0 comments on commit 211b37b

Please sign in to comment.
You can’t perform that action at this time.