brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [20/29] incubator-brooklyn git commit: add support for SNAPSHOT downloads - supports release downloads via Apache closer.lua mirror - supports snapshot download from Apache maven - supports snapshot download from a local -dist.tar.gz archive. *NOTE* this
Date Sat, 30 Jan 2016 03:38:45 GMT
add support for SNAPSHOT downloads
- supports release downloads via Apache closer.lua mirror
- supports snapshot download from Apache maven
- supports snapshot download from a local -dist.tar.gz archive.
*NOTE* this currently requires the user to copy the dist to the same directory
       as the Vagrantfile


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/16d1e913
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/16d1e913
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/16d1e913

Branch: refs/heads/master
Commit: 16d1e913a78beaca66adbb138ad067629709b0c7
Parents: 8b1a4cb
Author: John McCabe <john@johnmccabe.net>
Authored: Thu Jan 28 16:27:44 2016 +0000
Committer: John McCabe <john@johnmccabe.net>
Committed: Thu Jan 28 16:27:44 2016 +0000

----------------------------------------------------------------------
 .../vagrant/src/main/vagrant/README.md          | 58 ++++--------
 .../vagrant/src/main/vagrant/Vagrantfile        |  4 -
 .../src/main/vagrant/files/install_brooklyn.sh  | 92 ++++++++++++++++++++
 .../vagrant/src/main/vagrant/servers.yaml       | 27 +++---
 4 files changed, 127 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/16d1e913/brooklyn-dist/vagrant/src/main/vagrant/README.md
----------------------------------------------------------------------
diff --git a/brooklyn-dist/vagrant/src/main/vagrant/README.md b/brooklyn-dist/vagrant/src/main/vagrant/README.md
index b446ab8..2f5573c 100644
--- a/brooklyn-dist/vagrant/src/main/vagrant/README.md
+++ b/brooklyn-dist/vagrant/src/main/vagrant/README.md
@@ -1,63 +1,41 @@
 
 # [![**Brooklyn**](https://brooklyn.apache.org/style/img/apache-brooklyn-logo-244px-wide.png)](http://brooklyn.apache.org/)
 
