From b0042a22e57363ac67644eee7ddb659e3d46f9bb Mon Sep 17 00:00:00 2001 From: Thomas Bouron Date: Tue, 12 Sep 2017 14:54:19 +0100 Subject: [PATCH] Update vagrant configuration (centos 7.x) and use the new RPM package to install Brooklyn --- vagrant/src/main/vagrant/README.md | 6 +- .../main/vagrant/files/brooklyn.properties | 23 ------- .../src/main/vagrant/files/brooklyn.service | 38 ------------ .../main/vagrant/files/install_brooklyn.sh | 60 +++++++++++-------- vagrant/src/main/vagrant/files/logback.xml | 32 ---------- vagrant/src/main/vagrant/servers.yaml | 4 +- 6 files changed, 38 insertions(+), 125 deletions(-) delete mode 100644 vagrant/src/main/vagrant/files/brooklyn.properties delete mode 100644 vagrant/src/main/vagrant/files/brooklyn.service delete mode 100644 vagrant/src/main/vagrant/files/logback.xml diff --git a/vagrant/src/main/vagrant/README.md b/vagrant/src/main/vagrant/README.md index de5c9edd7f..6f77f38146 100644 --- a/vagrant/src/main/vagrant/README.md +++ b/vagrant/src/main/vagrant/README.md @@ -13,7 +13,7 @@ 2. You may proceed to use the `Vagrantfile` as normal; `vagrant up`, `vagrant destroy` etc. -##### Install a locally built `-dist.tar.gz` +##### Install a locally built RPM package 1. Set the `BROOKLYN_VERSION:` environment variable in `servers.yaml` to your current `-SNAPSHOT` version. For example: @@ -30,12 +30,12 @@ ``` -3. Copy your locally built `apache-brooklyn-.tar.gz` archive to the same directory as the Vagrantfile (this directory is mounted in the Vagrant VM at `/vagrant/`). +3. Copy your locally built `apache-brooklyn-.noarch.rpm` 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.12.0-SNAPSHOT` dist: ``` - cp ~/.m2/repository/org/apache/brooklyn/apache-brooklyn/0.12.0-SNAPSHOT/apache-brooklyn-0.12.0-SNAPSHOT.tar.gz . + cp ~/.m2/repository/org/apache/brooklyn/rpm-packaging/0.12.0-SNAPSHOT/rpm-packaging-0.12.0-SNAPSHOT-noarch.rpm ./apache-brooklyn-0.12.0-SNAPSHOT.noarch.rpm ``` 4. You may proceed to use the `Vagrantfile` as normal; `vagrant up`, `vagrant destroy` etc. diff --git a/vagrant/src/main/vagrant/files/brooklyn.properties b/vagrant/src/main/vagrant/files/brooklyn.properties deleted file mode 100644 index 0784ff300f..0000000000 --- a/vagrant/src/main/vagrant/files/brooklyn.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# 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. -# - -# Disabling security on the Vagrant Brooklyn instance for training purposes -brooklyn.webconsole.security.provider = org.apache.brooklyn.rest.security.provider.AnyoneSecurityProvider - -# Note: BYON locations are loaded from the files/vagrant-catalog.bom on startup \ No newline at end of file diff --git a/vagrant/src/main/vagrant/files/brooklyn.service b/vagrant/src/main/vagrant/files/brooklyn.service deleted file mode 100644 index 8a844e609d..0000000000 --- a/vagrant/src/main/vagrant/files/brooklyn.service +++ /dev/null @@ -1,38 +0,0 @@ -# -# 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. -# -[Unit] -Description=Apache Brooklyn Service -Documentation=https://brooklyn.apache.org/documentation/index.html - -[Service] -Type=simple -WorkingDirectory=/home/vagrant/apache-brooklyn/ -Environment="EXTRA_JAVA_OPTS=-Dbrooklyn.location.localhost.address=127.0.0.1 -XX:SoftRefLRUPolicyMSPerMB=1 -Xms256m -Xmx2g" -Environment="KARAF_HOME=/home/vagrant/apache-brooklyn/" -Environment="KARAF_ETC=/home/vagrant/apache-brooklyn/etc/" -Environment="KARAF_REDIRECT=/dev/null" -Environment="BROOKLYN_PERSISTENCE_DIR=/vagrant/brooklyn-persisted-state" -ExecStart=/home/vagrant/apache-brooklyn/bin/karaf server >> "$KARAF_REDIRECT" 2>&1 -Restart=always -User=vagrant -Group=vagrant -UMask=0066 - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/vagrant/src/main/vagrant/files/install_brooklyn.sh b/vagrant/src/main/vagrant/files/install_brooklyn.sh index 300c000c5d..eb88d66b3f 100755 --- a/vagrant/src/main/vagrant/files/install_brooklyn.sh +++ b/vagrant/src/main/vagrant/files/install_brooklyn.sh @@ -21,7 +21,7 @@ BROOKLYN_VERSION="" INSTALL_FROM_LOCAL_DIST="false" -TMP_ARCHIVE_NAME=apache-brooklyn.tar.gz +TMP_ARCHIVE_NAME=apache-brooklyn.rpm do_help() { echo "./install.sh -v [-l ]" @@ -48,45 +48,53 @@ 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" + BROOKLYN_URL="https://www.apache.org/dyn/closer.lua?action=download&filename=brooklyn/apache-brooklyn-${BROOKLYN_VERSION}/apache-brooklyn-${BROOKLYN_VERSION}.noarch.rpm" else # url for community-managed snapshots - BROOKLYN_URL="https://repository.apache.org/service/local/artifact/maven/redirect?r=snapshots&g=org.apache.brooklyn&a=apache-brooklyn&v=${BROOKLYN_VERSION}&e=tar.gz" - BROOKLYN_DIR="apache-brooklyn-${BROOKLYN_VERSION}" + BROOKLYN_URL="https://repository.apache.org/service/local/artifact/maven/redirect?r=snapshots&g=org.apache.brooklyn&a=rpm-packaging&v=${BROOKLYN_VERSION}&c=noarch&e=rpm" fi else - echo "Installing from a local -dist archive [ /vagrant/apache-brooklyn-${BROOKLYN_VERSION}.tar.gz]" + echo "Installing from a local -dist archive [ /vagrant/apache-brooklyn-${BROOKLYN_VERSION}.noarch.rpm]" # url to install from mounted /vagrant dir - BROOKLYN_URL="file:///vagrant/apache-brooklyn-${BROOKLYN_VERSION}.tar.gz" - BROOKLYN_DIR="apache-brooklyn-${BROOKLYN_VERSION}" + BROOKLYN_URL="file:///vagrant/apache-brooklyn-${BROOKLYN_VERSION}.noarch.rpm" # ensure local file exists - if [ ! -f /vagrant/apache-brooklyn-${BROOKLYN_VERSION}.tar.gz ]; then - echo "Error: file not found /vagrant/apache-brooklyn-${BROOKLYN_VERSION}.tar.gz" + if [ ! -f /vagrant/apache-brooklyn-${BROOKLYN_VERSION}.noarch.rpm ]; then + echo "Error: file not found /vagrant/apache-brooklyn-${BROOKLYN_VERSION}.noarch.rpm" 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 "Restarting Syslog" +sudo systemctl restart rsyslog + +echo "Updating Yum" +sudo yum -y update + +echo "Install Java" +sudo yum install -y java-1.8.0-openjdk-headless + +echo "Install Apache Brooklyn version ${BROOKLYN_VERSION} from [${BROOKLYN_URL}]" +sudo yum -y install ${TMP_ARCHIVE_NAME} -echo "Copying default vagrant Brooklyn properties file" -cp /vagrant/files/brooklyn.properties /home/vagrant/.brooklyn/ -chmod 600 /home/vagrant/.brooklyn/brooklyn.properties +echo "Configure catalog" +sudo cp /vagrant/files/vagrant-catalog.bom /opt/brooklyn/catalog/vagrant-catalog.bom +sudo chown brooklyn:brooklyn /opt/brooklyn/catalog/vagrant-catalog.bom +sudo chmod 740 /opt/brooklyn/catalog/vagrant-catalog.bom +echo ' - file:catalog/vagrant-catalog.bom' | sudo tee -a /etc/brooklyn/default.catalog.bom -echo "Installing JRE" -sudo sh -c 'yum -y install java-1.8.0-openjdk-headless' +echo "Starting Apache Brooklyn..." +sudo systemctl start brooklyn + +echo "Waiting for Apache Brooklyn to start..." +sleep 10 + +while ! (sudo grep "BundleEvent STARTED - org.apache.brooklyn.karaf-init" /var/log/brooklyn/brooklyn.debug.log) > /dev/null ; do + sleep 10 + echo ".... waiting for Apache Brooklyn to start at `date`" +done -echo "Copying Brooklyn systemd service unit file" -sudo cp /vagrant/files/brooklyn.service /etc/systemd/system/brooklyn.service +echo "Apache Brooklyn started!" \ No newline at end of file diff --git a/vagrant/src/main/vagrant/files/logback.xml b/vagrant/src/main/vagrant/files/logback.xml deleted file mode 100644 index 1560d8b6f3..0000000000 --- a/vagrant/src/main/vagrant/files/logback.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/vagrant/src/main/vagrant/servers.yaml b/vagrant/src/main/vagrant/servers.yaml index 0773e30c2c..68cfa59c46 100644 --- a/vagrant/src/main/vagrant/servers.yaml +++ b/vagrant/src/main/vagrant/servers.yaml @@ -47,14 +47,12 @@ servers: autocorrect: true shell: env: - BROOKLYN_VERSION: "1.0.0-SNAPSHOT" + BROOKLYN_VERSION: "1.0.0-SNAPSHOT" # BROOKLYN_VERSION INSTALL_FROM_LOCAL_DIST: false cmd: - ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsa - chmod a+x /vagrant/files/install_brooklyn.sh - /vagrant/files/install_brooklyn.sh -v ${BROOKLYN_VERSION} -l ${INSTALL_FROM_LOCAL_DIST} - - sudo systemctl start brooklyn - - sudo systemctl enable brooklyn - name: byon1 box: bento/centos-7.3 ram: 512