Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions userguide/aws/how-to-set-up-a-multi-tier-system.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,16 @@ To configure the EC2 instances and establish their connection to the databases,
[source,bash]
----
#!/bin/bash
set -euo pipefail

db_host="<DB endpoint writer instance>"
db_port="<DB port>"
db_user="<DB username>"
db_password="<DB passwordd>"
kb_admin_password="<Kaui admin login password>"

KB_PLUGINS_TEMP_DIR="/var/lib/killbill/bundles/temp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we typically use temp or tmp - does it matter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a directory we create during AMI creation (we can give any name) -- https://github.com/killbill/killbill-cloud/blob/master/ansible/roles/killbill/tasks/plugins/kpm_plugin.yml#L10


cat << EOF >> /etc/environment
KB_org_killbill_dao_url=jdbc:mysql://$db_host:$db_port/killbill
KB_org_killbill_dao_user=$db_user
Expand All @@ -182,6 +185,42 @@ KAUI_DB_USERNAME=$db_user
KAUI_DB_PASSWORD=$db_password
KAUI_KILLBILL_URL=http://127.0.0.1:8080
EOF

echo "Waiting for plugin SQL files..."

for i in {1..60}; do
if ls ${KB_PLUGINS_TEMP_DIR}/*/*.sql >/dev/null 2>&1; then
break
fi

sleep 10
done

echo "Installing plugin DDLs..."

find "${KB_PLUGINS_TEMP_DIR}" \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we guarantee that all ddl files will be there - the loop wait for the first one if I understand correctly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ansible copies these DDL files during AMI creation: https://github.com/killbill/killbill-cloud/blob/master/ansible/roles/killbill/tasks/plugins/kpm_plugin.yml#L18. If the AMI is created successfully, these files should be present when the instance is launched.

-mindepth 2 \
-maxdepth 2 \
-name "*.sql" \
| sort \
| while read -r ddl_file; do

plugin_name=$(basename "$(dirname "$ddl_file")")

echo "Installing DDL for plugin: ${plugin_name}"
echo "Executing file: ${ddl_file}"

mysql \
--host="${db_host}" \
--port="${db_port}" \
--user="${db_user}" \
--password="${db_password}" \
killbill < "${ddl_file}"

echo "Completed plugin: ${plugin_name}"
done

echo "All plugin DDLs installed successfully"
----

In the above script, replace the value of `db_host` with the full name of the DB writer endpoint obtained from the Connectivity and Security panel, as indicated earlier. Be sure to specify the appropriate database port number (`3306` for MySQL or `5432` for PostgreSQL) by setting `db_port`. The `kb_admin_password` value will be utilized as the admin password for Kaui login.
Expand Down
Loading