Working Tomcat CentOS image built with packer

This commit is contained in:
Jordan A 2019-05-07 12:41:50 -07:00
parent 09f08bab33
commit 7fe2fe9047
6 changed files with 252 additions and 2 deletions

3
.gitignore vendored
View file

@ -6,5 +6,4 @@ target/*
*.iml
/target
packer_cache/
*.vmdk
*.ovf
builds/

View 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>

View 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"

View 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

View 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

View 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"
]
}
]
}