Skip to content

Commit

Permalink
Added cookstyle corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
directdevops committed Jan 28, 2021
1 parent 4e94c6f commit d32b11a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 78 deletions.
6 changes: 3 additions & 3 deletions Jan21/cookbooks/qttomcatserver/attributes/default.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,13 +1,13 @@
default['qttomcatserver']['java_package'] = 'openjdk-8-jdk' default['qttomcatserver']['java_package'] = 'openjdk-8-jdk'
default['qttomcatserver']['groupname'] = 'tomcat' default['qttomcatserver']['groupname'] = 'tomcat'
default['qttomcatserver']['username'] = 'tomcat' default['qttomcatserver']['username'] = 'tomcat'
default['qttomcatserver']['shell'] = '/bin/false' default['qttomcatserver']['shell'] = '/bin/false'
default['qttomcatserver']['homedir'] = '/opt/tomcat' default['qttomcatserver']['homedir'] = '/opt/tomcat'
default['qttomcatserver']['tomcat_download_url'] = 'https://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.41/bin/apache-tomcat-9.0.41.tar.gz' default['qttomcatserver']['tomcat_download_url'] = 'https://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.41/bin/apache-tomcat-9.0.41.tar.gz'
default['qttomcatserver']['tomcat_download_location'] = "/tmp/apache-tomcat-9.0.41.tar.gz" default['qttomcatserver']['tomcat_download_location'] = '/tmp/apache-tomcat-9.0.41.tar.gz'
default['qttomcatserver']['tomcat_location'] = '/opt/tomcat' default['qttomcatserver']['tomcat_location'] = '/opt/tomcat'
default['qttomcatserver']['java_home'] = '/usr/lib/jvm/java-1.8.0-openjdk-amd64' default['qttomcatserver']['java_home'] = '/usr/lib/jvm/java-1.8.0-openjdk-amd64'
default['qttomcatserver']['catalina_opts']='-Xms256M -Xmx512M -server -XX:+UseParallelGC' default['qttomcatserver']['catalina_opts'] = '-Xms256M -Xmx512M -server -XX:+UseParallelGC'
default['qttomcatserver']['webusername'] = 'admin' default['qttomcatserver']['webusername'] = 'admin'
default['qttomcatserver']['webpassword'] = 'password' default['qttomcatserver']['webpassword'] = 'password'
default['qttomcatserver']['roles'] = 'manager-gui,admin-gui' default['qttomcatserver']['roles'] = 'manager-gui,admin-gui'
5 changes: 2 additions & 3 deletions Jan21/cookbooks/qttomcatserver/metadata.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,8 @@
name 'qttomcatserver' name 'qttomcatserver'
maintainer 'The Authors' maintainer 'shaik khaja ibrahim'
maintainer_email 'you@example.com' maintainer_email 'qtdevops@gmail.com'
license 'All Rights Reserved' license 'All Rights Reserved'
description 'Installs/Configures qttomcatserver' description 'Installs/Configures qttomcatserver'
long_description 'Installs/Configures qttomcatserver'
version '0.1.0' version '0.1.0'
chef_version '>= 14.0' chef_version '>= 14.0'


Expand Down
10 changes: 5 additions & 5 deletions Jan21/cookbooks/qttomcatserver/recipes/default.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# #
# Copyright:: 2021, The Authors, All Rights Reserved. # Copyright:: 2021, The Authors, All Rights Reserved.


if node['platform'] == 'ubuntu' if platform?('ubuntu')
include_recipe 'qttomcatserver::ubuntu_tomcat' include_recipe 'qttomcatserver::ubuntu_tomcat'
else else
raise "This cookbook is developed only for ubuntu" raise 'This cookbook is developed only for ubuntu'

end end
115 changes: 51 additions & 64 deletions Jan21/cookbooks/qttomcatserver/recipes/ubuntu_tomcat.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@


# sudo apt-get update # sudo apt-get update
apt_update 'update ubuntu packages' do apt_update 'update ubuntu packages' do
ignore_failure true ignore_failure true
action :update action :update
end end


java_package = node['qttomcatserver']['java_package'] java_package = node['qttomcatserver']['java_package']
package java_package do package java_package do
action :install action :install
end end


# variables from attributes # variables from attributes
Expand All @@ -23,15 +23,15 @@


# Create a user # Create a user
user user_name do user user_name do
home home_folder home home_folder
shell shell shell shell
action :create action :create
end end


# create group and add the user # create group and add the user
group groupname do group groupname do
members user_name members user_name
action :create action :create
end end


# variables for tomcat download location and url and home directory # variables for tomcat download location and url and home directory
Expand All @@ -42,96 +42,83 @@