-### Using Vagrant with Brooklyn -SNAPSHOT releases
-Due to the absence of a single source for snapshots (i.e. locally built vs. [periodically
published archives](https://brooklyn.apache.org/v/0.9.0-SNAPSHOT/misc/download.html)), we
require that you override the supplied `servers.yaml` to explicitly point at your desired
`-SNAPSHOT` release.
+### Using Vagrant with Brooklyn -SNAPSHOT builds
 
-Full releases use the `BROOKLYN_VERSION` environment variable to download the associated
`-bin` artifact from the closest Apache mirror, if this environment variable is set to a `-SNAPSHOT`
we abort creating the Brooklyn Vagrant VM.
-
-##### Installing from local file
-For example to install from a locally built `-dist` archive:
-
-1. Copy the SNAPSHOT `-dist` archive to the same directory as the `Vagrantfile`
-
-   ```
-   cp  ~/Workspaces/incubator-brooklyn/brooklyn-dist/dist/target/brooklyn-dist-0.9.0-SNAPSHOT-dist.tar.gz
.
-   ```
-
-2. Delete the `BROOKLYN_VERSION:` environment variable from `servers.yaml`. For example:
+##### Install a community-managed version from Maven
+1. No action is required other than setting the  `BROOKLYN_VERSION:` environment variable
in `servers.yaml` to a `-SNAPSHOT` version. For example:
 
    ```
    env:
      BROOKLYN_VERSION: 0.9.0-SNAPSHOT
    ```
 
-3. Update `servers.yaml` to install from the `-dist` archive. For example, replace:
-   ```
-   - curl -s -S -J -O -L "https://www.apache.org/dyn/closer.cgi?action=download&filename=brooklyn/apache-brooklyn-${BROOKLYN_VERSION}/apache-brooklyn-${BROOKLYN_VERSION}-bin.tar.gz"
-   - tar zxf apache-brooklyn-${BROOKLYN_VERSION}-bin.tar.gz
-   - ln -s apache-brooklyn-${BROOKLYN_VERSION}-bin apache-brooklyn
-   ```
-   with:
-   ```
-   - cp /vagrant/brooklyn-dist-0.9.0-SNAPSHOT-dist.tar.gz .
-   - tar zxf brooklyn-dist-0.9.0-SNAPSHOT-dist.tar.gz
-   - ln -s brooklyn-dist-0.9.0-SNAPSHOT apache-brooklyn
-   ```
-
-4. You may proceed to use the `Vagrantfile` as normal; `vagrant up`, `vagrant destroy` etc.
+2. You may proceed to use the `Vagrantfile` as normal; `vagrant up`, `vagrant destroy` etc.
 
-##### Installing from URL
-For example to install from a published `-SHAPSHOT` archive:
+##### Install a locally built `-dist.tar.gz`
 
-1. Delete the `BROOKLYN_VERSION:` environment variable from `servers.yaml`. For example:
+1. Set the `BROOKLYN_VERSION:` environment variable in `servers.yaml` to your current `-SNAPSHOT`
version. For example:
 
    ```
    env:
      BROOKLYN_VERSION: 0.9.0-SNAPSHOT
    ```
 
-2. Update `servers.yaml` to install from URL. For example, replace:
+2. Set the `INSTALL_FROM_LOCAL_DIST:` environment variable in `servers.yaml` to `true`. For
example:
+
    ```
-   - curl -s -S -J -O -L "https://www.apache.org/dyn/closer.cgi?action=download&filename=brooklyn/apache-brooklyn-${BROOKLYN_VERSION}/apache-brooklyn-${BROOKLYN_VERSION}-bin.tar.gz"
-   - tar zxf apache-brooklyn-${BROOKLYN_VERSION}-bin.tar.gz
-   - ln -s apache-brooklyn-${BROOKLYN_VERSION}-bin apache-brooklyn
+   env:
+     INSTALL_FROM_LOCAL_DIST: true
    ```
-   with:
+
+
+3. Copy your locally built `-dist.tar.gz` archive to the same directory as the Vagrantfile
(this directory is mounted in the Vagrant VM at `/vagrant/`).
+
+   For example to copy a locally built `0.9.0-SNAPSHOT` dist:
+
    ```
-   - curl -s -S -J -O -L "https://repository.apache.org/service/local/artifact/maven/redirect?r=snapshots&g=org.apache.brooklyn&a=brooklyn-dist&v=0.9.0-SNAPSHOT&c=dist&e=tar.gz"
-   - tar zxf brooklyn-dist-0.9.0-SNAPSHOT-dist.tar.gz
-   - ln -s brooklyn-dist-0.9.0-SNAPSHOT apache-brooklyn
+   cp ~/.m2/repository/org/apache/brooklyn/brooklyn-dist/0.9.0-SNAPSHOT/brooklyn-dist-0.9.0-SNAPSHOT-dist.tar.gz
.
    ```
 
-3. You may proceed to use the `Vagrantfile` as normal; `vagrant up`, `vagrant destroy` etc.
\ No newline at end of file
+4. You may proceed to use the `Vagrantfile` as normal; `vagrant up`, `vagrant destroy` etc.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/16d1e913/brooklyn-dist/vagrant/src/main/vagrant/Vagrantfile
----------------------------------------------------------------------
diff --git a/brooklyn-dist/vagrant/src/main/vagrant/Vagrantfile b/brooklyn-dist/vagrant/src/main/vagrant/Vagrantfile
index 7f5dbb0..fb35a15 100644
--- a/brooklyn-dist/vagrant/src/main/vagrant/Vagrantfile
+++ b/brooklyn-dist/vagrant/src/main/vagrant/Vagrantfile
@@ -39,10 +39,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   yaml_cfg["servers"].each do |server|
     config.vm.define server["name"] do |server_config|
 
-      if server["shell"] && server["shell"]["env"]["BROOKLYN_VERSION"] =~ /SNAPSHOT/i
-        raise Vagrant::Errors::VagrantError.new, "Deploying Brooklyn SNAPSHOTS is not supported
without a manual update to servers.yaml. See README for instructions."
-      end
-
       server_config.vm.box = server["box"]
 
       server_config.vm.box_check_update = yaml_cfg["default_config"]["check_newer_vagrant_box"]

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/16d1e913/brooklyn-dist/vagrant/src/main/vagrant/files/install_brooklyn.sh
----------------------------------------------------------------------
diff --git a/brooklyn-dist/vagrant/src/main/vagrant/files/install_brooklyn.sh b/brooklyn-dist/vagrant/src/main/vagrant/files/install_brooklyn.sh
new file mode 100755
index 0000000..9c52017
--- /dev/null
+++ b/brooklyn-dist/vagrant/src/main/vagrant/files/install_brooklyn.sh
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+
+#
+# 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_VERSION=""
+INSTALL_FROM_LOCAL_DIST="false"
+TMP_ARCHIVE_NAME=apache-brooklyn.tar.gz
+
+do_help() {
+  echo "./install.sh -v <Brooklyn Version> [-l <install from local file: true|false>]"
+  exit 1
+}
+
+while getopts ":hv:l:" opt; do
+    case "$opt" in
+    v)  BROOKLYN_VERSION=$OPTARG ;;
+        # using a true/false argopt rather than just flag to allow easier integration with
servers.yaml config
+    l)  INSTALL_FROM_LOCAL_DIST=$OPTARG ;;
+    h)  do_help;;
+    esac
+done
+
+# Exit if any step fails
+set -e
+
+if [ "x${BROOKLYN_VERSION}" == "x" ]; then
+  echo "Error: you must supply a Brooklyn version [-v]"
+  do_help
+fi
+
+if [ ! "${INSTALL_FROM_LOCAL_DIST}" == "true" ]; then
+  if [ ! -z "${BROOKLYN_VERSION##*-SNAPSHOT}" ] ; then
+    # url for official release versions
+    BROOKLYN_URL="https://www.apache.org/dyn/closer.lua?action=download&filename=brooklyn/apache-brooklyn-${BROOKLYN_VERSION}/apache-brooklyn-${BROOKLYN_VERSION}-bin.tar.gz"
+    BROOKLYN_DIR="apache-brooklyn-${BROOKLYN_VERSION}-bin"
+  else
+    # url for community-managed snapshots
+    BROOKLYN_URL="https://repository.apache.org/service/local/artifact/maven/redirect?r=snapshots&g=org.apache.brooklyn&a=brooklyn-dist&v=${BROOKLYN_VERSION}&c=dist&e=tar.gz"
+    BROOKLYN_DIR="brooklyn-dist-${BROOKLYN_VERSION}"
+  fi
+else
+  echo "Installing from a local -dist archive [ /vagrant/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz]"
+  # url to install from mounted /vagrant dir
+  BROOKLYN_URL="file:///vagrant/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
+  BROOKLYN_DIR="brooklyn-dist-${BROOKLYN_VERSION}"
+
+  # ensure local file exists
+  if [ ! -f /vagrant/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz ]; then
+    echo "Error: file not found /vagrant/brooklyn-dist-${BROOKLYN_VERSION}-dist.tar.gz"
+    exit 1
+  fi
+fi
+
+echo "Installing Apache Brooklyn version ${BROOKLYN_VERSION} from [${BROOKLYN_URL}]"
+
+echo "Downloading Brooklyn release archive"
+curl --fail --silent --show-error --location --output ${TMP_ARCHIVE_NAME} "${BROOKLYN_URL}"
+echo "Extracting Brooklyn release archive"
+tar zxf ${TMP_ARCHIVE_NAME}
+
+echo "Creating Brooklyn dirs and symlinks"
+ln -s ${BROOKLYN_DIR} apache-brooklyn
+sudo mkdir -p /var/log/brooklyn
+sudo chown -R vagrant:vagrant /var/log/brooklyn
+mkdir -p /home/vagrant/.brooklyn
+
+echo "Copying default vagrant Brooklyn properties file"
+cp /vagrant/files/brooklyn.properties /home/vagrant/.brooklyn/
+chmod 600 /home/vagrant/.brooklyn/brooklyn.properties
+
+echo "Installing JRE"
+sudo sh -c 'export DEBIAN_FRONTEND=noninteractive; apt-get install --yes openjdk-8-jre-headless'
+
+echo "Copying Brooklyn systemd service unit file"
+sudo cp /vagrant/files/brooklyn.service /etc/systemd/system/brooklyn.service
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/16d1e913/brooklyn-dist/vagrant/src/main/vagrant/servers.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-dist/vagrant/src/main/vagrant/servers.yaml b/brooklyn-dist/vagrant/src/main/vagrant/servers.yaml
index 5203171..3959fff 100644
--- a/brooklyn-dist/vagrant/src/main/vagrant/servers.yaml
+++ b/brooklyn-dist/vagrant/src/main/vagrant/servers.yaml
@@ -16,6 +16,21 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+#
+# Default Config
+#   check_newer_vagrant_box
+#     enable/disable the vagrant check for an updated box
+#   run_os_update
+#     enable/disable running a yum/apt-get update on box start
+#
+# Brooklyn Server Config
+#   shell:env:BROOKLYN_VERSION
+#     specifies the version of Brooklyn to install, be aware that for SNAPSHOTS you
+#     may wish to download a local -dist.tar.gz for the latest version.
+#   shell:env:INSTALL_FROM_LOCAL_DIST
+#     if set to `true` Vagrant will install from a local -dist.tar.gz stored in /vagrant
+#     on the guest VM (which is mounted from the Vagrantfile directory). You must
+#     ensure that a -dist.tar.gz archive has been copied to this directory on your host.
 
 ---
 default_config:
