Repository: stratos Updated Branches: refs/heads/master c3158ec7b -> 1c802d6a8
Add first cut of a docker image for a puppet master Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3528a20c Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3528a20c Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3528a20c Branch: refs/heads/master Commit: 3528a20c92454331d620ff61fe25cc2bdc618db9 Parents: b60c67b Author: Chris Snow <[email protected]> Authored: Sun Aug 3 15:52:42 2014 +0000 Committer: Chris Snow <[email protected]> Committed: Sun Aug 3 15:55:47 2014 +0000 ---------------------------------------------------------------------- tools/stratos-docker-images/puppet/Dockerfile | 51 +++++++++++++++++ .../puppet/docker-build.sh | 60 ++++++++++++++++++++ .../puppet/files/.gitignore | 25 ++++++++ tools/stratos-docker-images/puppet/run | 58 +++++++++++++++++++ .../stratos-docker-images/puppet/run-example.sh | 46 +++++++++++++++ tools/stratos-docker-images/run-example.sh | 14 +++++ 6 files changed, 254 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/3528a20c/tools/stratos-docker-images/puppet/Dockerfile ---------------------------------------------------------------------- diff --git a/tools/stratos-docker-images/puppet/Dockerfile b/tools/stratos-docker-images/puppet/Dockerfile new file mode 100755 index 0000000..2fbd4d5 --- /dev/null +++ b/tools/stratos-docker-images/puppet/Dockerfile @@ -0,0 +1,51 @@ +# ---------------------------------------------------------------------------- +# +# 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. +# +# ---------------------------------------------------------------------------- + +FROM ubuntu:14.04 + +RUN apt-get update -qq +RUN apt-get install -y wget + +RUN wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb +RUN dpkg -i puppetlabs-release-precise.deb +RUN apt-get update -qq +RUN apt-get install -y puppetmaster + +RUN mkdir -p /etc/puppet/modules/agent/files +RUN mkdir -p /etc/puppet/modules/java/files +RUN mkdir -p /etc/puppet/modules/tomcat/files + +COPY files/manifests /etc/puppet/manifests +COPY files/modules /etc/puppet/modules + +ADD files/jdk-7u51-linux-x64.tar.gz /etc/puppet/modules/java/files/ +ADD files/apache-tomcat-7.0.52.tar.gz /etc/puppet/modules/tomcat/files/ + +ADD files/agentfiles.tgz /tmp/ + +RUN mv /tmp/apache-stratos-cartridge-agent-*.zip /etc/puppet/modules/agent/files/ +RUN mv /tmp/apache-stratos-load-balancer-*.zip /etc/puppet/modules/agent/files/ + +ADD run /usr/local/bin/run +RUN chmod +x /usr/local/bin/run + +CMD ["/usr/local/bin/run"] + http://git-wip-us.apache.org/repos/asf/stratos/blob/3528a20c/tools/stratos-docker-images/puppet/docker-build.sh ---------------------------------------------------------------------- diff --git a/tools/stratos-docker-images/puppet/docker-build.sh b/tools/stratos-docker-images/puppet/docker-build.sh new file mode 100755 index 0000000..4ea8c27 --- /dev/null +++ b/tools/stratos-docker-images/puppet/docker-build.sh @@ -0,0 +1,60 @@ +#!/bin/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. +# +# ---------------------------------------------------------------------------- + +set -e # exit on error + +if [[ -z $STRATOS_SOURCE ]]; then + echo "STRATOS_SOURCE environment variable must be set" + exit 1 +fi + +ACTIVEMQ_URL="http://archive.apache.org/dist/activemq/5.9.1/apache-activemq-5.9.1-bin.tar.gz" + +MYSQLJ_URL="http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.29/mysql-connector-java-5.1.29.jar" + +# if you change the tomcat version, you will need to change the version in the Dockerfile too +TOMCAT_URL="http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.52/bin/apache-tomcat-7.0.52.tar.gz" + +HAWTBUF_URL="http://repo1.maven.org/maven2/org/fusesource/hawtbuf/hawtbuf/1.2/hawtbuf-1.2.jar" + +# if you change the JDK version, you will need to change the version in the Dockerfile too +JDK_URL="http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz" + +wget -N -c -P files $TOMCAT_URL + +wget -N -c -P files \ + --no-cookies --no-check-certificate \ + --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ + ${JDK_URL} + +cp -rf $STRATOS_SOURCE/tools/puppet3/manifests files/ +cp -rf $STRATOS_SOURCE/tools/puppet3/modules files/ + +cp -f $STRATOS_SOURCE/products/cartridge-agent/modules/distribution/target/apache-stratos-cartridge-agent-*.zip files/ + +cp -f $STRATOS_SOURCE/products/load-balancer/modules/distribution/target/apache-stratos-load-balancer-*.zip files/ + +cd files/ +tar -cvzf agentfiles.tgz apache-stratos-cartridge-agent-*.zip apache-stratos-load-balancer-*.zip +cd .. + +sudo docker build -t=apachestratos/puppet . http://git-wip-us.apache.org/repos/asf/stratos/blob/3528a20c/tools/stratos-docker-images/puppet/files/.gitignore ---------------------------------------------------------------------- diff --git a/tools/stratos-docker-images/puppet/files/.gitignore b/tools/stratos-docker-images/puppet/files/.gitignore new file mode 100755 index 0000000..9fcfe3a --- /dev/null +++ b/tools/stratos-docker-images/puppet/files/.gitignore @@ -0,0 +1,25 @@ +# ---------------------------------------------------------------------------- +# +# 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. +# +# ---------------------------------------------------------------------------- + +# Ignore everything in this directory +* +# Except this file +!.gitignore http://git-wip-us.apache.org/repos/asf/stratos/blob/3528a20c/tools/stratos-docker-images/puppet/run ---------------------------------------------------------------------- diff --git a/tools/stratos-docker-images/puppet/run b/tools/stratos-docker-images/puppet/run new file mode 100755 index 0000000..80a4840 --- /dev/null +++ b/tools/stratos-docker-images/puppet/run @@ -0,0 +1,58 @@ +#!/bin/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. +# +# ---------------------------------------------------------------------------- + +set -e + +TIMEZONE=${TIMEZONE:-"Etc/UTC"} + +echo ============================= +echo Environment Variable Settings +echo ============================= +echo Setting DOMAIN=${DOMAIN} +echo Setting MASTERHOSTNAME=${MASTERHOSTNAME} +echo Setting TIMEZONE=${TIMEZONE} +echo Setting MB_HOSTNAME=${MB_HOSTNAME} +echo Setting MB_PORT=${MB_PORT} +echo Setting TRUSTSTORE_PASSWORD=${TRUSTSTORE_PASSWORD} +echo ============================= + +echo "${TIMEZONE}" > /etc/timezone +dpkg-reconfigure --frontend noninteractive tzdata + +sed -i 's/START=no/START=yes/' /etc/default/puppetmaster +echo -e "*.${DOMAIN}" > /etc/puppet/autosign.conf +sed -i "2i server=${MASTERHOSTNAME}" /etc/puppet/puppet.conf +sed -i "3i dns_alt_names=${MASTERHOSTNAME}" /etc/puppet/puppet.conf + + +PUPPET_FILE=/etc/puppet/manifests/nodes/base.pp + +# TODO java version is hard coded +sed -i -E "s:(\s*[$]java_name.*=).*$:\1 \"jdk1.7.0_51\":g" $PUPPET_FILE +sed -i -E "s:(\s*[$]java_distribution.*=).*$:\1 \"jdk-7u51-linux-x64.tar.gz\":g" $PUPPET_FILE + +sed -i -E "s:(\s*[$]local_package_dir.*=).*$:\1 \"/mnt/packs\":g" $PUPPET_FILE +sed -i -E "s:(\s*[$]mb_ip.*=).*$:\1 \"$MB_HOSTNAME\":g" $PUPPET_FILE +sed -i -E "s:(\s*[$]mb_port.*=).*$:\1 \"$MB_PORT\":g" $PUPPET_FILE +sed -i -E "s:(\s*[$]truststore_password.*=).*$:\1 \"$TRUSTSTORE_PASSWORD\":g" $PUPPET_FILE + +puppet master --no-daemonize --logdest console http://git-wip-us.apache.org/repos/asf/stratos/blob/3528a20c/tools/stratos-docker-images/puppet/run-example.sh ---------------------------------------------------------------------- diff --git a/tools/stratos-docker-images/puppet/run-example.sh b/tools/stratos-docker-images/puppet/run-example.sh new file mode 100755 index 0000000..d42f436 --- /dev/null +++ b/tools/stratos-docker-images/puppet/run-example.sh @@ -0,0 +1,46 @@ +#!/bin/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. +# +# ---------------------------------------------------------------------------- + +DOMAIN=stratos.com +MASTERHOSTNAME=puppet.stratos.com +MB_HOSTNAME= +MB_PORT= +TRUSTSTORE_PASSWORD=wso2carbon + + +# To run interactively: +# sudo docker run -i -t -e "DOMAIN=${DOMAIN}" -e "MASTERHOSTNAME=${MASTERHOSTNAME}" -p 8140 apachestratos/puppet /bin/bash + +PUPPET_ID=$(sudo docker run -d -e "DOMAIN=${DOMAIN}" -e "MASTERHOSTNAME=${MASTERHOSTNAME}" -p 8140 apachestratos/puppet) +PUPPET_IP_ADDR=$(sudo docker inspect --format '{{ .NetworkSettings.Gateway }}' $PUPPET_ID) +PUPPET_PORT=$(sudo docker port $PUPPET_ID 8140 | awk -F':' '{ print $2 }') + +echo Puppet container ID: ${PUPPET_ID} +echo Puppet master reachable on IP address: ${PUPPET_IP_ADDR} +echo Puppet master reachable on port: ${PUPPET_PORT} + + +echo Connection test: +echo puppet agent --server puppet.stratos.com --masterport ${PUPPET_PORT} --test --verbose --debug + +echo View container logs: +echo sudo docker logs -f ${PUPPET_ID} http://git-wip-us.apache.org/repos/asf/stratos/blob/3528a20c/tools/stratos-docker-images/run-example.sh ---------------------------------------------------------------------- diff --git a/tools/stratos-docker-images/run-example.sh b/tools/stratos-docker-images/run-example.sh index 714fa8b..a47a054 100755 --- a/tools/stratos-docker-images/run-example.sh +++ b/tools/stratos-docker-images/run-example.sh @@ -33,6 +33,20 @@ MB_IP_ADDR=$(sudo docker inspect --format '{{ .NetworkSettings.Gateway }}' $MB_I MB_PORT=$(sudo docker port $MB_ID 61616 | awk -F':' '{ print $2 }') # +# Start Puppet Container +# + +DOMAIN=stratos.com +MASTERHOSTNAME=puppet.stratos.com +MB_HOSTNAME=${MB_IP_ADDR} +MB_PORT=${MB_PORT} +TRUSTSTORE_PASSWORD=wso2carbon + +PUPPET_ID=$(sudo docker run -d -e "DOMAIN=${DOMAIN}" -e "MASTERHOSTNAME=${MASTERHOSTNAME}" -e "MB_HOSTNAME=${MB_HOSTNAME}" -e "MB_PORT=${MB_PORT}" -e "TRUSTSTORE_PASSWORD=${TRUSTSTORE_PASSWORD}" -p 8140 apachestratos/puppet) +PUPPET_IP_ADDR=$(sudo docker inspect --format '{{ .NetworkSettings.Gateway }}' $PUPPET_ID) +PUPPET_PORT=$(sudo docker port $PUPPET_ID 8140 | awk -F':' '{ print $2 }') + +# # Start mysql docker container # (skip this step if you already have mysql already installed that has a Stratos schema) #