# Create tomcat home directory # Create tomcat home directory
directory tomcat_location do directory tomcat_location do
owner user_name owner user_name
group groupname group groupname
mode '775' mode '775'
action :create action :create
end end


# download the tomcat tar file # download the tomcat tar file
remote_file tomcat_download_location do remote_file tomcat_download_location do
source tomcat_download_url source tomcat_download_url
action :create action :create
notifies :run, 'execute[untartomcat]', :immediate notifies :run, 'execute[untartomcat]', :immediately
end end


# untar the tomcat tar to /opt/tomcat # untar the tomcat tar to /opt/tomcat
# lets execute manual linux commands # lets execute manual linux commands
# note manual linux commands are not idemponent # note manual linux commands are not idemponent
execute 'untartomcat' do execute 'untartomcat' do
command "sudo tar xzvf #{tomcat_download_location} -C #{tomcat_location} --strip-components=1" command "sudo tar xzvf #{tomcat_download_location} -C #{tomcat_location} --strip-components=1"
action :nothing action :nothing
end end


execute 'give tomcat ownership' do execute 'give tomcat ownership' do
command 'sudo chgrp -R tomcat /opt/tomcat' command 'sudo chgrp -R tomcat /opt/tomcat'
action :nothing action :nothing
subscribes :run, 'execute[untartomcat]', :immediate subscribes :run, 'execute[untartomcat]', :immediate
end end


execute 'give permission to conf' do execute 'give permission to conf' do
command 'sudo chmod -R g+r /opt/tomcat/conf && sudo chmod g+x /opt/tomcat/conf' command 'sudo chmod -R g+r /opt/tomcat/conf && sudo chmod g+x /opt/tomcat/conf'
action :nothing action :nothing
subscribes :run, 'execute[untartomcat]', :immediate subscribes :run, 'execute[untartomcat]', :immediate
end end


execute 'recursive give ownership' do execute 'recursive give ownership' do
command 'sudo chown -R tomcat /opt/tomcat/webapps/ /opt/tomcat/work/ /opt/tomcat/temp/ /opt/tomcat/logs/' command 'sudo chown -R tomcat /opt/tomcat/webapps/ /opt/tomcat/work/ /opt/tomcat/temp/ /opt/tomcat/logs/'
action :nothing action :nothing
subscribes :run, 'execute[untartomcat]', :immediate subscribes :run, 'execute[untartomcat]', :immediate
end end


template '/etc/systemd/system/tomcat.service' do template '/etc/systemd/system/tomcat.service' do
source 'tomcat.service.erb' source 'tomcat.service.erb'
owner user_name owner user_name
group groupname group groupname
mode '0755' mode '0755'
action :create action :create
notifies :restart, 'service[tomcat]', :immediate notifies :restart, 'service[tomcat]', :immediately
end end


service 'tomcat' do service 'tomcat' do
action :enable action :enable
end end


template '/opt/tomcat/conf/tomcat-users.xml' do template '/opt/tomcat/conf/tomcat-users.xml' do
source 'tomcat-users.xml.erb' source 'tomcat-users.xml.erb'
owner user_name owner user_name
group groupname group groupname
mode '0755' mode '0755'
action :create action :create
notifies :restart, 'service[tomcat]', :immediate notifies :restart, 'service[tomcat]', :immediately
end end


context_paths = ['/opt/tomcat/webapps/manager/META-INF/context.xml', '/opt/tomcat/webapps/host-manager/META-INF/context.xml'] context_paths = ['/opt/tomcat/webapps/manager/META-INF/context.xml', '/opt/tomcat/webapps/host-manager/META-INF/context.xml']


context_paths.each do |context_path| context_paths.each do |context_path|
cookbook_file context_path do cookbook_file context_path do
source 'context.xml' source 'context.xml'
owner user_name
group groupname
mode '0755'
action :create
notifies :restart, 'service[tomcat]'
end
end

remote_file '/opt/tomcat/webapps/gameoflife.war' do
source 'https://referenceappkhaja.s3-us-west-2.amazonaws.com/gameoflife.war'
owner user_name owner user_name
group groupname group groupname
mode '0755'
action :create action :create
notifies :restart, 'service[tomcat]'
end
end end



remote_file '/opt/tomcat/webapps/gameoflife.war' do

source 'https://referenceappkhaja.s3-us-west-2.amazonaws.com/gameoflife.war'

owner user_name

group groupname

action :create

end






Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@


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


Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
it { should exist } it { should exist }
end end



describe file('/tmp/apache-tomcat-9.0.41.tar.gz') do describe file('/tmp/apache-tomcat-9.0.41.tar.gz') do
it { should exist } it { should exist }
end end
Expand Down

0 comments on commit d32b11a

Please sign in to comment.