@@ -30,17 +45,9 @@ servers:
     shell:
       env:
         BROOKLYN_VERSION: 0.9.0-SNAPSHOT
+        INSTALL_FROM_LOCAL_DIST: false
       cmd:
-        - sudo sh -c 'export DEBIAN_FRONTEND=noninteractive; apt-get install --yes openjdk-8-jre-headless'
-        - curl -s -S -J -O -L "https://www.apache.org/dyn/closer.cgi?action=download&filename=brooklyn/apache-brooklyn-${BROOKLYN_VERSION}/apache-brooklyn-${BROOKLYN_VERSION}-bin.tar.gz"
-        - tar zxf apache-brooklyn-${BROOKLYN_VERSION}-bin.tar.gz
-        - ln -s apache-brooklyn-${BROOKLYN_VERSION}-bin apache-brooklyn
-        - sudo mkdir -p /var/log/brooklyn
-        - sudo chown -R vagrant:vagrant /var/log/brooklyn
-        - sudo cp /vagrant/files/brooklyn.service /etc/systemd/system/brooklyn.service
-        - mkdir -p /home/vagrant/.brooklyn
-        - cp /vagrant/files/brooklyn.properties /home/vagrant/.brooklyn/
-        - chmod 600 /home/vagrant/.brooklyn/brooklyn.properties
+        - /vagrant/files/install_brooklyn.sh -v ${BROOKLYN_VERSION} -l ${INSTALL_FROM_LOCAL_DIST}
         - sudo systemctl start brooklyn
         - sudo systemctl enable brooklyn
   - name: byon1


Mime
View raw message