Skip to content

Instantly share code, notes, and snippets.

@bbaugher
Created April 18, 2017 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbaugher/a52e4d65317f97be2a93ec868e11f4ef to your computer and use it in GitHub Desktop.
Save bbaugher/a52e4d65317f97be2a93ec868e11f4ef to your computer and use it in GitHub Desktop.
M1514808:cerner_tomcat bb021949$ kitchen test centos
-----> Starting Kitchen (v1.15.0)
W, [2017-04-18T14:29:09.257308 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:29:09.257458 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:29:09.257641 #54369] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:29:09.257799 #54369] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:29:09.263580 #54369] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:29:09.263696 #54369] WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
-----> Cleaning up any prior instances of <default-centos-67>
-----> Destroying <default-centos-67>...
Finished destroying <default-centos-67> (0m0.00s).
-----> Testing <default-centos-67>
-----> Creating <default-centos-67>...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-6.7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-6.7' is up to date...
==> default: Setting the name of the VM: kitchen-cerner_tomcat-default-centos-67_default_1492543756918_83657
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.0.20
default: VirtualBox Version: 5.1
==> default: Setting hostname...
==> default: Mounting shared folders...
default: /tmp/omnibus/cache => /Users/bb021949/.kitchen/cache
==> default: Machine not provisioned because `--no-provision` is specified.
[SSH] Established
Vagrant instance <default-centos-67> created.
Finished creating <default-centos-67> (0m50.45s).
-----> Converging <default-centos-67>...
Preparing files for transfer
Preparing dna.json
Resolving cookbook dependencies with Berkshelf 5.6.0...
W, [2017-04-18T14:30:07.155180 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:10.692564 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:10.693260 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:10.693882 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:10.694568 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:10.695195 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:10.695814 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.073762 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.074715 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.075664 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.076565 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.077439 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.078546 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.079456 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:12.080385 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:13.232910 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#fetch defined at /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/hashie-3.5.1/lib/hashie/mash.rb:141. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:13.670050 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:14.383676 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:14.384323 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-04-18T14:30:14.384919 #54369] WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#zip defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Removing non-cookbook files before transfer
Preparing solo.rb
-----> Installing Chef Omnibus (install only if missing)
Downloading https://omnitruck.chef.io/install.sh to file /tmp/install.sh
Trying wget...
Download complete.
el 6 x86_64
Getting information for chef stable for el...
downloading https://omnitruck.chef.io/stable/chef/metadata?v=&p=el&pv=6&m=x86_64
to file /tmp/install.sh.2820/metadata.txt
trying wget...
sha1 b92640edfce4b23788cfc6e201e862f985ed6873
sha256 aa47e3da21416091e5cb80fd5a8e9172bc7971a228b522871d7276c915116d2f
url https://packages.chef.io/files/stable/chef/13.0.118/el/6/chef-13.0.118-1.el6.x86_64.rpm
version 13.0.118
downloaded metadata file looks valid...
/tmp/omnibus/cache/chef-13.0.118-1.el6.x86_64.rpm already exists, verifiying checksum...
Comparing checksum with sha256sum...
checksum compare succeeded, using existing file!
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
You are installing an omnibus package without a version pin. If you are installing
on production servers via an automated process this is DANGEROUS and you will
be upgraded without warning on new releases, even to new major releases.
Letting the version float is only appropriate in desktop, test, development or
CI/CD environments.
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
Installing chef
installing with rpm...
warning: /tmp/omnibus/cache/chef-13.0.118-1.el6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
Preparing... ########################################### [100%]
1:chef ########################################### [100%]
Thank you for installing Chef!
Transferring files to <default-centos-67>
Starting Chef Client, version 13.0.118
Creating a new client identity for default-centos-67 using the validator key.
resolving cookbooks for run list: ["apt", "cerner_tomcat_tester"]
Synchronizing Cookbooks:
- cerner_tomcat_tester (1.0.0)
- apt (2.9.2)
- cerner_tomcat (2.3.0)
- ulimit (0.4.0)
- homebrew (3.0.0)
- java (1.47.0)
- windows (2.1.1)
- logrotate (2.1.0)
- compat_resource (12.16.3)
- ohai (5.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
/tmp/kitchen/cache/cookbooks/windows/resources/printer_port.rb:30: warning: constant ::Fixnum is deprecated
/tmp/kitchen/cache/cookbooks/windows/resources/printer_port.rb:33: warning: constant ::Fixnum is deprecated
Converging 13 resources
Recipe: apt::default
* file[/var/lib/apt/periodic/update-success-stamp] action nothing (skipped due to action :nothing)
* directory[/etc/apt/apt.conf.d] action create
- create new directory /etc/apt/apt.conf.d
- restore selinux security context
* cookbook_file[/etc/apt/apt.conf.d/15update-stamp] action create
- create new file /etc/apt/apt.conf.d/15update-stamp
- update content in file /etc/apt/apt.conf.d/15update-stamp from none to 174cdb
--- /etc/apt/apt.conf.d/15update-stamp 2017-04-18 19:32:35.380146003 +0000
+++ /etc/apt/apt.conf.d/.chef-15update-stamp20170418-2926-ms9641 2017-04-18 19:32:35.379145503 +0000
@@ -1 +1,2 @@
+APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};
- restore selinux security context
* execute[apt-get update] action nothing (skipped due to action :nothing)
* execute[apt-get autoremove] action nothing (skipped due to action :nothing)
* execute[apt-get autoclean] action nothing (skipped due to action :nothing)
* execute[apt-get-update-periodic] action run (skipped due to only_if)
* directory[/var/cache/local] action create (skipped due to only_if)
* directory[/var/cache/local/preseeding] action create (skipped due to only_if)
* template[/etc/apt/apt.conf.d/10recommends] action create
- create new file /etc/apt/apt.conf.d/10recommends
- update content in file /etc/apt/apt.conf.d/10recommends from none to f41e1d
--- /etc/apt/apt.conf.d/10recommends 2017-04-18 19:32:35.495203503 +0000
+++ /etc/apt/apt.conf.d/.chef-10recommends20170418-2926-m9c4rm 2017-04-18 19:32:35.495203503 +0000
@@ -1 +1,4 @@
+# Managed by Chef
+APT::Install-Recommends "1";
+APT::Install-Suggests "0";
- change mode from '' to '0644'
- change owner from '' to 'root'
- change group from '' to 'root'
- restore selinux security context
* yum_package[apt-transport-https] action install (skipped due to only_if)
Recipe: cerner_tomcat_tester::default
* cerner_tomcat[my_tomcat] action install
Recipe: java::notify
* log[jdk-version-changed] action nothing (skipped due to action :nothing)
Recipe: java::openjdk
* yum_package[java-1.8.0-openjdk] action install
- install version 1.8.0.121-1.b13.el6 of package java-1.8.0-openjdk
Recipe: java::notify
* log[jdk-version-changed] action write
Recipe: java::openjdk
* yum_package[java-1.8.0-openjdk-devel] action install
- install version 1.8.0.121-1.b13.el6 of package java-1.8.0-openjdk-devel
Recipe: java::notify
* log[jdk-version-changed] action write
Recipe: java::openjdk
* java_alternatives[set-java-alternatives] action set
- Add alternative for appletviewer
- Add alternative for extcheck
- Add alternative for idlj
- Add alternative for jar
- Add alternative for jarsigner
- Add alternative for java
- Add alternative for javac
- Add alternative for javadoc
- Add alternative for javah
- Add alternative for javap
- Add alternative for jcmd
- Add alternative for jconsole
- Add alternative for jdb
- Add alternative for jdeps
- Add alternative for jhat
- Add alternative for jinfo
- Add alternative for jjs
- Add alternative for jmap
- Add alternative for jps
- Add alternative for jrunscript
- Add alternative for jsadebugd
- Add alternative for jstack
- Add alternative for jstat
- Add alternative for jstatd
- Add alternative for keytool
- Add alternative for native2ascii
- Add alternative for orbd
- Add alternative for pack200
- Add alternative for policytool
- Add alternative for rmic
- Add alternative for rmid
- Add alternative for rmiregistry
- Add alternative for schemagen
- Add alternative for serialver
- Add alternative for servertool
- Add alternative for tnameserv
- Add alternative for unpack200
- Add alternative for wsgen
- Add alternative for wsimport
- Add alternative for xjc
Recipe: java::set_java_home
* directory[/etc/profile.d] action create (up to date)
* template[/etc/profile.d/jdk.sh] action create
- create new file /etc/profile.d/jdk.sh
- update content in file /etc/profile.d/jdk.sh from none to 7f8009
--- /etc/profile.d/jdk.sh 2017-04-18 19:34:44.880863999 +0000
+++ /etc/profile.d/.chef-jdk20170418-2926-13iahx1.sh 2017-04-18 19:34:44.880863999 +0000
@@ -1 +1,2 @@
+export JAVA_HOME=/usr/lib/jvm/java-1.8.0
- change mode from '' to '0755'
- restore selinux security context
* yum_package[curl_my_tomcat] action install (up to date)
* group[my_group] action create
- create group my_group
* linux_user[my_user] action create
- create user my_user
Recipe: <Dynamically Defined Resource>
* template[/etc/security/limits.d/my_user_limits.conf] action create
- create new file /etc/security/limits.d/my_user_limits.conf
- update content in file /etc/security/limits.d/my_user_limits.conf from none to 49c7af
--- /etc/security/limits.d/my_user_limits.conf 2017-04-18 19:34:45.343095005 +0000
+++ /etc/security/limits.d/.chef-my_user_limits20170418-2926-1lnr59o.conf 2017-04-18 19:34:45.343095005 +0000
@@ -1 +1,13 @@
+# Limits settings for my_user
+
+my_user - nofile 65536
+
+my_user - nproc 4096
+
+
+
+
+
+
+
- change mode from '' to '0644'
- change owner from '' to 'root'
- change group from '' to 'root'
- restore selinux security context
* directory[/opt/my_dir] action create
- create new directory /opt/my_dir
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* remote_file[/tmp/kitchen/cache/cerner_tomcat_my_tomcat-apache-tomcat.tar.gz] action create
- create new file /tmp/kitchen/cache/cerner_tomcat_my_tomcat-apache-tomcat.tar.gz
- update content in file /tmp/kitchen/cache/cerner_tomcat_my_tomcat-apache-tomcat.tar.gz from none to a009f8
(new content is binary, diff output suppressed)
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* service[tomcat_my_tomcat] action stop (up to date)
* bash[install_tomcat_my_tomcat] action run
- execute "bash" "/tmp/chef-script20170418-2926-131hap6"
* bash[install_tomcat_my_tomcat] action nothing (skipped due to action :nothing)
* directory[/opt/my_logs] action create
- create new directory /opt/my_logs
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* link[/opt/my_logs/my_tomcat] action create
- create symlink at /opt/my_logs/my_tomcat to /opt/my_dir/my_tomcat/logs[2017-04-18T19:35:00+00:00] WARN: /opt/my_logs/my_tomcat mode not changed: File.lchmod is unimplemented on this OS and Ruby version
[2017-04-18T19:35:00+00:00] WARN: /opt/my_logs/my_tomcat mode not changed: File.lchmod is unimplemented on this OS and Ruby version
- change mode from '0777' to '0755'
- change owner from 'root' to 'my_user'
- change group from 'root' to 'my_group'
* logrotate_app[tomcat-my_tomcat] action enable
* directory[/etc/logrotate.d] action create (up to date)
* template[/etc/logrotate.d/tomcat-my_tomcat] action create
- create new file /etc/logrotate.d/tomcat-my_tomcat
- update content in file /etc/logrotate.d/tomcat-my_tomcat from none to 5580a8
--- /etc/logrotate.d/tomcat-my_tomcat 2017-04-18 19:35:00.743791501 +0000
+++ /etc/logrotate.d/.chef-tomcat-my_tomcat20170418-2926-q6kw0c 2017-04-18 19:35:00.740790001 +0000
@@ -1 +1,13 @@
+# This file was generated by Chef for default-centos-67.vagrantup.com.
+# Do not modify this file by hand!
+
+"/opt/my_logs/my_tomcat/*.out" "/opt/my_logs/my_tomcat/*.log" {
+ daily
+ maxsize 100M
+ rotate 1
+ size 10M
+ notifempty
+ copytruncate
+ compress
+}
- change mode from '' to '0644'
- change owner from '' to 'root'
- change group from '' to 'root'
- restore selinux security context
* template[/etc/init.d/tomcat_my_tomcat] action create
- create new file /etc/init.d/tomcat_my_tomcat
- update content in file /etc/init.d/tomcat_my_tomcat from none to 2ff893
--- /etc/init.d/tomcat_my_tomcat 2017-04-18 19:35:00.859849498 +0000
+++ /etc/init.d/.chef-tomcat_my_tomcat20170418-2926-u42wc9 2017-04-18 19:35:00.859849498 +0000
@@ -1 +1,166 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: my_tomcat
+# Short-Description: my_tomcat tomcat server
+# Default-Start: 1 2 3 4 5
+# Default-Stop: 0 1 2 6
+# Required-Start:
+# Required-Stop:
+# Should-Start:
+# Should-Stop:
+# Thing: Value
+### END INIT INFO
+
+# Set up the path to CATALINA_HOME (base of Tomcat)
+CATALINA_HOME=/opt/my_dir/my_tomcat
+SLEEP_TIME=5
+TIMEOUT=60
+USER=my_user
+NAME=my_tomcat
+START_CLASS="org.apache.catalina.startup.Bootstrap start"
+
+if [[ ! -f $CATALINA_HOME/bin/catalina.sh ]]; then
+ echo "$NAME may not be installed..."
+ exit 1
+fi
+
+start() {
+ find_pid
+
+ if [[ $PID -gt 0 ]]; then
+ echo "$NAME is already started"
+ else
+ echo "Starting $NAME:"
+ su -l $USER -c $CATALINA_HOME/bin/startup.sh
+
+ if [[ $? -ne 0 ]]; then
+ echo "Error starting $NAME"
+ exit 1
+ fi
+
+ echo "Waiting for application at http://localhost:8001/my_webapp/hello to start"
+ HC_CODE=$(healthCheck http://localhost:8001/my_webapp/hello GET 3 )
+ for BACKOFF in 0 5 10 30 30 60
+ do
+
+ if $(wasSuccessful $HC_CODE); then
+ echo "Health check passed with status $HC_CODE"
+ break
+ fi
+
+ echo "Health check failed with status $HC_CODE"
+ echo "Sleeping for $BACKOFF"
+ sleep $BACKOFF
+ HC_CODE=$(healthCheck http://localhost:8001/my_webapp/hello GET 3 )
+
+ done
+ if ! $(wasSuccessful $HC_CODE); then
+ echo "Application at http://localhost:8001/my_webapp/hello failed to start."
+ exit 1
+ fi
+
+ echo
+ fi
+}
+
+stop() {
+ echo "Shutting down $NAME:"
+
+ find_pid
+
+ CURRENT_WAIT=0
+
+ # Wait until tomcat has successfully stopped
+ while [[ $PID -gt 0 ]];
+ do
+ echo "Attempting to shutdown $NAME..."
+ su -l $USER -c $CATALINA_HOME/bin/shutdown.sh
+
+ if [[ $? -ne 0 ]]; then
+ echo "Error stopping $NAME"
+ exit 1
+ fi
+
+ sleep $SLEEP_TIME
+ CURRENT_WAIT=$(($CURRENT_WAIT+$SLEEP_TIME))
+ if [[ $CURRENT_WAIT -gt $TIMEOUT ]]; then
+ echo "Timed out waiting for $NAME to stop"
+ exit 1
+ fi
+
+ find_pid
+ done
+ echo "$NAME has stopped"
+}
+
+status() {
+ find_pid
+ if [[ $PID -gt 0 ]]; then
+ echo "$NAME ( pid $PID ) is running..."
+ else
+ echo "$NAME is stopped" ; exit 1
+ fi
+}
+
+health() {
+ EXIT_CODE=0
+ HC_CODE=0
+ echo -n "Testing application at http://localhost:8001/my_webapp/hello ..."
+ HC_CODE=$(healthCheck http://localhost:8001/my_webapp/hello GET 3 )
+ if $(wasSuccessful $HC_CODE); then
+ echo "Health check passed with status $HC_CODE"
+ else
+ echo "Health check failed with status $HC_CODE"
+ EXIT_CODE=1
+ fi
+ exit $EXIT_CODE
+}
+
+# Runs an HTTP health check against the specified URI.
+# Parameters:
+# 1: request URI
+# 2: request method (get, head, etc.)
+# 3: maximum request time
+# 4: additional arguments
+healthCheck() {
+ curl "--$2" -s -L -w "%{http_code}\\n" "$1" --max-time "$3" -o /dev/null ${@:4}
+}
+
+# Checks whether a health check result was successful.
+# Parameters:
+# 1: The HTTP status code from the health check request
+# Returns: boolean true (i.e. 0) or boolean false (i.e. 1)
+wasSuccessful() {
+ if [[ $1 -ge 200 && $1 -le 299 ]]; then
+ return `true`
+ else
+ return `false`
+ fi
+}
+
+find_pid() {
+ PID=`pgrep -u $USER -f "$CATALINA_HOME.*$START_CLASS"`
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ status)
+ status
+ ;;
+ health)
+ health
+ ;;
+ *)
+ echo "Usage: tomcat_$NAME {start|stop|restart|status|health}"
+ exit 1
+esac
- change mode from '' to '0755'
- restore selinux security context
* template[/opt/my_dir/my_tomcat/bin/setenv.sh] action create
- create new file /opt/my_dir/my_tomcat/bin/setenv.sh
- update content in file /opt/my_dir/my_tomcat/bin/setenv.sh from none to a36355
- suppressed sensitive resource
- change mode from '' to '0755'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat/webapps/my_webapp] action create
- create new directory /opt/my_dir/my_tomcat/webapps/my_webapp
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* execute[delete my_tomcat web app my_webapp] action nothing (skipped due to action :nothing)
* remote_file[/opt/my_dir/my_tomcat/webapps/my_webapp.war] action create
- create new file /opt/my_dir/my_tomcat/webapps/my_webapp.war
- update content in file /opt/my_dir/my_tomcat/webapps/my_webapp.war from none to 89b33c
(new content is binary, diff output suppressed)
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* service[tomcat_my_tomcat] action stop (up to date)
* execute[delete my_tomcat web app my_webapp] action run
- execute rm -rf /opt/my_dir/my_tomcat/webapps/my_webapp/*
* execute[jar xf /opt/my_dir/my_tomcat/webapps/my_webapp.war] action run
- execute jar xf /opt/my_dir/my_tomcat/webapps/my_webapp.war
* directory[/opt/my_dir/my_tomcat/webapps/my_webapp] action create (up to date)
* cookbook_file[/opt/my_dir/my_tomcat/webapps/my_webapp/my_file] action create
- create new file /opt/my_dir/my_tomcat/webapps/my_webapp/my_file
- update content in file /opt/my_dir/my_tomcat/webapps/my_webapp/my_file from none to eccc63
- suppressed sensitive resource
- change mode from '' to '0750'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat/webapps/my_webapp] action create (up to date)
* remote_file[/opt/my_dir/my_tomcat/webapps/my_webapp/my_remote_file] action create
- create new file /opt/my_dir/my_tomcat/webapps/my_webapp/my_remote_file
- update content in file /opt/my_dir/my_tomcat/webapps/my_webapp/my_remote_file from none to 5d6ae8
- suppressed sensitive resource
- change mode from '' to '0750'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat/webapps/my_webapp] action create (up to date)
* template[/opt/my_dir/my_tomcat/webapps/my_webapp/my_template] action create
- create new file /opt/my_dir/my_tomcat/webapps/my_webapp/my_template
- update content in file /opt/my_dir/my_tomcat/webapps/my_webapp/my_template from none to 3ef125
- suppressed sensitive resource
- change mode from '' to '0750'
- change owner from '' to 'my_user'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat] action create
- change owner from 'root' to 'my_user'
- change group from 'root' to 'my_group'
- restore selinux security context
* cookbook_file[/opt/my_dir/my_tomcat/my_file] action create
- create new file /opt/my_dir/my_tomcat/my_file
- update content in file /opt/my_dir/my_tomcat/my_file from none to eccc63
- suppressed sensitive resource
- change mode from '' to '0767'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* cookbook_file[/opt/my_dir/my_tomcat/only_if_skipped_cookbook_file] action create (skipped due to only_if)
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* cookbook_file[/opt/my_dir/my_tomcat/not_if_skipped_cookbook_file] action create (skipped due to not_if)
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* remote_file[/opt/my_dir/my_tomcat/my_remote_file] action create
- create new file /opt/my_dir/my_tomcat/my_remote_file
- update content in file /opt/my_dir/my_tomcat/my_remote_file from none to 3c491d
- suppressed sensitive resource
- change mode from '' to '0747'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* remote_file[/opt/my_dir/my_tomcat/only_if_skipped_remote_file] action create (skipped due to only_if)
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* remote_file[/opt/my_dir/my_tomcat/not_if_skipped_remote_file] action create (skipped due to not_if)
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* remote_file[/opt/my_dir/my_tomcat/multiple_not_if_skipped_remote_file] action create (skipped due to not_if)
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* template[/opt/my_dir/my_tomcat/my_template] action create
- create new file /opt/my_dir/my_tomcat/my_template
- update content in file /opt/my_dir/my_tomcat/my_template from none to 6d8034
- suppressed sensitive resource
- change mode from '' to '0707'
- change owner from '' to 'my_user'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* template[/opt/my_dir/my_tomcat/only_if_skipped_template] action create (skipped due to only_if)
* directory[/opt/my_dir/my_tomcat] action create (up to date)
* template[/opt/my_dir/my_tomcat/not_if_skipped_template] action create (skipped due to not_if)
* directory[/opt/my_dir/my_tomcat/conf] action create
- change owner from 'root' to 'my_user'
- change group from 'root' to 'my_group'
- restore selinux security context
* template[/opt/my_dir/my_tomcat/conf/server.xml] action create
- update content in file /opt/my_dir/my_tomcat/conf/server.xml from 52bc27 to 590846
- suppressed sensitive resource
- change mode from '0600' to '0750'
- change owner from 'root' to 'my_user'
- restore selinux security context
* execute[chown -R my_user:my_group /opt/my_dir/my_tomcat] action run
- execute chown -R my_user:my_group /opt/my_dir/my_tomcat
* service[tomcat_my_tomcat] action enable
- enable service service[tomcat_my_tomcat]
* service[tomcat_my_tomcat] action restart
- restart service service[tomcat_my_tomcat]
Recipe: cerner_tomcat_tester::default
* cerner_tomcat[my_tomcat_2] action install
* yum_package[curl_my_tomcat_2] action install (up to date)
* group[my_group] action create (skipped due to only_if)
* linux_user[my_user] action create (skipped due to only_if)
Recipe: <Dynamically Defined Resource>
* template[/etc/security/limits.d/my_user_limits.conf] action create (up to date)
* directory[/opt/my_dir] action create (up to date)
* remote_file[/tmp/kitchen/cache/cerner_tomcat_my_tomcat_2-apache-tomcat.tar.gz] action create
- create new file /tmp/kitchen/cache/cerner_tomcat_my_tomcat_2-apache-tomcat.tar.gz
- update content in file /tmp/kitchen/cache/cerner_tomcat_my_tomcat_2-apache-tomcat.tar.gz from none to a009f8
(new content is binary, diff output suppressed)
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* service[tomcat_my_tomcat_2] action stop (up to date)
* bash[install_tomcat_my_tomcat_2] action run
- execute "bash" "/tmp/chef-script20170418-2926-fy3d9t"
* bash[install_tomcat_my_tomcat_2] action nothing (skipped due to action :nothing)
* directory[/opt/my_logs] action create (up to date)
* link[/opt/my_logs/my_tomcat_2] action create
- create symlink at /opt/my_logs/my_tomcat_2 to /opt/my_dir/my_tomcat_2/logs[2017-04-18T19:35:37+00:00] WARN: /opt/my_logs/my_tomcat_2 mode not changed: File.lchmod is unimplemented on this OS and Ruby version
[2017-04-18T19:35:37+00:00] WARN: /opt/my_logs/my_tomcat_2 mode not changed: File.lchmod is unimplemented on this OS and Ruby version
- change mode from '0777' to '0755'
- change owner from 'root' to 'my_user'
- change group from 'root' to 'my_group'
* logrotate_app[tomcat-my_tomcat_2] action enable
* directory[/etc/logrotate.d] action create (up to date)
* template[/etc/logrotate.d/tomcat-my_tomcat_2] action create
- create new file /etc/logrotate.d/tomcat-my_tomcat_2
- update content in file /etc/logrotate.d/tomcat-my_tomcat_2 from none to 56e582
--- /etc/logrotate.d/tomcat-my_tomcat_2 2017-04-18 19:35:37.478149502 +0000
+++ /etc/logrotate.d/.chef-tomcat-my_tomcat_220170418-2926-1hgglf5 2017-04-18 19:35:37.478149502 +0000
@@ -1 +1,13 @@
+# This file was generated by Chef for default-centos-67.vagrantup.com.
+# Do not modify this file by hand!
+
+"/opt/my_logs/my_tomcat_2/*.out" "/opt/my_logs/my_tomcat_2/*.log" {
+ daily
+ maxsize 100M
+ rotate 1
+ size 10M
+ notifempty
+ copytruncate
+ compress
+}
- change mode from '' to '0644'
- change owner from '' to 'root'
- change group from '' to 'root'
- restore selinux security context
* template[/etc/init.d/tomcat_my_tomcat_2] action create
- create new file /etc/init.d/tomcat_my_tomcat_2
- update content in file /etc/init.d/tomcat_my_tomcat_2 from none to 4100bd
--- /etc/init.d/tomcat_my_tomcat_2 2017-04-18 19:35:37.593207000 +0000
+++ /etc/init.d/.chef-tomcat_my_tomcat_220170418-2926-21yv8g 2017-04-18 19:35:37.593207000 +0000
@@ -1 +1,166 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: my_tomcat_2
+# Short-Description: my_tomcat_2 tomcat server
+# Default-Start: 1 2 3 4 5
+# Default-Stop: 0 1 2 6
+# Required-Start:
+# Required-Stop:
+# Should-Start:
+# Should-Stop:
+# Thing: Value
+### END INIT INFO
+
+# Set up the path to CATALINA_HOME (base of Tomcat)
+CATALINA_HOME=/opt/my_dir/my_tomcat_2
+SLEEP_TIME=5
+TIMEOUT=60
+USER=my_user
+NAME=my_tomcat_2
+START_CLASS="org.apache.catalina.startup.Bootstrap start"
+
+if [[ ! -f $CATALINA_HOME/bin/catalina.sh ]]; then
+ echo "$NAME may not be installed..."
+ exit 1
+fi
+
+start() {
+ find_pid
+
+ if [[ $PID -gt 0 ]]; then
+ echo "$NAME is already started"
+ else
+ echo "Starting $NAME:"
+ su -l $USER -c $CATALINA_HOME/bin/startup.sh
+
+ if [[ $? -ne 0 ]]; then
+ echo "Error starting $NAME"
+ exit 1
+ fi
+
+ echo "Waiting for application at http://localhost:8011/my_webapp/hello to start"
+ HC_CODE=$(healthCheck http://localhost:8011/my_webapp/hello GET 3 -k)
+ for BACKOFF in 0 5 10 30 30 60
+ do
+
+ if $(wasSuccessful $HC_CODE); then
+ echo "Health check passed with status $HC_CODE"
+ break
+ fi
+
+ echo "Health check failed with status $HC_CODE"
+ echo "Sleeping for $BACKOFF"
+ sleep $BACKOFF
+ HC_CODE=$(healthCheck http://localhost:8011/my_webapp/hello GET 3 -k)
+
+ done
+ if ! $(wasSuccessful $HC_CODE); then
+ echo "Application at http://localhost:8011/my_webapp/hello failed to start."
+ exit 1
+ fi
+
+ echo
+ fi
+}
+
+stop() {
+ echo "Shutting down $NAME:"
+
+ find_pid
+
+ CURRENT_WAIT=0
+
+ # Wait until tomcat has successfully stopped
+ while [[ $PID -gt 0 ]];
+ do
+ echo "Attempting to shutdown $NAME..."
+ su -l $USER -c $CATALINA_HOME/bin/shutdown.sh
+
+ if [[ $? -ne 0 ]]; then
+ echo "Error stopping $NAME"
+ exit 1
+ fi
+
+ sleep $SLEEP_TIME
+ CURRENT_WAIT=$(($CURRENT_WAIT+$SLEEP_TIME))
+ if [[ $CURRENT_WAIT -gt $TIMEOUT ]]; then
+ echo "Timed out waiting for $NAME to stop"
+ exit 1
+ fi
+
+ find_pid
+ done
+ echo "$NAME has stopped"
+}
+
+status() {
+ find_pid
+ if [[ $PID -gt 0 ]]; then
+ echo "$NAME ( pid $PID ) is running..."
+ else
+ echo "$NAME is stopped" ; exit 1
+ fi
+}
+
+health() {
+ EXIT_CODE=0
+ HC_CODE=0
+ echo -n "Testing application at http://localhost:8011/my_webapp/hello ..."
+ HC_CODE=$(healthCheck http://localhost:8011/my_webapp/hello GET 3 -k)
+ if $(wasSuccessful $HC_CODE); then
+ echo "Health check passed with status $HC_CODE"
+ else
+ echo "Health check failed with status $HC_CODE"
+ EXIT_CODE=1
+ fi
+ exit $EXIT_CODE
+}
+
+# Runs an HTTP health check against the specified URI.
+# Parameters:
+# 1: request URI
+# 2: request method (get, head, etc.)
+# 3: maximum request time
+# 4: additional arguments
+healthCheck() {
+ curl "--$2" -s -L -w "%{http_code}\\n" "$1" --max-time "$3" -o /dev/null ${@:4}
+}
+
+# Checks whether a health check result was successful.
+# Parameters:
+# 1: The HTTP status code from the health check request
+# Returns: boolean true (i.e. 0) or boolean false (i.e. 1)
+wasSuccessful() {
+ if [[ $1 -ge 200 && $1 -le 299 ]]; then
+ return `true`
+ else
+ return `false`
+ fi
+}
+
+find_pid() {
+ PID=`pgrep -u $USER -f "$CATALINA_HOME.*$START_CLASS"`
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ status)
+ status
+ ;;
+ health)
+ health
+ ;;
+ *)
+ echo "Usage: tomcat_$NAME {start|stop|restart|status|health}"
+ exit 1
+esac
- change mode from '' to '0755'
- restore selinux security context
* template[/opt/my_dir/my_tomcat_2/bin/setenv.sh] action create
- create new file /opt/my_dir/my_tomcat_2/bin/setenv.sh
- update content in file /opt/my_dir/my_tomcat_2/bin/setenv.sh from none to a36355
- suppressed sensitive resource
- change mode from '' to '0755'
- restore selinux security context
* directory[/opt/my_dir/my_tomcat_2/webapps/my_webapp] action create
- create new directory /opt/my_dir/my_tomcat_2/webapps/my_webapp
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* execute[delete my_tomcat_2 web app my_webapp] action nothing (skipped due to action :nothing)
* remote_file[/opt/my_dir/my_tomcat_2/webapps/my_webapp.war] action create
- create new file /opt/my_dir/my_tomcat_2/webapps/my_webapp.war
- update content in file /opt/my_dir/my_tomcat_2/webapps/my_webapp.war from none to 89b33c
(new content is binary, diff output suppressed)
- change mode from '' to '0755'
- change owner from '' to 'my_user'
- change group from '' to 'my_group'
- restore selinux security context
* service[tomcat_my_tomcat_2] action stop (up to date)
* execute[delete my_tomcat_2 web app my_webapp] action run
- execute rm -rf /opt/my_dir/my_tomcat_2/webapps/my_webapp/*
* execute[jar xf /opt/my_dir/my_tomcat_2/webapps/my_webapp.war] action run
- execute jar xf /opt/my_dir/my_tomcat_2/webapps/my_webapp.war
* directory[/opt/my_dir/my_tomcat_2/conf] action create
- change owner from 'root' to 'my_user'
- change group from 'root' to 'my_group'
- restore selinux security context
* template[/opt/my_dir/my_tomcat_2/conf/server.xml] action create
- update content in file /opt/my_dir/my_tomcat_2/conf/server.xml from 52bc27 to 0fdc5c
- suppressed sensitive resource
- change mode from '0600' to '0750'
- change owner from 'root' to 'my_user'
- restore selinux security context
* execute[chown -R my_user:my_group /opt/my_dir/my_tomcat_2] action run
- execute chown -R my_user:my_group /opt/my_dir/my_tomcat_2
* service[tomcat_my_tomcat_2] action enable
- enable service service[tomcat_my_tomcat_2]
* service[tomcat_my_tomcat_2] action restart
- restart service service[tomcat_my_tomcat_2]
Running handlers:
Running handlers complete
Chef Client finished, 55/101 resources updated in 03 minutes 11 seconds
Finished converging <default-centos-67> (5m46.48s).
-----> Setting up <default-centos-67>...
Finished setting up <default-centos-67> (0m0.00s).
-----> Verifying <default-centos-67>...
Preparing files for transfer
-----> Installing Busser (busser)
Fetching: thor-0.19.0.gem (100%)
Successfully installed thor-0.19.0
Fetching: busser-0.7.1.gem (100%)
Successfully installed busser-0.7.1
2 gems installed
Installing Busser plugins: busser-serverspec
Plugin serverspec installed (version 0.5.10)
-----> Running postinstall for serverspec plugin
Suite path directory /tmp/verifier/suites does not exist, skipping.
Transferring files to <default-centos-67>
-----> Running serverspec test suite
-----> Installing Serverspec..
Fetching: diff-lcs-1.3.gem (100%)
Fetching: rspec-expectations-3.5.0.gem (100%)
Fetching: rspec-mocks-3.5.0.gem (100%)
Fetching: rspec-3.5.0.gem (100%)
Fetching: rspec-its-1.2.0.gem (100%)
Fetching: multi_json-1.12.1.gem (100%)
Fetching: net-ssh-4.1.0.gem (100%)
Fetching: net-scp-1.2.1.gem (100%)
Fetching: net-telnet-0.1.1.gem (100%)
Fetching: sfl-2.3.gem (100%)
Fetching: specinfra-2.67.8.gem (100%)
Fetching: serverspec-2.38.0.gem (100%)
-----> serverspec installed (version 2.38.0)
/opt/chef/embedded/bin/ruby -I/tmp/verifier/suites/serverspec -I/tmp/verifier/gems/gems/rspec-support-3.5.0/lib:/tmp/verifier/gems/gems/rspec-core-3.5.4/lib /opt/chef/embedded/bin/rspec --pattern /tmp/verifier/suites/serverspec/\*\*/\*_spec.rb --color --format documentation --default-path /tmp/verifier/suites/serverspec
User "my_user"
should exist
should belong to group "my_group"
Service "my_tomcat"
should be running
Service "my_tomcat_2"
should be running
Process "java"
count
should eq 2
user
should eq "my_user"
args
should match /-Xms512m -Xmx512m -XX:PermSize=384m -XX:MaxPermSize=384m/
File "/opt/my_dir/my_tomcat/my_file"
should be file
should be owned by "my_user"
should be grouped into "my_group"
should be mode 767
File "/opt/my_dir/my_tomcat/only_if_skipped_cookbook_file"
should not exist
File "/opt/my_dir/my_tomcat/not_if_skipped_cookbook_file"
should not exist
File "/opt/my_dir/my_tomcat/my_remote_file"
should be file
should be owned by "my_user"
should be grouped into "my_group"
should be mode 747
File "/opt/my_dir/my_tomcat/only_if_skipped_remote_file"
should not exist
File "/opt/my_dir/my_tomcat/not_if_skipped_remote_file"
should not exist
File "/opt/my_dir/my_tomcat/multiple_not_if_skipped_remote_file"
should not exist
File "/opt/my_dir/my_tomcat/my_template"
should be file
should be owned by "my_user"
should be grouped into "my_group"
should contain "tomcat_my_template"
should be mode 707
File "/opt/my_dir/my_tomcat/only_if_skipped_template"
should not exist
File "/opt/my_dir/my_tomcat/not_if_skipped_template"
should not exist
File "/opt/my_dir/my_tomcat/webapps/my_webapp"
should be directory
should be owned by "my_user"
should be grouped into "my_group"
File "/opt/my_dir/my_tomcat/webapps/my_webapp.war"
should be file
should be owned by "my_user"
should be grouped into "my_group"
File "/opt/my_dir/my_tomcat/webapps/my_webapp/my_file"
should be file
should be owned by "my_user"
should be grouped into "my_group"
File "/opt/my_dir/my_tomcat/webapps/my_webapp/my_remote_file"
should be file
should be owned by "my_user"
should be grouped into "my_group"
File "/opt/my_dir/my_tomcat/webapps/my_webapp/my_template"
should be file
should be owned by "my_user"
should be grouped into "my_group"
should contain "web_app_template"
File "/opt/my_logs"
should be directory
should be owned by "my_user"
should be grouped into "my_group"
File "/opt/my_logs/my_tomcat"
should be symlink
should be linked to "/opt/my_dir/my_tomcat/logs"
should be owned by "my_user"
should be grouped into "my_group"
File "/etc/logrotate.d/tomcat-my_tomcat"
should contain "\"/opt/my_logs/my_tomcat/*.out\" \"/opt/my_logs/my_tomcat/*.log\" {"
should contain "rotate 1"
should contain "maxsize 100M"
should contain "size 10M"
should contain "daily"
should contain "compress"
should contain "copytruncate"
File "/etc/init.d/tomcat_my_tomcat"
should be file
should be owned by "root"
should be grouped into "root"
should contain "# Thing: Value"
should contain "# Default-Start: 1 2 3 4 5"
should contain "# Provides: my_tomcat"
should contain "# Default-Stop: 0 1 2 6"
should contain "HC_CODE=$(healthCheck http://localhost:8001/my_webapp/hello GET 3 )"
File "/etc/init.d/tomcat_my_tomcat_2"
should be file
should be owned by "root"
should be grouped into "root"
should contain "# Thing: Value"
should contain "# Default-Start: 1 2 3 4 5"
should contain "# Provides: my_tomcat_2"
should contain "# Default-Stop: 0 1 2 6"
should contain "HC_CODE=$(healthCheck http://localhost:8011/my_webapp/hello GET 3 -k)"
File "/opt/my_dir/my_tomcat/bin/setenv.sh"
should be file
should be owned by "my_user"
should be grouped into "my_group"
should contain "export TEST_VAR=TEST_VALUE"
File "/etc/security/limits.d/my_user_limits.conf"
should be file
should contain "my_user - nofile 65536"
should contain "my_user - nproc 4096"
Finished in 0.61178 seconds (files took 0.27909 seconds to load)
80 examples, 0 failures
Finished verifying <default-centos-67> (0m18.58s).
-----> Destroying <default-centos-67>...
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
Vagrant instance <default-centos-67> destroyed.
Finished destroying <default-centos-67> (0m4.17s).
Finished testing <default-centos-67> (6m59.72s).
-----> Kitchen is finished. (7m0.29s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment