Skip to content

Commit

Permalink
Added deployment step
Browse files Browse the repository at this point in the history
  • Loading branch information
qtsathish committed Jun 6, 2021
1 parent 97a8136 commit 7647aa6
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 2 deletions.
3 changes: 3 additions & 0 deletions May21/cookbooks/qt_tomcat/attributes/default.rb
Expand Up @@ -20,3 +20,6 @@
default['qt_tomcat']['tomcat_service_file'] = '/etc/systemd/system/tomcat.service'
default['qt_tomcat']['tomcat_download_temp_location'] = '/tmp/apache-tomcat-9.0.46.tar.gz'

#warfile url
default['qt_tomcat']['warfile_url'] = 'https://referenceapplicationskhaja.s3-us-west-2.amazonaws.com/gameoflife.war'
default['qt_tomcat']['warfile_destination'] = '/opt/tomcat/webapps/gameoflife.war'
Binary file added May21/cookbooks/qt_tomcat/gameoflife.war
Binary file not shown.
3 changes: 1 addition & 2 deletions May21/cookbooks/qt_tomcat/kitchen.yml
Expand Up @@ -50,8 +50,7 @@ platforms:
suites:
- name: default
run_list:
- recipe[qt_tomcat::install_java]
- recipe[qt_tomcat::configure]
- recipe[qt_tomcat::default]
verifier:
inspec_tests:
- test/integration/default
Expand Down
8 changes: 8 additions & 0 deletions May21/cookbooks/qt_tomcat/recipes/default.rb
Expand Up @@ -3,3 +3,11 @@
# Recipe:: default
#
# Copyright:: 2021, The Authors, All Rights Reserved.

if node['platform'] == 'ubuntu' or node['platform'] == 'redhat'
include_recipe 'qt_tomcat::install_java'
include_recipe 'qt_tomcat::configure'
include_recipe 'qt_tomcat::deploy'
else
raise 'This cookbook supports only ubuntu and redhat platforms'
end
15 changes: 15 additions & 0 deletions May21/cookbooks/qt_tomcat/recipes/deploy.rb
@@ -0,0 +1,15 @@
#
# Cookbook:: qt_tomcat
# Recipe:: deploy
#
# Copyright:: 2021, The Authors, All Rights Reserved.

# download the file from internet into node

war_url = node['qt_tomcat']['warfile_url']
war_dest = node['qt_tomcat']['warfile_destination']

remote_file war_dest do
source war_url
action :create
end
29 changes: 29 additions & 0 deletions May21/cookbooks/qt_tomcat/spec/unit/recipes/deploy_spec.rb
@@ -0,0 +1,29 @@
#
# Cookbook:: .
# Spec:: deploy
#
# Copyright:: 2021, The Authors, All Rights Reserved.

require 'spec_helper'

describe '.::deploy' do
context 'When all attributes are default, on Ubuntu 20.04' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'ubuntu', '20.04'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end

context 'When all attributes are default, on CentOS 8' do
# for a complete list of available platforms and versions see:
# https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
platform 'centos', '8'

it 'converges successfully' do
expect { chef_run }.to_not raise_error
end
end
end
16 changes: 16 additions & 0 deletions May21/cookbooks/qt_tomcat/test/integration/default/deploy_test.rb
@@ -0,0 +1,16 @@
# InSpec test for recipe .::deploy

# The Chef InSpec reference, with examples and extensive documentation, can be
# found at https://docs.chef.io/inspec/resources/

unless os.windows?
# This is an example test, replace with your own test.
describe user('root'), :skip do
it { should exist }
end
end

# This is an example test, replace it with your own test.
describe port(80), :skip do
it { should_not be_listening }
end

0 comments on commit 7647aa6

Please sign in to comment.