mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 14:05:50 +00:00
commit
6ed8b1e168
17 changed files with 686 additions and 214 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,3 +5,5 @@ target/*
|
|||
.idea
|
||||
*.iml
|
||||
/target
|
||||
packer_cache/
|
||||
builds/
|
||||
|
|
215
Jenkinsfile
vendored
215
Jenkinsfile
vendored
|
@ -1,226 +1,29 @@
|
|||
#!/bin/env groovy
|
||||
|
||||
@Library('ldop-shared-library@fd16602cad0f97ca1b04090f93a0540ddc871b45') _
|
||||
|
||||
pipeline {
|
||||
agent none
|
||||
|
||||
environment {
|
||||
IMAGE = "liatrio/petclinic-tomcat"
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Build') {
|
||||
agent {
|
||||
docker {
|
||||
image 'maven:3.5.0'
|
||||
args '-e INITIAL_ADMIN_USER -e INITIAL_ADMIN_PASSWORD --network=${LDOP_NETWORK_NAME}'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
configFileProvider([configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) {
|
||||
sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true -B'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Sonar') {
|
||||
stage('Deploy to Artifactory') {
|
||||
agent {
|
||||
docker {
|
||||
image 'sebp/sonar-runner'
|
||||
args '-e SONAR_ACCOUNT_LOGIN -e SONAR_ACCOUNT_PASSWORD -e SONAR_DB_URL -e SONAR_DB_LOGIN -e SONAR_DB_PASSWORD --network=${LDOP_NETWORK_NAME}'
|
||||
node {
|
||||
label 'tester'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh '/opt/sonar-runner-2.4/bin/sonar-runner -e -D sonar.login=${SONAR_ACCOUNT_LOGIN} -D sonar.password=${SONAR_ACCOUNT_PASSWORD} -D sonar.jdbc.url=${SONAR_DB_URL} -D sonar.jdbc.username=${SONAR_DB_LOGIN} -D sonar.jdbc.password=${SONAR_DB_PASSWORD}'
|
||||
sh 'mvn deploy'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Get Artifact') {
|
||||
stage('Deploy to Dev') {
|
||||
agent {
|
||||
docker {
|
||||
image 'maven:3.5.0'
|
||||
args '-e INITIAL_ADMIN_USER -e INITIAL_ADMIN_PASSWORD --network=${LDOP_NETWORK_NAME}'
|
||||
node {
|
||||
label 'tester'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'mvn clean'
|
||||
script {
|
||||
pom = readMavenPom file: 'pom.xml'
|
||||
getArtifact(pom.groupId, pom.artifactId, pom.version, 'petclinic')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build container') {
|
||||
agent any
|
||||
steps {
|
||||
script {
|
||||
if ( env.BRANCH_NAME == 'master' ) {
|
||||
pom = readMavenPom file: 'pom.xml'
|
||||
TAG = pom.version
|
||||
} else {
|
||||
TAG = env.BRANCH_NAME
|
||||
}
|
||||
sh "docker build -t ${env.IMAGE}:${TAG} ."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run local container') {
|
||||
agent any
|
||||
steps {
|
||||
sh 'docker rm -f petclinic-tomcat-temp || true'
|
||||
sh "docker run -d --network=${LDOP_NETWORK_NAME} --name petclinic-tomcat-temp ${env.IMAGE}:${TAG}"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Smoke-Test & OWASP Security Scan') {
|
||||
agent {
|
||||
docker {
|
||||
image 'maven:3.5.0'
|
||||
args '--network=${LDOP_NETWORK_NAME}'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh "cd regression-suite && mvn clean -B test -DPETCLINIC_URL=http://petclinic-tomcat-temp:8080/petclinic/"
|
||||
}
|
||||
}
|
||||
stage('Stop local container') {
|
||||
agent any
|
||||
steps {
|
||||
sh 'docker rm -f petclinic-tomcat-temp || true'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push to dockerhub') {
|
||||
agent any
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUsername')]){
|
||||
script {
|
||||
sh "docker login -u ${env.dockerUsername} -p ${env.dockerPassword}"
|
||||
sh "docker push ${env.IMAGE}:${TAG}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to dev') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent any
|
||||
steps {
|
||||
script {
|
||||
deployToEnvironment("ec2-user", "dev.petclinic.liatr.io", "petclinic-deploy-key", env.IMAGE, TAG, "spring-petclinic", "dev.petclinic.liatr.io")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Smoke test dev') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent {
|
||||
docker {
|
||||
image 'maven:3.5.0'
|
||||
args '--network=${LDOP_NETWORK_NAME}'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh "cd regression-suite && mvn clean -B test -DPETCLINIC_URL=https://dev.petclinic.liatr.io/petclinic"
|
||||
echo "Should be accessible at https://dev.petclinic.liatr.io/petclinic"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to qa') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent any
|
||||
steps {
|
||||
deployToEnvironment("ec2-user", "qa.petclinic.liatr.io", "petclinic-deploy-key", env.IMAGE, TAG, "spring-petclinic", "qa.petclinic.liatr.io")
|
||||
}
|
||||
}
|
||||
|
||||
stage('Smoke test qa') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent {
|
||||
docker {
|
||||
image 'maven:3.5.0'
|
||||
args '--network=${LDOP_NETWORK_NAME}'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh "cd regression-suite && mvn clean -B test -DPETCLINIC_URL=https://qa.petclinic.liatr.io/petclinic"
|
||||
echo "Should be accessible at https://qa.petclinic.liatr.io/petclinic"
|
||||
input 'Deploy to Prod?'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Blue/Green Prod Deploy') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent {
|
||||
dockerfile {
|
||||
filename "blue-green/Dockerfile"
|
||||
}
|
||||
}
|
||||
steps {
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY'),
|
||||
file(credentialsId: 'petclinic-deploy-key', variable: 'DEPLOY_KEY_PATH')
|
||||
]) {
|
||||
script {
|
||||
sh "TAG=${TAG} blue-green/blue-green deploy"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Blue/Green Prod Regression Test') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent {
|
||||
dockerfile {
|
||||
filename "blue-green/Dockerfile"
|
||||
}
|
||||
}
|
||||
steps {
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY'),
|
||||
file(credentialsId: 'petclinic-deploy-key', variable: 'DEPLOY_KEY_PATH')
|
||||
]) {
|
||||
script {
|
||||
sh "TAG=${TAG} blue-green/blue-green test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Blue/Green Prod Toggle Load Balancer') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
agent {
|
||||
dockerfile {
|
||||
filename "blue-green/Dockerfile"
|
||||
}
|
||||
}
|
||||
steps {
|
||||
input "Toggle Prod Load Balancer?"
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY'),
|
||||
file(credentialsId: 'petclinic-deploy-key', variable: 'DEPLOY_KEY_PATH')
|
||||
]) {
|
||||
script {
|
||||
sh "TAG=${TAG} blue-green/blue-green toggle"
|
||||
}
|
||||
}
|
||||
sh 'scp -P 2225 -r script.sh admin@192.168.0.20:/home/admin/.'
|
||||
sh 'ssh -p 2225 admin@192.168.0.20 < script.sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -420,14 +420,11 @@
|
|||
</reporting>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<url>http://nexus:8081/nexus/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>releases</id>
|
||||
<url>http://nexus:8081/nexus/content/repositories/releases</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>snapshots</id>
|
||||
<name>localhost.localdomain-snapshots</name>
|
||||
<url>http://192.168.0.20:8081/artifactory/libs-snapshot-local</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<url>demopetclinic</url>
|
||||
|
|
22
script.sh
Normal file
22
script.sh
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
wget http://192.168.0.20:8081/artifactory/libs-snapshot-local/org/springframework/samples/spring-petclinic/maven-metadata.xml
|
||||
VERSION=$(cat maven-metadata.xml | grep -m 1 -oP '(?<=<version>).*(?=</version>)')
|
||||
rm -f maven-metadata.xml
|
||||
wget http://192.168.0.20:8081/artifactory/libs-snapshot-local/org/springframework/samples/spring-petclinic/$VERSION/maven-metadata.xml
|
||||
|
||||
AID=$(cat maven-metadata.xml | grep -m 1 -oP '(?<=<artifactId>).*(?=</artifactId>)')
|
||||
VALUE=$(cat maven-metadata.xml | grep -m 1 -oP '(?<=<value>).*(?=</value>)')
|
||||
echo $AID-$VALUE.war > version
|
||||
#echo "curl \"http://192.168.0.56:8081/repository/maven-snapshots/org/springframework/samples/spring-petclinic/$VERSION/" > command
|
||||
|
||||
echo "curl \"http://192.168.0.20:8081/artifactory/libs-snapshot-local/org/springframework/samples/spring-petclinic/$VERSION/" > command
|
||||
|
||||
paste -d '' command version > firsthalf
|
||||
echo "\" -o /usr/share/tomcat/webapps/petclinic.war" > secondhalf
|
||||
paste -d '' firsthalf secondhalf > fullcmd
|
||||
sudo chmod 755 fullcmd
|
||||
sudo ./fullcmd
|
||||
sudo service tomcat restart
|
||||
#rm -f command firsthalf fullcmd maven-metadata.xml secondhalf version
|
||||
rm -f command firsthalf maven-metadata.xml secondhalf version
|
2
test.sh
Normal file
2
test.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
echo 'TESTING JF' >> jfile.txt
|
51
vm-images/jenkins/jenkins_build.json
Normal file
51
vm-images/jenkins/jenkins_build.json
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"variables": {
|
||||
"file": "http://mirrors.ocf.berkeley.edu/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso",
|
||||
"checksum": "bd43d41e01c2a46b3cb23eb9139dce4b",
|
||||
"type": "md5",
|
||||
"non_gui": "false"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"iso_url": "{{ user `file` }}",
|
||||
"iso_checksum": "{{ user `checksum` }}",
|
||||
"iso_checksum_type": "md5",
|
||||
"headless": "{{ user `non_gui` }}",
|
||||
"output_directory": "builds",
|
||||
"vm_name": "jenkins_centos",
|
||||
"guest_os_type": "RedHat_64",
|
||||
"disk_size": "10240",
|
||||
"vboxmanage": [
|
||||
["modifyvm", "{{.Name}}", "--memory", "2048"],
|
||||
["modifyvm", "{{.Name}}", "--cpus", "2"],
|
||||
["modifyvm", "{{.Name}}", "--audio", "none"],
|
||||
["modifyvm", "{{.Name}}", "--usb", "off"]
|
||||
],
|
||||
"http_directory": "src",
|
||||
"boot_wait": "5s",
|
||||
"boot_command": [
|
||||
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
|
||||
],
|
||||
"ssh_username": "admin",
|
||||
"ssh_password": "admin",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "10000s",
|
||||
"guest_additions_path": "disable",
|
||||
"shutdown_command": "echo 'admin' | sudo -S /sbin/halt -h -p"
|
||||
}
|
||||
],
|
||||
"provisioners": [{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"sleep 30",
|
||||
"sudo yum upgrade",
|
||||
"sudo yum install git -y",
|
||||
"sudo yum install wget -y",
|
||||
"sudo yum install java-1.8.0-openjdk-devel -y",
|
||||
"sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo",
|
||||
"sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key",
|
||||
"sudo yum install jenkins -y"
|
||||
]
|
||||
}]
|
||||
}
|
87
vm-images/jenkins/src/ks.cfg
Normal file
87
vm-images/jenkins/src/ks.cfg
Normal file
|
@ -0,0 +1,87 @@
|
|||
install
|
||||
cdrom
|
||||
|
||||
lang en_US.UTF-8
|
||||
keyboard us
|
||||
timezone UTC
|
||||
|
||||
network --bootproto=dhcp
|
||||
firewall --disabled
|
||||
|
||||
rootpw --plaintext packer
|
||||
user --name=admin --password=admin
|
||||
auth --enableshadow --passalgo=sha512 --kickstart
|
||||
selinux --permissive
|
||||
|
||||
text
|
||||
skipx
|
||||
|
||||
clearpart --all --initlabel
|
||||
zerombr
|
||||
autopart
|
||||
bootloader --location=mbr
|
||||
|
||||
firstboot --disable
|
||||
reboot
|
||||
|
||||
%packages --instLangs=en_US.utf8 --nobase --ignoremissing --excludedocs
|
||||
@^minimal
|
||||
@core
|
||||
|
||||
-aic94xx-firmware
|
||||
-atmel-firmware
|
||||
-b43-openfwwf
|
||||
-bfa-firmware
|
||||
-ipw2100-firmware
|
||||
-ipw2200-firmware
|
||||
-ivtv-firmware
|
||||
-iwl100-firmware
|
||||
-iwl105-firmware
|
||||
-iwl135-firmware
|
||||
-iwl1000-firmware
|
||||
-iwl2000-firmware
|
||||
-iwl2030-firmware
|
||||
-iwl3160-firmware
|
||||
-iwl3945-firmware
|
||||
-iwl4965-firmware
|
||||
-iwl5000-firmware
|
||||
-iwl5150-firmware
|
||||
-iwl6000-firmware
|
||||
-iwl6000g2a-firmware
|
||||
-iwl6000g2b-firmware
|
||||
-iwl6050-firmware
|
||||
-iwl7260-firmware
|
||||
-libertas-usb8388-firmware
|
||||
-ql2100-firmware
|
||||
-ql2200-firmware
|
||||
-ql23xx-firmware
|
||||
-ql2400-firmware
|
||||
-ql2500-firmware
|
||||
-rt61pci-firmware
|
||||
-rt73usb-firmware
|
||||
-xorg-x11-drv-ati-firmware
|
||||
-zd1211-firmware
|
||||
%end
|
||||
|
||||
%post --log=/root/ks.log
|
||||
SEE NEXT PICTURE!!!! The security settings of my provider does not allow this content!
|
||||
%end
|
||||
|
||||
%post
|
||||
echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/admin
|
||||
echo "Defaults:admin !requiretty" >> /etc/sudoers.d/admin
|
||||
chmod 0440 /etc/sudoers.d/admin
|
||||
mkdir -pm 700 /home/admin/.ssh
|
||||
cat <<EOK >/home/admin/.ssh/authorized_keys
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8Y\
|
||||
Vr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO\
|
||||
KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7Pt\
|
||||
ixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmC\
|
||||
P3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW\
|
||||
yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== admin insecure public key
|
||||
EOK
|
||||
chmod 0600 /home/admin/.ssh/authorized_keys
|
||||
chown -R admin.admin /home/admin/.ssh
|
||||
yum -y update
|
||||
yum -y remove linux-firmware
|
||||
%end
|
51
vm-images/test_env/config/tomcat-users.xml
Normal file
51
vm-images/test_env/config/tomcat-users.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<tomcat-users>
|
||||
<!--
|
||||
NOTE: By default, no user is included in the "manager-gui" role required
|
||||
to operate the "/manager/html" web application. If you wish to use this app,
|
||||
you must define such a user - the username and password are arbitrary. It is
|
||||
strongly recommended that you do NOT use one of the users in the commented out
|
||||
section below since they are intended for use with the examples web
|
||||
application.
|
||||
-->
|
||||
<!--
|
||||
NOTE: The sample user and role entries below are intended for use with the
|
||||
examples web application. They are wrapped in a comment and thus are ignored
|
||||
when reading this file. If you wish to configure these users for use with the
|
||||
examples web application, do not forget to remove the <!.. ..> that surrounds
|
||||
them. You will also need to set the passwords to something appropriate.
|
||||
-->
|
||||
<!--
|
||||
<role rolename="tomcat"/>
|
||||
<role rolename="role1"/>
|
||||
<user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
|
||||
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
|
||||
<user username="role1" password="<must-be-changed>" roles="role1"/>
|
||||
-->
|
||||
|
||||
<!-- <role rolename="admin"/> -->
|
||||
<!-- <role rolename="admin-gui"/> -->
|
||||
<!-- <role rolename="admin-script"/> -->
|
||||
<!-- <role rolename="manager"/> -->
|
||||
<!-- <role rolename="manager-gui"/> -->
|
||||
<!-- <role rolename="manager-script"/> -->
|
||||
<!-- <role rolename="manager-jmx"/> -->
|
||||
<!-- <role rolename="manager-status"/> -->
|
||||
<user name="admin" password="admin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
|
||||
</tomcat-users>
|
51
vm-images/test_env/config/tomcat.conf
Normal file
51
vm-images/test_env/config/tomcat.conf
Normal file
|
@ -0,0 +1,51 @@
|
|||
# System-wide configuration file for tomcat services
|
||||
# This will be loaded by systemd as an environment file,
|
||||
# so please keep the syntax. For shell expansion support
|
||||
# place your custom files as /etc/tomcat/conf.d/*.conf
|
||||
#
|
||||
# There are 2 "classes" of startup behavior in this package.
|
||||
# The old one, the default service named tomcat.service.
|
||||
# The new named instances are called tomcat@instance.service.
|
||||
#
|
||||
# Use this file to change default values for all services.
|
||||
# Change the service specific ones to affect only one service.
|
||||
# For tomcat.service it's /etc/sysconfig/tomcat, for
|
||||
# tomcat@instance it's /etc/sysconfig/tomcat@instance.
|
||||
|
||||
# This variable is used to figure out if config is loaded or not.
|
||||
TOMCAT_CFG_LOADED="1"
|
||||
|
||||
# In new-style instances, if CATALINA_BASE isn't specified, it will
|
||||
# be constructed by joining TOMCATS_BASE and NAME.
|
||||
TOMCATS_BASE="/var/lib/tomcats/"
|
||||
|
||||
# Where your java installation lives
|
||||
JAVA_HOME="/usr/lib/jvm/jre"
|
||||
|
||||
# Where your tomcat installation lives
|
||||
CATALINA_HOME="/usr/share/tomcat"
|
||||
|
||||
# System-wide tmp
|
||||
CATALINA_TMPDIR="/var/cache/tomcat/temp"
|
||||
|
||||
# You can pass some parameters to java here if you wish to
|
||||
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
|
||||
|
||||
# Use JAVA_OPTS to set java.library.path for libtcnative.so
|
||||
#JAVA_OPTS="-Djava.library.path=/usr/lib"
|
||||
|
||||
# You can change your tomcat locale here
|
||||
#LANG="en_US"
|
||||
|
||||
# Run tomcat under the Java Security Manager
|
||||
SECURITY_MANAGER="false"
|
||||
|
||||
# Time to wait in seconds, before killing process
|
||||
# TODO(stingray): does nothing, fix.
|
||||
# SHUTDOWN_WAIT="30"
|
||||
|
||||
# If you wish to further customize your tomcat environment,
|
||||
# put your own definitions here
|
||||
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
|
||||
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"
|
||||
|
87
vm-images/test_env/src/ks.cfg
Normal file
87
vm-images/test_env/src/ks.cfg
Normal file
|
@ -0,0 +1,87 @@
|
|||
install
|
||||
cdrom
|
||||
|
||||
lang en_US.UTF-8
|
||||
keyboard us
|
||||
timezone UTC
|
||||
|
||||
network --bootproto=dhcp
|
||||
firewall --disabled
|
||||
|
||||
rootpw --plaintext packer
|
||||
user --name=admin --password=admin
|
||||
auth --enableshadow --passalgo=sha512 --kickstart
|
||||
selinux --permissive
|
||||
|
||||
text
|
||||
skipx
|
||||
|
||||
clearpart --all --initlabel
|
||||
zerombr
|
||||
autopart
|
||||
bootloader --location=mbr
|
||||
|
||||
firstboot --disable
|
||||
reboot
|
||||
|
||||
%packages --instLangs=en_US.utf8 --nobase --ignoremissing --excludedocs
|
||||
@^minimal
|
||||
@core
|
||||
|
||||
-aic94xx-firmware
|
||||
-atmel-firmware
|
||||
-b43-openfwwf
|
||||
-bfa-firmware
|
||||
-ipw2100-firmware
|
||||
-ipw2200-firmware
|
||||
-ivtv-firmware
|
||||
-iwl100-firmware
|
||||
-iwl105-firmware
|
||||
-iwl135-firmware
|
||||
-iwl1000-firmware
|
||||
-iwl2000-firmware
|
||||
-iwl2030-firmware
|
||||
-iwl3160-firmware
|
||||
-iwl3945-firmware
|
||||
-iwl4965-firmware
|
||||
-iwl5000-firmware
|
||||
-iwl5150-firmware
|
||||
-iwl6000-firmware
|
||||
-iwl6000g2a-firmware
|
||||
-iwl6000g2b-firmware
|
||||
-iwl6050-firmware
|
||||
-iwl7260-firmware
|
||||
-libertas-usb8388-firmware
|
||||
-ql2100-firmware
|
||||
-ql2200-firmware
|
||||
-ql23xx-firmware
|
||||
-ql2400-firmware
|
||||
-ql2500-firmware
|
||||
-rt61pci-firmware
|
||||
-rt73usb-firmware
|
||||
-xorg-x11-drv-ati-firmware
|
||||
-zd1211-firmware
|
||||
%end
|
||||
|
||||
%post --log=/root/ks.log
|
||||
SEE NEXT PICTURE!!!! The security settings of my provider does not allow this content!
|
||||
%end
|
||||
|
||||
%post
|
||||
echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/admin
|
||||
echo "Defaults:admin !requiretty" >> /etc/sudoers.d/admin
|
||||
chmod 0440 /etc/sudoers.d/admin
|
||||
mkdir -pm 700 /home/admin/.ssh
|
||||
cat <<EOK >/home/admin/.ssh/authorized_keys
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8Y\
|
||||
Vr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO\
|
||||
KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7Pt\
|
||||
ixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmC\
|
||||
P3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW\
|
||||
yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== admin insecure public key
|
||||
EOK
|
||||
chmod 0600 /home/admin/.ssh/authorized_keys
|
||||
chown -R admin.admin /home/admin/.ssh
|
||||
yum -y update
|
||||
yum -y remove linux-firmware
|
||||
%end
|
12
vm-images/test_env/test_env.sh
Normal file
12
vm-images/test_env/test_env.sh
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Provision tomcat
|
||||
sudo yum install tomcat -y
|
||||
sudo yum install tomcat-webapps tomcat-admin-webapps -y
|
||||
sudo mv tomcat-users.xml /usr/share/tomcat/conf/tomcat-users.xml
|
||||
sudo mv tomcat.conf /usr/share/tomcat/conf/tomcat.conf
|
||||
sudo systemctl enable tomcat
|
||||
|
||||
# Provision jenkins
|
||||
sudo yum install maven -y
|
||||
|
||||
# Install git
|
||||
sudo yum install git -y
|
56
vm-images/test_env/test_env_build.json
Normal file
56
vm-images/test_env/test_env_build.json
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"variables": {
|
||||
"file": "http://mirrors.ocf.berkeley.edu/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso",
|
||||
"checksum": "bd43d41e01c2a46b3cb23eb9139dce4b",
|
||||
"type": "md5",
|
||||
"non_gui": "false"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"iso_url": "{{ user `file` }}",
|
||||
"iso_checksum": "{{ user `checksum` }}",
|
||||
"iso_checksum_type": "md5",
|
||||
"headless": "{{ user `non_gui` }}",
|
||||
"output_directory": "builds",
|
||||
"vm_name": "Test-env-CentOS7",
|
||||
"guest_os_type": "RedHat_64",
|
||||
"disk_size": "10240",
|
||||
"vboxmanage": [
|
||||
["modifyvm", "{{.Name}}", "--memory", "2048"],
|
||||
["modifyvm", "{{.Name}}", "--cpus", "2"],
|
||||
["modifyvm", "{{.Name}}", "--audio", "none"],
|
||||
["modifyvm", "{{.Name}}", "--usb", "off"]
|
||||
],
|
||||
"http_directory": "src",
|
||||
"boot_wait": "5s",
|
||||
"boot_command": [
|
||||
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
|
||||
],
|
||||
"ssh_username": "admin",
|
||||
"ssh_password": "admin",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "10000s",
|
||||
"guest_additions_path": "disable",
|
||||
"shutdown_command": "echo 'admin' | sudo -S /sbin/halt -h -p"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "file",
|
||||
"source": "config/tomcat-users.xml",
|
||||
"destination": "~/tomcat-users.xml"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "config/tomcat.conf",
|
||||
"destination": "~/tomcat.conf"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"test_env.sh"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
51
vm-images/tomcat/config/tomcat-users.xml
Normal file
51
vm-images/tomcat/config/tomcat-users.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<tomcat-users>
|
||||
<!--
|
||||
NOTE: By default, no user is included in the "manager-gui" role required
|
||||
to operate the "/manager/html" web application. If you wish to use this app,
|
||||
you must define such a user - the username and password are arbitrary. It is
|
||||
strongly recommended that you do NOT use one of the users in the commented out
|
||||
section below since they are intended for use with the examples web
|
||||
application.
|
||||
-->
|
||||
<!--
|
||||
NOTE: The sample user and role entries below are intended for use with the
|
||||
examples web application. They are wrapped in a comment and thus are ignored
|
||||
when reading this file. If you wish to configure these users for use with the
|
||||
examples web application, do not forget to remove the <!.. ..> that surrounds
|
||||
them. You will also need to set the passwords to something appropriate.
|
||||
-->
|
||||
<!--
|
||||
<role rolename="tomcat"/>
|
||||
<role rolename="role1"/>
|
||||
<user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
|
||||
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
|
||||
<user username="role1" password="<must-be-changed>" roles="role1"/>
|
||||
-->
|
||||
|
||||
<!-- <role rolename="admin"/> -->
|
||||
<!-- <role rolename="admin-gui"/> -->
|
||||
<!-- <role rolename="admin-script"/> -->
|
||||
<!-- <role rolename="manager"/> -->
|
||||
<!-- <role rolename="manager-gui"/> -->
|
||||
<!-- <role rolename="manager-script"/> -->
|
||||
<!-- <role rolename="manager-jmx"/> -->
|
||||
<!-- <role rolename="manager-status"/> -->
|
||||
<user name="admin" password="admin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
|
||||
</tomcat-users>
|
51
vm-images/tomcat/config/tomcat.conf
Normal file
51
vm-images/tomcat/config/tomcat.conf
Normal file
|
@ -0,0 +1,51 @@
|
|||
# System-wide configuration file for tomcat services
|
||||
# This will be loaded by systemd as an environment file,
|
||||
# so please keep the syntax. For shell expansion support
|
||||
# place your custom files as /etc/tomcat/conf.d/*.conf
|
||||
#
|
||||
# There are 2 "classes" of startup behavior in this package.
|
||||
# The old one, the default service named tomcat.service.
|
||||
# The new named instances are called tomcat@instance.service.
|
||||
#
|
||||
# Use this file to change default values for all services.
|
||||
# Change the service specific ones to affect only one service.
|
||||
# For tomcat.service it's /etc/sysconfig/tomcat, for
|
||||
# tomcat@instance it's /etc/sysconfig/tomcat@instance.
|
||||
|
||||
# This variable is used to figure out if config is loaded or not.
|
||||
TOMCAT_CFG_LOADED="1"
|
||||
|
||||
# In new-style instances, if CATALINA_BASE isn't specified, it will
|
||||
# be constructed by joining TOMCATS_BASE and NAME.
|
||||
TOMCATS_BASE="/var/lib/tomcats/"
|
||||
|
||||
# Where your java installation lives
|
||||
JAVA_HOME="/usr/lib/jvm/jre"
|
||||
|
||||
# Where your tomcat installation lives
|
||||
CATALINA_HOME="/usr/share/tomcat"
|
||||
|
||||
# System-wide tmp
|
||||
CATALINA_TMPDIR="/var/cache/tomcat/temp"
|
||||
|
||||
# You can pass some parameters to java here if you wish to
|
||||
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
|
||||
|
||||
# Use JAVA_OPTS to set java.library.path for libtcnative.so
|
||||
#JAVA_OPTS="-Djava.library.path=/usr/lib"
|
||||
|
||||
# You can change your tomcat locale here
|
||||
#LANG="en_US"
|
||||
|
||||
# Run tomcat under the Java Security Manager
|
||||
SECURITY_MANAGER="false"
|
||||
|
||||
# Time to wait in seconds, before killing process
|
||||
# TODO(stingray): does nothing, fix.
|
||||
# SHUTDOWN_WAIT="30"
|
||||
|
||||
# If you wish to further customize your tomcat environment,
|
||||
# put your own definitions here
|
||||
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
|
||||
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"
|
||||
|
87
vm-images/tomcat/src/ks.cfg
Normal file
87
vm-images/tomcat/src/ks.cfg
Normal file
|
@ -0,0 +1,87 @@
|
|||
install
|
||||
cdrom
|
||||
|
||||
lang en_US.UTF-8
|
||||
keyboard us
|
||||
timezone UTC
|
||||
|
||||
network --bootproto=dhcp
|
||||
firewall --disabled
|
||||
|
||||
rootpw --plaintext packer
|
||||
user --name=admin --password=admin
|
||||
auth --enableshadow --passalgo=sha512 --kickstart
|
||||
selinux --permissive
|
||||
|
||||
text
|
||||
skipx
|
||||
|
||||
clearpart --all --initlabel
|
||||
zerombr
|
||||
autopart
|
||||
bootloader --location=mbr
|
||||
|
||||
firstboot --disable
|
||||
reboot
|
||||
|
||||
%packages --instLangs=en_US.utf8 --nobase --ignoremissing --excludedocs
|
||||
@^minimal
|
||||
@core
|
||||
|
||||
-aic94xx-firmware
|
||||
-atmel-firmware
|
||||
-b43-openfwwf
|
||||
-bfa-firmware
|
||||
-ipw2100-firmware
|
||||
-ipw2200-firmware
|
||||
-ivtv-firmware
|
||||
-iwl100-firmware
|
||||
-iwl105-firmware
|
||||
-iwl135-firmware
|
||||
-iwl1000-firmware
|
||||
-iwl2000-firmware
|
||||
-iwl2030-firmware
|
||||
-iwl3160-firmware
|
||||
-iwl3945-firmware
|
||||
-iwl4965-firmware
|
||||
-iwl5000-firmware
|
||||
-iwl5150-firmware
|
||||
-iwl6000-firmware
|
||||
-iwl6000g2a-firmware
|
||||
-iwl6000g2b-firmware
|
||||
-iwl6050-firmware
|
||||
-iwl7260-firmware
|
||||
-libertas-usb8388-firmware
|
||||
-ql2100-firmware
|
||||
-ql2200-firmware
|
||||
-ql23xx-firmware
|
||||
-ql2400-firmware
|
||||
-ql2500-firmware
|
||||
-rt61pci-firmware
|
||||
-rt73usb-firmware
|
||||
-xorg-x11-drv-ati-firmware
|
||||
-zd1211-firmware
|
||||
%end
|
||||
|
||||
%post --log=/root/ks.log
|
||||
SEE NEXT PICTURE!!!! The security settings of my provider does not allow this content!
|
||||
%end
|
||||
|
||||
%post
|
||||
echo "admin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/admin
|
||||
echo "Defaults:admin !requiretty" >> /etc/sudoers.d/admin
|
||||
chmod 0440 /etc/sudoers.d/admin
|
||||
mkdir -pm 700 /home/admin/.ssh
|
||||
cat <<EOK >/home/admin/.ssh/authorized_keys
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8Y\
|
||||
Vr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO\
|
||||
KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7Pt\
|
||||
ixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmC\
|
||||
P3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW\
|
||||
yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== admin insecure public key
|
||||
EOK
|
||||
chmod 0600 /home/admin/.ssh/authorized_keys
|
||||
chown -R admin.admin /home/admin/.ssh
|
||||
yum -y update
|
||||
yum -y remove linux-firmware
|
||||
%end
|
6
vm-images/tomcat/tomcat.sh
Normal file
6
vm-images/tomcat/tomcat.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
sudo yum install tomcat -y
|
||||
sudo yum install tomcat-webapps tomcat-admin-webapps -y
|
||||
sudo mv tomcat-users.xml /usr/share/tomcat/conf/tomcat-users.xml
|
||||
sudo mv tomcat.conf /usr/share/tomcat/conf/tomcat.conf
|
||||
sudo systemctl enable tomcat
|
||||
|
56
vm-images/tomcat/tomcat_build.json
Normal file
56
vm-images/tomcat/tomcat_build.json
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"variables": {
|
||||
"file": "http://mirrors.ocf.berkeley.edu/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso",
|
||||
"checksum": "bd43d41e01c2a46b3cb23eb9139dce4b",
|
||||
"type": "md5",
|
||||
"non_gui": "false"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"iso_url": "{{ user `file` }}",
|
||||
"iso_checksum": "{{ user `checksum` }}",
|
||||
"iso_checksum_type": "md5",
|
||||
"headless": "{{ user `non_gui` }}",
|
||||
"output_directory": "builds",
|
||||
"vm_name": "Tomcat-CentOS7",
|
||||
"guest_os_type": "RedHat_64",
|
||||
"disk_size": "10240",
|
||||
"vboxmanage": [
|
||||
["modifyvm", "{{.Name}}", "--memory", "2048"],
|
||||
["modifyvm", "{{.Name}}", "--cpus", "2"],
|
||||
["modifyvm", "{{.Name}}", "--audio", "none"],
|
||||
["modifyvm", "{{.Name}}", "--usb", "off"]
|
||||
],
|
||||
"http_directory": "src",
|
||||
"boot_wait": "5s",
|
||||
"boot_command": [
|
||||
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
|
||||
],
|
||||
"ssh_username": "admin",
|
||||
"ssh_password": "admin",
|
||||
"ssh_port": 22,
|
||||
"ssh_wait_timeout": "10000s",
|
||||
"guest_additions_path": "disable",
|
||||
"shutdown_command": "echo 'admin' | sudo -S /sbin/halt -h -p"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "file",
|
||||
"source": "config/tomcat-users.xml",
|
||||
"destination": "~/tomcat-users.xml"
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"source": "config/tomcat.conf",
|
||||
"destination": "~/tomcat.conf"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"scripts": [
|
||||
"tomcat.sh"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue