From 515a1d36c04a4c60bf5a4fa2379cd47c23477a93 Mon Sep 17 00:00:00 2001 From: Habitat User Date: Tue, 12 Jun 2018 21:05:26 +0000 Subject: [PATCH 1/2] My automation workshop edits --- national-parks/.gitignore | 1 + national-parks/habitat/README.md | 9 ++++++ national-parks/habitat/default.toml | 6 ++++ national-parks/habitat/haproxy.toml | 15 ++++++++++ national-parks/habitat/hooks/init | 21 ++++++++++++++ national-parks/habitat/hooks/run | 12 ++++++++ national-parks/habitat/mongo.toml | 7 +++++ national-parks/habitat/plan.sh | 34 +++++++++++++++++++++++ national-parks/src/main/webapp/index.html | 2 +- 9 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 national-parks/.gitignore create mode 100644 national-parks/habitat/README.md create mode 100644 national-parks/habitat/default.toml create mode 100644 national-parks/habitat/haproxy.toml create mode 100644 national-parks/habitat/hooks/init create mode 100644 national-parks/habitat/hooks/run create mode 100644 national-parks/habitat/mongo.toml create mode 100644 national-parks/habitat/plan.sh diff --git a/national-parks/.gitignore b/national-parks/.gitignore new file mode 100644 index 0000000..fbca225 --- /dev/null +++ b/national-parks/.gitignore @@ -0,0 +1 @@ +results/ diff --git a/national-parks/habitat/README.md b/national-parks/habitat/README.md new file mode 100644 index 0000000..fbe5c43 --- /dev/null +++ b/national-parks/habitat/README.md @@ -0,0 +1,9 @@ +# Habitat package: national-parks + +## Description + +Provide a brief description of the `national-parks` plan / purpose. + +## Usage + +Describe the general usage for the `national-parks` plan diff --git a/national-parks/habitat/default.toml b/national-parks/habitat/default.toml new file mode 100644 index 0000000..2a7b6cc --- /dev/null +++ b/national-parks/habitat/default.toml @@ -0,0 +1,6 @@ +mongodb_database = "demo" + +[server] +port = "8080" +shutdown-port = "8005" +redirect-port = "8443" diff --git a/national-parks/habitat/haproxy.toml b/national-parks/habitat/haproxy.toml new file mode 100644 index 0000000..939b2dc --- /dev/null +++ b/national-parks/habitat/haproxy.toml @@ -0,0 +1,15 @@ +maxconn = 32 +httpchk = 'GET /national-parks' + +[front-end] +listen = '*' +port = 8085 +mode = 'http' + +[status] +enabled = true +listen = '*' +port = 8000 +user = 'admin' +password = 'password' +uri = '/haproxy-stats' diff --git a/national-parks/habitat/hooks/init b/national-parks/habitat/hooks/init new file mode 100644 index 0000000..da352d3 --- /dev/null +++ b/national-parks/habitat/hooks/init @@ -0,0 +1,21 @@ +#!/bin/bash -x + +echo "Preparing TOMCAT_HOME..." +# Move directories that ship in the package into place +cp -a {{pkgPathFor "core/tomcat8"}}/tc {{pkg.svc_var_path}}/ + +cp {{pkg.path}}/*.war {{pkg.svc_var_path}}/tc/webapps + +# Following lines are to copy project tomcat configs to run time tomcat8 directory +for file in $(cd {{pkg.svc_config_path}}; ls -1 *.xml) +do + echo "Linking $file" + target="${file//_//}" + ln -vsf {{pkg.svc_config_path}}/$file {{pkg.svc_var_path}}/tc/$target +done + +echo "Done preparing TOMCAT_HOME" + +{{#if bind.database ~}} +{{pkgPathFor "core/mongo-tools"}}/bin/mongoimport --drop -d demo -c nationalparks --type json --jsonArray --file {{pkg.path}}/national-parks.json --host={{bind.database.first.sys.ip}} --port={{bind.database.first.cfg.port}} +{{/if ~}} diff --git a/national-parks/habitat/hooks/run b/national-parks/habitat/hooks/run new file mode 100644 index 0000000..056bd10 --- /dev/null +++ b/national-parks/habitat/hooks/run @@ -0,0 +1,12 @@ +#!/bin/bash + +{{#if bind.database ~}} +export CATALINA_OPTS="-DMONGODB_SERVICE_HOST={{bind.database.first.sys.ip}} +-DMONGODB_SERVICE_PORT={{bind.database.first.cfg.port}} +-DMONGODB_DATABASE={{cfg.mongodb_database}}" +{{/if ~}} + +export JAVA_HOME="{{pkgPathFor "core/jre8"}}" +export TOMCAT_HOME="{{pkgPathFor "core/tomcat8"}}/tc" +cp {{pkg.path}}/*.war $TOMCAT_HOME/webapps +exec ${TOMCAT_HOME}/bin/catalina.sh run diff --git a/national-parks/habitat/mongo.toml b/national-parks/habitat/mongo.toml new file mode 100644 index 0000000..b5dbdc6 --- /dev/null +++ b/national-parks/habitat/mongo.toml @@ -0,0 +1,7 @@ +[mongod] + +[mongod.net] +bind_ip = "0.0.0.0" + +[mongod.security] +cluster_auth_mode = "" diff --git a/national-parks/habitat/plan.sh b/national-parks/habitat/plan.sh new file mode 100644 index 0000000..1f7ca72 --- /dev/null +++ b/national-parks/habitat/plan.sh @@ -0,0 +1,34 @@ +pkg_origin=weldfire_hab_demo +pkg_name=national-parks +pkg_description="A sample JavaEE Web app deployed in the Tomcat8 package" +pkg_version=1.0.0 +pkg_maintainer="Bill Meyer " +pkg_license=('Apache-2.0') +pkg_deps=(core/tomcat8 core/jre8 core/mongo-tools) +pkg_build_deps=(core/jdk8/8u131 core/maven) +pkg_svc_user="root" +pkg_binds=( + [database]="port" +) +pkg_exports=( + [port]=server.port +) +pkg_exposes=(port) + +do_prepare() +{ + export JAVA_HOME=$(hab pkg path core/jdk8) +} + +do_build() +{ + cp -r $PLAN_CONTEXT/../ $HAB_CACHE_SRC_PATH/$pkg_dirname + cd ${HAB_CACHE_SRC_PATH}/${pkg_dirname} + mvn package +} + +do_install() +{ + cp ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/target/${pkg_name}.war ${PREFIX}/ + cp -v ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/data/national-parks.json ${PREFIX}/ +} diff --git a/national-parks/src/main/webapp/index.html b/national-parks/src/main/webapp/index.html index 3088710..c1b2107 100644 --- a/national-parks/src/main/webapp/index.html +++ b/national-parks/src/main/webapp/index.html @@ -1,7 +1,7 @@ - Map of National Parks + Map of National Parks Version 2 From d632fd511d21d203a93374d039d9c24afb555379 Mon Sep 17 00:00:00 2001 From: Habitat User Date: Tue, 12 Jun 2018 21:11:55 +0000 Subject: [PATCH 2/2] updates homepage with new icons and colored map --- national-parks/habitat/plan.sh | 2 +- national-parks/src/main/webapp/index.html | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/national-parks/habitat/plan.sh b/national-parks/habitat/plan.sh index 1f7ca72..d3107e2 100644 --- a/national-parks/habitat/plan.sh +++ b/national-parks/habitat/plan.sh @@ -1,7 +1,7 @@ pkg_origin=weldfire_hab_demo pkg_name=national-parks pkg_description="A sample JavaEE Web app deployed in the Tomcat8 package" -pkg_version=1.0.0 +pkg_version=1.1.0 pkg_maintainer="Bill Meyer " pkg_license=('Apache-2.0') pkg_deps=(core/tomcat8 core/jre8 core/mongo-tools) diff --git a/national-parks/src/main/webapp/index.html b/national-parks/src/main/webapp/index.html index c1b2107..fe4f218 100644 --- a/national-parks/src/main/webapp/index.html +++ b/national-parks/src/main/webapp/index.html @@ -1,8 +1,8 @@ - Map of National Parks Version 2 - + Map of National Parks + @@ -35,10 +35,12 @@ -

U.S. National Parks v6.3

+

U.S. National Parks v6.4.0

- + + +