name: Cloudsoft 3T Three Tier Application

services:
  - type: cloudsoft-threetier-nginx
    brooklyn.config:
      target_ips: $brooklyn:component("cluster").attributeWhenReady("children_ips")
      target_port: 8080
    brooklyn.policies:
      - type: workflow-policy
        triggers:
          - entity: cluster
            sensor: children_ips
        period: 1d          # optionally regenerate daily for good measure
        steps:
          - invoke-effector regenerate-config

  - type: org.apache.brooklyn.entity.group.DynamicCluster
    id: cluster
    name: Java Cluster
    brooklyn.config:
      cluster.initial.size: 2
      memberSpec:
        type: cloudsoft-threetier-java-midtier
        brooklyn.config:
          jar_url: https://github.com/cloudsoft/hello-world-spring-boot/releases/download/1.0.1/hello-world-spring-boot-1.0.1.jar
          extra_args: >
            $brooklyn:formatString("--spring.profiles.active=remote --DB_IP='%s' --DB_USER='%s' --DB_PASS='%s'",
            $brooklyn:component("db").attributeWhenReady("host.address"),
            "brooklyn",
            $brooklyn:external("brooklyn-demo-sample","hidden-brooklyn-password"))
        brooklyn.policies:
          - type: workflow-policy
            period: 10s
            steps:
              - ssh curl -f -LI localhost:8080
              - clear-sensor service.problems['curl-check']
            on-error:
              - set-sensor service.problems['curl-check'] = "curl failed."
    brooklyn.enrichers:
      - type: org.apache.brooklyn.enricher.stock.Aggregator
        id: address_aggregator
        brooklyn.config:
          enricher.sourceSensor: $brooklyn:sensor("host.address")
          enricher.targetSensor: $brooklyn:sensor("children_ips")
          enricher.aggregating.fromMembers: true
          transformation: list

  - type: cloudsoft-threetier-mariadb
    id: db
    brooklyn.config:
      creation_script_sql_url: https://github.com/cloudsoft/hello-world-spring-boot/releases/download/1.0.1/creation-script-mariadb.sql


location: aws-ubuntu