Skip to content

Instantly share code, notes, and snippets.

@ahgittin
Last active July 21, 2020 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahgittin/bead9ba295cb6bcfb4929177ae3c5418 to your computer and use it in GitHub Desktop.
Save ahgittin/bead9ba295cb6bcfb4929177ae3c5418 to your computer and use it in GitHub Desktop.
Cloudsoft AMP Training examples
name: My Tomcat Server
location: my-first-location
services:
- type: 'TomcatServer'
brooklyn.config:
wars.root: >-
http://bit.ly/2dcaKIV
name: My Web Cluster
location: my-first-location
services:
- type: org.apache.brooklyn.entity.database.mysql.MySqlNode
id: db
name: My DB
brooklyn.config:
creationScriptUrl: 'https://bit.ly/brooklyn-visitors-creation-script'
- type: org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster
name: My Web
brooklyn.config:
wars.root: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
java.sysprops:
brooklyn.example.db.url: |
$brooklyn:formatString("jdbc:%s%s?user=%s&password=%s",
component("db").attributeWhenReady("datastore.url"),
"visitors", "brooklyn", "br00k11n")
name: Python Web Server
# this example deploys a very simple python web server
services:
- type: vanilla-bash-server
name: My Bash Web Server VM
brooklyn.config:
install.command: |
# install python if not present
which python || \
{ apt-get update && apt-get install python ; } || \
{ yum update && yum install python ; } || \
{ echo WARNING: cannot install python && exit 1 ; }
customize.command: |
# create the web page to serve
cat > index.html << EOF
Hello world.
<p>
I am ${ENTITY_INFO}, ${MESSAGE:-a Brooklyn sample}.
<p>
Created at: `date`
<p>
I am running at ${HOSTNAME}, with on-box IP configuration:
<pre>
`ifconfig | grep inet`
</pre>
EOF
launch.command: |
# launch in background (ensuring no streams open), and record PID to file
nohup python -m SimpleHTTPServer ${PORT:-8080} < /dev/null > output.txt 2>&1 &
echo $! > ${PID_FILE:-pid.txt}
sleep 5
ps -p `cat ${PID_FILE:-pid.txt}`
if [ $? -ne 0 ] ; then
cat output.txt
echo WARNING: python web server not running
exit 1
fi
shell.env:
HOSTNAME: $brooklyn:attributeWhenReady("host.name")
PORT: $brooklyn:config("my.app.port")
ENTITY_INFO: $brooklyn:component("this", "")
MESSAGE: $brooklyn:config("my.message")
# custom
my.app.port: 8080
my.message: "good to meet you"
brooklyn.enrichers:
# publish the URL as a sensor; the GUI will pick this up (main.uri)
- type: org.apache.brooklyn.enricher.stock.Transformer
brooklyn.config:
uniqueTag: url-generator
enricher.sourceSensor: host.name
# use the definition from Attributes class, as it has a RendererHint so GUI makes it a link
enricher.targetSensor: $brooklyn:sensor("org.apache.brooklyn.core.entity.Attributes", "main.uri")
enricher.targetValue:
$brooklyn:formatString:
- "http://%s:%s/"
- $brooklyn:attributeWhenReady("host.name")
- $brooklyn:config("my.app.port")
location: my-first-location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment