-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 3 tier app with scripts. Nginx still needs more configuring.
- Loading branch information
Showing
11 changed files
with
459 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
brooklyn.catalog: | ||
bundle: io.brooklyn.three-tier-webapp.brooklyn-three-tier-webapp | ||
name: Brooklyn Three Tier App Types | ||
version: 1.1.0-SNAPSHOT # version of this blueprint. | ||
items: | ||
- classpath://three-tier-webapp/three-tier-webapp.bom | ||
- classpath://common-types/tomcat9.bom | ||
- classpath://common-types/mysql5.bom | ||
- classpath://common-types/nginx.bom | ||
- classpath://three-tier-webapp/three-tier-webapp.bom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
brooklyn.catalog: | ||
version: 1.0.0-SNAPSHOT | ||
publish: | ||
name: &mysql5Name MySQL 5 Server | ||
description: &mysql5Description This is the MySQL 5 blueprint type. | ||
license_code: Apache-2.0 | ||
|
||
items: | ||
- id: org.apache.brooklyn.entity.database.mysql5 | ||
name: *mysql5Name | ||
iconUrl: classpath://icons/mysql.png | ||
item: | ||
name: *mysql5Name | ||
type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess | ||
|
||
brooklyn.parameters: | ||
- name: creation.script.sql.url | ||
label: SQL creation script URL | ||
description: | | ||
If supplied, the server will download a creation SQL script from this URL and | ||
initialize the DB with it. | ||
To have the orchestration server download it, or to use a classpath URL with a bundled resource, | ||
use files.customize writing from that URL to creation-script.sql instead of this. | ||
type: string | ||
default: "" | ||
- name: mysql.url | ||
type: string | ||
label: Database pack URL | ||
default: "https://artifactory.cloudsoftcorp.com/artifactory/libs-release-local/io/cloudsoft/packs/mysql5/1.0.0/mysql5-1.0.0-tar.gz" | ||
description: | | ||
Publicly accessible URL of MySQL to install. | ||
If this is not supplied, callers should typically set files.customize to install, | ||
including multiple archives bundled with the blueprint. | ||
- name: install.command | ||
pinned: false | ||
- name: customize.command | ||
pinned: false | ||
- name: launch.command | ||
pinned: false | ||
- name: checkRunning.command | ||
pinned: false | ||
- name: stop.command | ||
pinned: false | ||
|
||
brooklyn.config: | ||
dontRequireTtyForSudo: true | ||
start.timeout: 20m | ||
sshMonitoring.enabled: false | ||
mysql.port: 3306 | ||
|
||
shell.env: | ||
CREATION_SCRIPT_URL: $brooklyn:config("creation.script.sql.url") | ||
DB_URL: $brooklyn:config("mysql.url") | ||
|
||
install.command: | | ||
MYSQL_CFG=/etc/mysql/mysql.conf.d/ | ||
sudo test -d "$MYSQL_CFG" && MYSQL_EXISTS="0" | ||
|
||
if [ "$MYSQL_EXISTS" ]; then | ||
echo "MySQL already installed." | ||
else | ||
echo "Installing MySQL." | ||
while sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/{lock,lock-frontend} >/dev/null 2>&1; do | ||
echo 'Waiting for release of dpkg/apt locks...'; | ||
sleep 5 | ||
done | ||
|
||
which curl || sudo apt --assume-yes install curl | ||
|
||
## Install the MySQL server | ||
if [ ! -z "${DB_URL}" ] ; then | ||
curl -L -k -f -o mysql.tar.gz "${DB_URL}" | ||
fi | ||
tar xf mysql.tar.gz | ||
PREV=`pwd` | ||
cd mysql | ||
while sudo fuser /var/{lib/{dpkg,apt/lists},cache/apt/archives}/{lock,lock-frontend} >/dev/null 2>&1; do | ||
echo 'Waiting for release of dpkg/apt locks...'; | ||
sleep 5 | ||
done | ||
sudo ./dbmanager.sh install | ||
cd $PREV | ||
|
||
sudo systemctl stop mysql | ||
|
||
cat >/tmp/zz-bind-address.cnf <<ENDOFTEXT | ||
[mysqld] | ||
bind-address = 0.0.0.0 | ||
ENDOFTEXT | ||
|
||
sudo mv /tmp/zz-bind-address.cnf /etc/mysql/mysql.conf.d/ | ||
sudo chown root:root /etc/mysql/mysql.conf.d/zz-bind-address.cnf | ||
fi | ||
|
||
customize.command: | | ||
# When MySQL is stopped `systemctl status mysql` returns `Active: inactive (dead)` | ||
# reminder: test for what you expect | ||
sudo systemctl status mysql | grep 'dead' > /dev/null 2>&1 | ||
if [ $? != 0 ] ; then | ||
echo "MySQL is running when configure is called. Skipping configuration assuming it has already been done. If this is not correct then stop the DB before invoking this." | ||
else | ||
echo "Configuring MySQL..." | ||
# When MySQL is up `systemctl status mysql` returns `Active: active (running)` | ||
sudo systemctl start mysql | ||
|
||
if [ ! -z "${CREATION_SCRIPT_URL}" ] ; then | ||
echo "Fetching and running creation script from ${CREATION_SCRIPT_URL}..." | ||
curl -L -k -f -o creation-script-from-url.sql ${CREATION_SCRIPT_URL} | ||
sudo mysql -u root < creation-script-from-url.sql | ||
fi | ||
fi | ||
|
||
launch.command: | | ||
sudo systemctl status mysql | grep 'running' > /dev/null 2>&1 | ||
if [ $? == 0 ]; then | ||
echo "MySQL is up. All is well with the world." | ||
else | ||
echo "MySQL is down. Starting it..." | ||
sudo systemctl start mysql | ||
fi | ||
|
||
stop.command: | | ||
sudo systemctl status mysql | grep 'running' > /dev/null 2>&1 | ||
if [ $? == 0 ]; then | ||
echo "MySQL is up. Shutting it down..." | ||
sudo systemctl stop mysql | ||
else | ||
echo "MySQL is already down." | ||
fi | ||
|
||
checkRunning.command: | ||
sudo /etc/init.d/mysql status | grep -i -e 'active' -e 'uptime' | ||
|
||
brooklyn.initializers: | ||
- type: org.apache.brooklyn.core.sensor.StaticSensor | ||
brooklyn.config: | ||
name: datastore.driver | ||
static.value: "com.mysql.jdbc.Driver" | ||
|
||
brooklyn.enrichers: | ||
- type: org.apache.brooklyn.enricher.stock.Transformer | ||
brooklyn.config: | ||
enricher.sourceSensor: $brooklyn:sensor("host.name") | ||
enricher.targetSensor: $brooklyn:sensor("datastore.url") | ||
enricher.targetValue: | ||
$brooklyn:formatString: | ||
- "mysql://%s:%s" | ||
- $brooklyn:attributeWhenReady("host.name") | ||
- $brooklyn:config("mysql.port") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
brooklyn.catalog: | ||
version: 1.1.0-SNAPSHOT # BROOKLYN_THREE_TIER_WEBAPP_VERSION | ||
publish: | ||
name: &nginXName NginX | ||
description: &nginXDescription A single Nginx server. Provides HTTP and reverse proxy services. | ||
license_code: Apache-2.0 | ||
|
||
items: | ||
- id: org.apache.brooklyn.entity.proxy.nginx | ||
name: *nginXName | ||
iconUrl: classpath://icons/nginx.jpeg | ||
item: | ||
name: *nginXName | ||
type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess | ||
|
||
brooklyn.parameters: | ||
- name: app.port | ||
label: NginX Port | ||
description: | | ||
If supplied, the server will download a creation SQL script from this URL and | ||
initialize the DB with it. | ||
To have the orchestration server download it, or to use a classpath URL with a bundled resource, | ||
use files.customize writing from that URL to creation-script.sql instead of this. | ||
type: string | ||
default: 8080 | ||
- name: nginx.sticky | ||
description: Whether to use sticky sessions (no sure where this is used) | ||
type: boolean | ||
default: true | ||
|
||
brooklyn.config: | ||
dontRequireTtyForSudo: true | ||
start.timeout: 20m | ||
sshMonitoring.enabled: false | ||
app.port: 8080 | ||
|
||
shell.env: | ||
APP_PORT: $brooklyn:config("app.port") | ||
|
||
install.command: | | ||
sudo apt -y update | ||
sudo apt -y install nginx | ||
|
||
customize.command: | | ||
echo customize | ||
|
||
#sudo systemctl enable postgresql.service | ||
|
||
launch.command: | | ||
sudo systemctl start nginx | ||
|
||
stop.command: | | ||
sudo systemctl stop nginx | ||
|
||
checkRunning.command: | ||
sudo systemctl status nginx | grep -i -e 'active' -e 'online' | ||
|
||
brooklyn.enrichers: | ||
- type: org.apache.brooklyn.enricher.stock.Transformer | ||
brooklyn.config: | ||
enricher.sourceSensor: $brooklyn:sensor("host.name") | ||
enricher.targetSensor: $brooklyn:sensor("main.uri") | ||
enricher.targetValue: | ||
$brooklyn:formatString: | ||
- "http://%s:%s" | ||
- $brooklyn:attributeWhenReady("host.name") | ||
- $brooklyn:config("app.port") | ||
|
Oops, something went wrong.