├── vagrant ├── fileserver.conf ├── config.yaml.sample ├── README.md └── Vagrantfile ├── .gitignore ├── validate-yaml.rb ├── hiera.yaml ├── manifests └── site.pp ├── scripts └── base.sh ├── README.md ├── package.xml ├── pom.xml ├── setup.sh └── LICENSE /vagrant/fileserver.conf: -------------------------------------------------------------------------------- 1 | [files] 2 | path /puppet/files 3 | allow * 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse Project Files 2 | .project 3 | .classpath 4 | .settings/ 5 | .metadata 6 | *.class 7 | 8 | # IntelliJ IDEA Project Files 9 | .idea/ 10 | *.iml 11 | *.ipr 12 | *.iws 13 | *.swp 14 | 15 | # Backup files 16 | *~ 17 | 18 | # Package Files # 19 | *.jar 20 | *.war 21 | *.ear 22 | 23 | target/ 24 | 25 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 26 | hs_err_pid* 27 | 28 | # Vagrant user data 29 | vagrant/.vagrant 30 | vagrant/config.yaml -------------------------------------------------------------------------------- /validate-yaml.rb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | begin 16 | require 'yaml' 17 | 18 | Dir.glob('**/*.yaml') do |yaml_file| 19 | YAML.load_file("#{yaml_file}") 20 | end 21 | 22 | rescue => e 23 | puts "Error during processing: #{$!}" 24 | end 25 | -------------------------------------------------------------------------------- /hiera.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | :hierarchy: 17 | - "wso2/%{::product_name}/%{::pattern}/%{::product_profile}" 18 | - "wso2/%{::product_name}/%{::pattern}/common" 19 | - "wso2/common" 20 | :backends: 21 | - yaml 22 | :yaml: 23 | :datadir: "hieradata/%{::environment}" -------------------------------------------------------------------------------- /manifests/site.pp: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | # 3 | # Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # ------------------------------------------------------------------------------ 18 | 19 | # Default node definition 20 | node "default" { 21 | if $::use_hieradata == "true" { 22 | hiera_include('classes') 23 | 24 | } else { 25 | class { "::${::product_name}": } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vagrant/config.yaml.sample: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | servers: 17 | - 18 | enabled: true 19 | hostname: default 20 | facters: 21 | product_name: wso2am_runtime 22 | product_version: 2.1.0 23 | product_profile: default 24 | environment: dev 25 | platform: default 26 | use_hieradata: false 27 | pattern: pattern-0 28 | box: ubuntu/trusty64 29 | ip: 192.168.100.2 30 | ram: 2048 31 | cpu: 1 32 | 33 | # - 34 | # enabled: false 35 | # hostname: product.dev.wso2.org 36 | # facters: 37 | # product_name: wso2product 38 | # product_version: version 39 | # product_profile: profile 40 | # environment: dev 41 | # platform: default 42 | # use_hieradata: true 43 | # pattern: pattern-1 44 | # box: ubuntu/trusty64 45 | # ip: 192.168.100.3 46 | # ram: 2048 47 | # cpu: 1 48 | -------------------------------------------------------------------------------- /vagrant/README.md: -------------------------------------------------------------------------------- 1 | # Deploy WSO2 Products with Puppet using Vagrant 2 | 3 | This guide walks through the steps needed for deploying WSO2 products using Vagrant with VirtualBox as the provider. 4 | Puppet will be used as the provisioning method in Vagrant and Hiera as the configuration data store. 5 | 6 | 7 | ## Pre-requisites 8 | 9 | * **[Vagrant](https://www.vagrantup.com)** 10 | * **[Virtualbox](https://www.virtualbox.org)** Vagrant hypervisor 11 | 12 | 13 | ## How to Use 14 | 15 | 1. Create server configuration file: 16 | 17 | Rename `config.yaml.sample` to `config.yaml` and update the `/servers` section with required values. You can add more instances by adding more entries to `/servers` array. You can pass facters to Vagrant nodes through `/servers/*/facters` array. 18 | 19 | Additionally, you can copy a sample `config.yaml` file from the `vagrant-samples` folder found in puppet- repository for quickly running a product on Vagrant. 20 | 21 | 2. Download and copy Oracle JDK `1.8.0_112` distribution to the following path: 22 | 23 | ```` 24 | /modules/wso2base/files/jdk-8u112-linux-x64.tar.gz 25 | ```` 26 | 27 | 3. Download and copy required WSO2 product distributions to each Puppet module under `files` folder: 28 | 29 | ```` 30 | /modules/wso2esb/files 31 | /modules/wso2is/files 32 | ```` 33 | 34 | 4. Optionally update `/hieradata` with required product configurations. `default` profile every product can be run on Vagrant without any changes to the Hiera data. 35 | 36 | 5. Execute the following command to start the VMs: 37 | 38 | ```` 39 | vagrant up 40 | ```` -------------------------------------------------------------------------------- /scripts/base.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------ 3 | # 4 | # Copyright 2016 WSO2, Inc. (http://wso2.com) 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License 17 | 18 | # ------------------------------------------------------------------------ 19 | function echoDim () { 20 | if [ -z "$2" ]; then 21 | echo $'\e[2m'"${1}"$'\e[0m' 22 | else 23 | echo -n $'\e[2m'"${1}"$'\e[0m' 24 | fi 25 | } 26 | 27 | function echoError () { 28 | echo $'\e[1;31m'"${1}"$'\e[0m' 29 | } 30 | 31 | function echoWarn () { 32 | echo $'\e[1;33m'"${1}"$'\e[0m' 33 | } 34 | 35 | function echoSuccess () { 36 | echo $'\e[1;32m'"${1}"$'\e[0m' 37 | } 38 | 39 | function echoInfo () { 40 | echo $'\e[1;34m'"${1}"$'\e[0m' 41 | } 42 | 43 | function echoDot () { 44 | echoDim "." "append" 45 | } 46 | 47 | function echoBold () { 48 | echo $'\e[1m'"${1}"$'\e[0m' 49 | } 50 | 51 | function askBold () { 52 | echo -n $'\e[1m'"${1}"$'\e[0m' 53 | } 54 | 55 | function listFiles () { 56 | find "${1}" -maxdepth 1 -mindepth 1 \( ! -iname ".*" ! -iname "*.md" \)| rev | cut -d '/' -f1 | rev | awk NF 57 | } 58 | 59 | function listDirectories () { 60 | IFS=' ' read -r -a dirs <<< `ls -l --time-style="long-iso" $1 | egrep '^d' | awk '{print $8}'` 61 | for dir in "${dirs[@]}" 62 | do 63 | echo "${dir}" 64 | done 65 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WSO2 Puppet Common 2 | 3 | WSO2 Puppet Common repository provides files required for setting up a Puppet environment: 4 | 5 | - [manifests/site.pp](manifests/site.pp): Puppet site manifest 6 | - [scripts/base.sh](scripts/base.sh): Base bash script file which provides utility bash methods. 7 | - [setup.sh](setup.sh): The setup bash script for setting up a puppet environment for development work. 8 | - [vagrant](vagrant) A vagrant script for testing Puppet modules using VirtualBox. 9 | 10 | ## Getting Started 11 | 12 | Execute setup.sh to prepare a Puppet environment: 13 | 14 | ```bash 15 | Usage: ./setup.sh -p [product-name] -l [platform] 16 | 17 | Options: 18 | 19 | -p [REQUIRED] Comma separated list of product codes. [esb,is,apim,das][all] 20 | -l [OPTIONAL] Platform to setup Hiera data. If none given 'default' platform will be taken 21 | -v [OPTIONAL] Product version. If none given latest version will be taken. Multiple products not supported. 22 | -t [OPTIONAL] Product-puppet module release tag. Checkouts the tag into a detached HEAD state. 23 | 24 | Ex: ./setup.sh -p esb 25 | Ex: ./setup.sh -p esb -v 4.9.0 26 | Ex: ./setup.sh -p esb,apim -l kubernetes 27 | Ex: ./setup.sh -p apim -t v2.1.0 28 | Ex: ./setup.sh -p all 29 | ``` 30 | Finally go to the puppet-base module and checkout the compatible version of puppet-base module with the 31 | product-module version. 32 | 33 | ### Required Custom Facts 34 | 35 | Following custom Facts are required for the WSO2 Puppet modules to run. 36 | 37 | ```yaml 38 | product_name: Product name as defined in the product Puppet module 39 | product_version: Produce version 40 | product_profile: Product profile 41 | environment: Puppet environment 42 | platform: The platform to use. ex: default, kubernetes, mesos 43 | use_hieradata: Set to true to use Hiera as the data backend 44 | pattern: Product pattern as defined in the product Puppet module. 45 | ``` 46 | 47 | For example, for WSO2 API Manager pattern-0, the following set of Facts can be set. 48 | 49 | ```yaml 50 | product_name: wso2am_runtime 51 | product_version: 2.1.0 52 | product_profile: default 53 | environment: dev 54 | platform: default 55 | use_hieradata: false 56 | pattern: pattern-0 57 | ``` 58 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 17 | 20 | package 21 | 22 | zip 23 | 24 | false 25 | 26 | 27 | ${project.basedir}/manifests 28 | ${pom.artifactId}-${pom.version}/manifests/ 29 | 30 | ** 31 | 32 | 33 | 34 | ${project.basedir}/scripts 35 | ${pom.artifactId}-${pom.version}/scripts/ 36 | 37 | ** 38 | 39 | 40 | 41 | ${project.basedir}/vagrant 42 | ${pom.artifactId}-${pom.version}/vagrant/ 43 | 44 | ** 45 | 46 | 47 | 48 | 49 | 50 | 51 | ${project.basedir}/LICENSE 52 | ${pom.artifactId}-${pom.version}/ 53 | true 54 | 644 55 | 56 | 57 | ${project.basedir}/README.md 58 | ${pom.artifactId}-${pom.version}/ 59 | true 60 | 644 61 | 62 | 63 | ${project.basedir}/hiera.yaml 64 | ${pom.artifactId}-${pom.version}/ 65 | true 66 | 644 67 | 68 | 69 | ${project.basedir}/setup.sh 70 | ${pom.artifactId}-${pom.version}/ 71 | true 72 | 644 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /vagrant/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # -*- mode: ruby -*- 16 | # vi: set ft=ruby : 17 | 18 | require 'yaml' 19 | require 'fileutils' 20 | 21 | # load server config from YAML file 22 | CONFIGURATION_YAML = YAML.load_file('config.yaml') 23 | PUPPET_HOME = ENV['PUPPET_HOME'] 24 | if PUPPET_HOME == nil 25 | puts 'ERROR! PUPPET_HOME is not defined.' 26 | exit(1) 27 | end 28 | HIERADATA_PATH = ENV['HIERA_HOME'] || File.join(PUPPET_HOME, 'hieradata') 29 | PUPPET_FILESERVER_PATH = File.join(PUPPET_HOME, 'files') 30 | 31 | $puppet_lib_install_script = < /etc/facter/facts.d/public_ip.txt 39 | EOF 40 | 41 | puts "PUPPET_HOME set to #{PUPPET_HOME}" 42 | puts "HIERADATA_PATH set to #{HIERADATA_PATH}" 43 | puts "PUPPET_FILESERVER_PATH set to #{PUPPET_FILESERVER_PATH}" 44 | 45 | Vagrant.configure(2) do |config| 46 | CONFIGURATION_YAML['servers'].each do |server| 47 | if defined?(server['enabled']) && server['enabled'] != false 48 | puts 'Provisioning VirtualBox with hostname: ', server['hostname'] 49 | config.vm.define server['hostname'] do |server_config| 50 | server_config.vm.box = server['box'] 51 | server_config.vm.host_name = server['hostname'] 52 | server_config.vm.network :private_network, ip: server['ip'] 53 | server_config.vm.synced_folder HIERADATA_PATH, '/puppet/hieradata', id: 'hieradata', type: 'rsync' 54 | server_config.vm.synced_folder PUPPET_FILESERVER_PATH, '/puppet/files', id: 'puppet_fileserver' 55 | memory = server['ram'] ? server['ram'] : 256 56 | cpu = server['cpu'] ? server['cpu'] : 1 57 | 58 | server_config.vm.provider :virtualbox do |vb| 59 | vb.name = server['hostname'] 60 | vb.check_guest_additions = false 61 | vb.functional_vboxsf = false 62 | vb.gui = false 63 | vb.customize ['modifyvm', :id, '--groups', '/WSO2-Puppet-Dev'] 64 | vb.customize ['modifyvm', :id, '--memory', memory] 65 | vb.customize ['modifyvm', :id, '--cpus', cpu] 66 | end 67 | 68 | server_config.vm.provision :shell do |shell| 69 | shell.inline = $puppet_lib_install_script 70 | end 71 | 72 | server_config.vm.provision :puppet do |puppet| 73 | puppet.manifest_file = 'site.pp' 74 | puppet.manifests_path = File.join(PUPPET_HOME, 'manifests') 75 | puppet.module_path = File.join(PUPPET_HOME, 'modules') 76 | puppet.hiera_config_path = File.join(PUPPET_HOME, 'hiera.yaml') 77 | puppet.working_directory = '/puppet' 78 | puppet.options = %w(--verbose --fileserverconfig=/vagrant/fileserver.conf --debug --trace) 79 | 80 | # custom facts provided to Puppet 81 | puppet.facter = server['facters'] 82 | end 83 | end 84 | end 85 | end 86 | end 87 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 4.0.0 20 | 21 | org.wso2.puppet 22 | wso2-puppet-common 23 | pom 24 | 1.0.1-SNAPSHOT 25 | WSO2 Puppet Common 26 | WSO2 Puppet Common 27 | 28 | 29 | 30 | Apache License Version 2.0 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | 34 | 35 | 36 | 37 | 38 | maven-assembly-plugin 39 | true 40 | 2.5.3 41 | 42 | package.xml 43 | false 44 | 45 | 46 | 47 | create-archive 48 | package 49 | 50 | single 51 | 52 | 53 | 54 | 55 | 56 | org.codehaus.mojo 57 | exec-maven-plugin 58 | 1.2 59 | 60 | 61 | compile 62 | 63 | ruby 64 | ${validation.script.dir} 65 | 66 | validate-yaml.rb 67 | 68 | 69 | compile 70 | 71 | exec 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | pedantic 83 | 84 | 85 | 86 | org.apache.rat 87 | apache-rat-plugin 88 | 0.12 89 | 90 | 91 | 92 | WSO2 93 | WSO2 License 1.0 94 | 95 | 96 | Copyright WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 97 | WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 98 | WSO2, Inc. http://www.wso2.org 99 | WSO2 Inc. (http://wso2.com) All Rights Reserved. 100 | WSO2, Inc. (http://wso2.com) 101 | 102 | 103 | 104 | 105 | 106 | 107 | WSO2 License 1.0 108 | 109 | 110 | 111 | 112 | **/target/**/* 113 | **/.settings/**/* 114 | **/.project 115 | **/.classpath 116 | **/.git/**/* 117 | **/.vagrant/**/* 118 | **/README.md 119 | **/*.iml 120 | **/*.iws 121 | **/*.ipr 122 | **/.gitignore 123 | **/.gitkeep 124 | **/*.conf 125 | **/*.key 126 | **/*.json 127 | **/*.json.erb 128 | 129 | **/*.config.erb 130 | **/*.sql 131 | **/.idea/**/* 132 | **/.idea 133 | **/tlds/**/* 134 | **/*.log 135 | **/.gitmodules 136 | **/password-tmp.erb 137 | 138 | false 139 | 140 | 141 | 142 | verify 143 | 144 | check 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | central 157 | Maven Central Repository 158 | default 159 | http://repo1.maven.org/maven2 160 | 161 | true 162 | daily 163 | ignore 164 | 165 | 166 | 167 | wso2-nexus 168 | WSO2 Internal Repository 169 | http://maven.wso2.org/nexus/content/groups/wso2-public/ 170 | 171 | true 172 | daily 173 | ignore 174 | 175 | 176 | 177 | 178 | 179 | 180 | UTF-8 181 | ${project.basedir} 182 | 183 | 184 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------------ 3 | # 4 | # Copyright 2016 WSO2, Inc. (http://wso2.com) 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License 17 | 18 | # ------------------------------------------------------------------------ 19 | set -e 20 | self_path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 21 | source "${self_path}/scripts/base.sh" 22 | 23 | function getProductName() { 24 | case ${1} in 25 | esb) 26 | product_name="wso2esb" 27 | ;; 28 | apim) 29 | product_name="wso2am" 30 | ;; 31 | is) 32 | product_name="wso2is" 33 | ;; 34 | das) 35 | product_name="wso2das" 36 | ;; 37 | cep) 38 | product_name="wso2cep" 39 | ;; 40 | iot) 41 | product_name="wso2iot" 42 | ;; 43 | \?) 44 | product_name="" 45 | ;; 46 | esac 47 | } 48 | 49 | # Show usage and exit 50 | function showUsageAndExit() { 51 | echoError "Insufficient or invalid options provided!" 52 | echo 53 | echoBold "Usage: ./setup.sh -p [product-name] -l [platform]" 54 | echo 55 | 56 | echoBold "Options:" 57 | echo 58 | echo -en " -p\t" 59 | echo "[REQUIRED] Comma separated list of product codes. [esb,is,apim,das][all]" 60 | echo -en " -l\t" 61 | echo "[OPTIONAL] Platform to setup Hiera data. If none given 'default' platform will be taken" 62 | echo -en " -v\t" 63 | echo "[OPTIONAL] Product version. The version related branch will be checked out. If none given, latest version will 64 | be taken. Multiple products not supported." 65 | echo -en " -t\t" 66 | echo "[OPTIONAL] Product-puppet module release tag. Checkouts the tag into a detached HEAD state" 67 | echo 68 | 69 | echoBold "Ex: ./setup.sh -p esb " 70 | echoBold "Ex: ./setup.sh -p esb -v 4.9.0 " 71 | echoBold "Ex: ./setup.sh -p esb,apim -l kubernetes" 72 | echoBold "Ex: ./setup.sh -p all " 73 | echoBold "Ex: ./setup.sh -p apim -t v2.1.0" 74 | echo 75 | exit 1 76 | } 77 | 78 | function validatePuppetHome() { 79 | if [ ! -d "${1}" ]; then 80 | echoError "Invalid path provided for [PUPPET_HOME] ${1}" 81 | exit 1 82 | fi 83 | export PUPPET_HOME=${1} 84 | if [ "$(ls -A ${PUPPET_HOME})" ]; then 85 | echoDim "[PUPPET_HOME] $PUPPET_HOME directory is not empty. Continuing..." 86 | fi 87 | } 88 | 89 | # To checkout the git branch and switch between branches if it exists 90 | # $1 - Puppet module name (equivalent to product name) 91 | # $2 - product version (branch related to the given version will be checked out) 92 | function checkoutBranch() { 93 | pushd ${PUPPET_HOME}/modules/${1} 94 | if [[ ${2} == "latest" ]]; then 95 | if [[ `git branch --list master` ]]; then 96 | if [[ `git symbolic-ref --short -q HEAD` != "master" ]]; then 97 | echo "checking out master..." 98 | git checkout master 99 | fi 100 | else 101 | echo "creating branch master" 102 | git checkout -b master 103 | fi 104 | else 105 | if [[ `git branch --list v${2}` ]]; then 106 | if [[ `git symbolic-ref --short -q HEAD` != "${2}" ]]; then 107 | echo "checking out branch ${2}" 108 | git checkout v${2} 109 | fi 110 | else 111 | echo "creating branch ${2}" 112 | git checkout -b v${2} origin/v${2} || echoWarn "Puppet module for ${1} ${2} is not available" 113 | fi 114 | fi 115 | popd 116 | } 117 | 118 | # Checkout the release tag to a new branch 119 | # $1 - Puppet module name (equivalent to product name) 120 | # $2 - product release tag 121 | function checkoutTag(){ 122 | pushd ${PUPPET_HOME}/modules/${1} 123 | if [[ -n ${2} ]]; then 124 | if [[ `git tag -l ${2}` == ${2} ]]; then 125 | echoInfo "Checking out tag ${2} ..." 126 | git checkout tags/${2} 127 | else 128 | echoError "Specified tag '${2}' does not exist for puppet module repository '${1}'"; 129 | fi 130 | fi 131 | popd 132 | } 133 | 134 | # Setup Puppet module for given wso2 product 135 | # $1 - Puppet module name (equivalent to product name) 136 | # $2 - product code 137 | # $3 - platform 138 | # $4 - product version 139 | # $5 - Release tag of the product puppet module 140 | function setupModule() { 141 | echoInfo "Setting up ${1} Puppet module for ${3} platform..." 142 | if [ -d "${PUPPET_HOME}/modules/${1}" ]; then 143 | 144 | if [[ ${1} != "wso2base" ]];then 145 | checkoutBranch ${1} ${4} 146 | checkoutTag ${1} ${5} 147 | fi 148 | 149 | echoWarn "${PUPPET_HOME}/modules/${1} directory exists. Skipping..." 150 | return 151 | fi 152 | 153 | # clone repository 154 | puppet_git_url="https://github.com/wso2/puppet-${2}" 155 | curl -s --head ${puppet_git_url} | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null 156 | if [ $? -ne 0 ]; then 157 | echoError "[URL] ${puppet_git_url} is not reachable." 158 | echoError "Failed to setup PUPPET_HOME" 159 | exit 1 160 | fi 161 | 162 | git clone ${puppet_git_url} "${PUPPET_HOME}/modules/${1}" 163 | if [[ ${1} == "wso2base" ]];then 164 | echoInfo "Cloned wso2base module and it is in the master branch" 165 | fi 166 | 167 | if [[ ${2} == "iot" ]]; then 168 | mv "${PUPPET_HOME}/modules/${1}/wso2iot_core" "${PUPPET_HOME}/modules/" 169 | mv "${PUPPET_HOME}/modules/${1}/wso2iot_analytics" "${PUPPET_HOME}/modules/" 170 | mv "${PUPPET_HOME}/modules/${1}/wso2iot_broker" "${PUPPET_HOME}/modules/" 171 | 172 | rm -rf "${PUPPET_HOME}/modules/${1}" 173 | 174 | echoInfo "Creating symlink for Hiera data..." 175 | ln -sf "${PUPPET_HOME}/modules/wso2iot_core/hieradata/dev/wso2/wso2iot_core" "${PUPPET_HOME}/hieradata/dev/wso2/" 176 | ln -sf "${PUPPET_HOME}/modules/wso2iot_broker/hieradata/dev/wso2/wso2iot_broker" "${PUPPET_HOME}/hieradata/dev/wso2/" 177 | ln -sf "${PUPPET_HOME}/modules/wso2iot_analytics/hieradata/dev/wso2/wso2iot_analytics" "${PUPPET_HOME}/hieradata/dev/wso2/" 178 | echoSuccess "Successfully installed ${1} puppet modules and Hiera data for ${3} platform." 179 | 180 | return 181 | fi 182 | 183 | if [[ ${2} == "apim" ]]; then 184 | checkoutBranch ${1} ${4} 185 | checkoutTag ${1} ${5} 186 | mv "${PUPPET_HOME}/modules/${1}/wso2am_runtime" "${PUPPET_HOME}/modules/" 187 | mv "${PUPPET_HOME}/modules/${1}/wso2am_analytics" "${PUPPET_HOME}/modules/" 188 | mv "${PUPPET_HOME}/modules/${1}/wso2is_prepacked" "${PUPPET_HOME}/modules/" 189 | rm -rf "${PUPPET_HOME}/modules/${1}" 190 | 191 | echoInfo "Creating symlink for Hiera data..." 192 | ln -sf "${PUPPET_HOME}/modules/wso2am_runtime/hieradata/dev/wso2/wso2am_runtime" "${PUPPET_HOME}/hieradata/dev/wso2/" 193 | ln -sf "${PUPPET_HOME}/modules/wso2am_analytics/hieradata/dev/wso2/wso2am_analytics" "${PUPPET_HOME}/hieradata/dev/wso2/" 194 | ln -sf "${PUPPET_HOME}/modules/wso2is_prepacked/hieradata/dev/wso2/wso2is_prepacked" "${PUPPET_HOME}/hieradata/dev/wso2/" 195 | echoSuccess "Successfully installed ${1} puppet modules and Hiera data for ${3} platform." 196 | 197 | return 198 | fi 199 | 200 | echoInfo "Creating symlink for Hiera data..." 201 | if [[ ${1} == "wso2base" ]];then 202 | ln -sf "${PUPPET_HOME}/modules/${1}/hieradata/dev/wso2/common.yaml" "${PUPPET_HOME}/hieradata/dev/wso2/" 203 | echoSuccess "Successfully installed ${1} puppet module and Hiera data for ${3} platform." 204 | return 205 | else 206 | checkoutBranch ${1} ${4} 207 | checkoutTag ${1} ${5} 208 | fi 209 | 210 | if [[ ${3} == "default" ]]; then 211 | ln -sf "${PUPPET_HOME}/modules/${1}/hieradata/dev/wso2/${1}" "${PUPPET_HOME}/hieradata/dev/wso2/" 212 | else 213 | mkdir -p "${PUPPET_HOME}/${3}/" 214 | platform_artifacts_url="https://github.com/wso2/${3}-${2}" 215 | curl -s --head ${platform_artifacts_url} | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null 216 | if [ $? -ne 0 ]; then 217 | echoError "[URL] ${platform_artifacts_url} is not reachable." 218 | echoError "Failed to setup Hiera data for ${4} platform" 219 | exit 1 220 | fi 221 | git clone ${platform_artifacts_url} "${PUPPET_HOME}/${3}/${3}-${2}" 222 | ln -sf "${PUPPET_HOME}/${3}/${3}-${2}/hieradata/dev/wso2/${1}" ${PUPPET_HOME}/hieradata/dev/wso2/ 223 | fi 224 | 225 | echoSuccess "Successfully installed ${1} puppet module and Hiera data for ${3} platform." 226 | } 227 | 228 | platform='default' 229 | while getopts :p:l:v:t: FLAG; do 230 | case ${FLAG} in 231 | p) 232 | product_codes=$OPTARG 233 | ;; 234 | l) 235 | platform=$OPTARG 236 | ;; 237 | v) 238 | product_version=$OPTARG 239 | ;; 240 | t) 241 | release_tag=$OPTARG 242 | ;; 243 | \?) 244 | showUsageAndExit 245 | ;; 246 | esac 247 | done 248 | 249 | if [[ -z ${product_codes} ]]; then 250 | showUsageAndExit 251 | fi 252 | 253 | if [[ -z ${product_version} ]]; then 254 | product_version="latest" 255 | fi 256 | 257 | if [ -z "$PUPPET_HOME" ]; then 258 | echoWarn "PUPPET_HOME is not set as an environment variable, prompting for input..." 259 | askBold "Enter directory path for PUPPET_HOME: " 260 | read -r puppet_home_v 261 | PUPPET_HOME=${puppet_home_v} 262 | fi 263 | 264 | validatePuppetHome ${PUPPET_HOME} 265 | echoInfo "Setting up [PUPPET_HOME] ${PUPPET_HOME}..." 266 | 267 | # Copy Hiera configuration file 268 | cp ${self_path}/hiera.yaml ${PUPPET_HOME} 269 | 270 | # Create symlink for manifest/site.pp 271 | echoInfo "Creating symlink for site.pp..." 272 | ln -sf ${self_path}/manifests ${PUPPET_HOME}/ 273 | 274 | # Create folder structure 275 | mkdir -p ${PUPPET_HOME}/files/packs 276 | mkdir -p ${PUPPET_HOME}/hieradata/dev/wso2 277 | mkdir -p ${PUPPET_HOME}/modules 278 | 279 | # Setup wso2base Puppet module 280 | setupModule "wso2base" "base" "default" 281 | 282 | # Setup Puppet modules for specified products 283 | if [[ ${product_codes} == "all" ]]; then 284 | IFS=',' read -r -a product_code_array <<< "apim,cep,das,esb,is,iot" 285 | else 286 | IFS=',' read -r -a product_code_array <<< "${product_codes}" 287 | fi 288 | 289 | for product_code in "${product_code_array[@]}"; do 290 | getProductName ${product_code} 291 | setupModule ${product_name} ${product_code} ${platform} ${product_version} ${release_tag} 292 | done 293 | 294 | echoInfo "Setup completed successfully. Please copy relevant distributions to Puppet file bucket." 295 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------