diff --git a/.gitignore b/.gitignore index 592a133a2..a4381843c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ target/* *.iml /target packer_cache/ -*.vmdk -*.ovf +builds/ diff --git a/vm-images/tomcat/config/tomcat-users.xml b/vm-images/tomcat/config/tomcat-users.xml new file mode 100644 index 000000000..61d2b4889 --- /dev/null +++ b/vm-images/tomcat/config/tomcat-users.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + diff --git a/vm-images/tomcat/config/tomcat.conf b/vm-images/tomcat/config/tomcat.conf new file mode 100644 index 000000000..bdfeb770a --- /dev/null +++ b/vm-images/tomcat/config/tomcat.conf @@ -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" + diff --git a/vm-images/tomcat/src/ks.cfg b/vm-images/tomcat/src/ks.cfg new file mode 100644 index 000000000..e659d3c6c --- /dev/null +++ b/vm-images/tomcat/src/ks.cfg @@ -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 </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 diff --git a/vm-images/tomcat/tomcat.sh b/vm-images/tomcat/tomcat.sh new file mode 100644 index 000000000..82910deb9 --- /dev/null +++ b/vm-images/tomcat/tomcat.sh @@ -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 + diff --git a/vm-images/tomcat/tomcat_build.json b/vm-images/tomcat/tomcat_build.json new file mode 100644 index 000000000..018a19a5b --- /dev/null +++ b/vm-images/tomcat/tomcat_build.json @@ -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": [ + " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" + ], + "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" + ] + } + ] +}