Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds servicepack, waits for validation urls upon restart and other changes #62

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#2.2.3
* Fixes
* Replaces hard-coded url to criticalmass server with an attribute for Service Pack

#2.2.2
* Enhancements
* Waits for validation urls each time an aem instance is restarted

#2.2.1
* Enhancements
* Add servicepack when indicated by an attribute
* Relaxes version constraint on ark cookbook such that no conflict arises with maven cookbook.

#2.2.0
* Enhancements
* Add new group provider.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.5
7 changes: 7 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
'CQ_PERMGEN' => '128'
}

# To install a service pack, specify the name of the pack and a complete url of that.
# Ex: 'AEM-6.1-Service-Pack-1-6.1.SP1.zip' and 'http://fileserver/AEM-6.1-Service-Pack-1-6.1.SP1.zip'
default[:aem][:service_pack] = nil
default[:aem][:service_pack_url] = 'http://a-dummy-url'

# These work in such a way that the providers will find the closest matching command using the provided
# node[:aem][:version]. The command matching the given version without going over will be used.
# For example, if node[:aem][:version] is 5.5, then node[:aem][:commands][:replicators][:publish][:add]['5.4']
Expand Down Expand Up @@ -270,3 +275,5 @@
default[:aem][:dispatcher][:mod_dispatcher_checksum] = nil
default[:aem][:dispatcher][:deflate_enabled] = true
default[:aem][:dispatcher][:header] = []

default[:aem][:curb_version] = '0.9.4'
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
supports 'centos'

depends 'apache2'
depends 'ark', '~> 0.8.2'
depends 'ark'
depends 'iptables'
depends 'java'
41 changes: 41 additions & 0 deletions providers/startup_urls_watcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Cookbook Name:: aem
# Provider:: startup_urls_watcher
#
# Copyright 2016, Critical Mass, Inc.
#
# Licensed 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.

# This provider creates a resource that monitors a collection of validation urls on a newly started aem instance

action :wait do
instance_name = new_resource.instance_name
if node[:aem][:version].to_f > 5.4
node['aem'][instance_name]['validation_urls'].each do |url|
aem_url_watcher url do
validation_url url
status_command "service aem-#{instance_name} status | grep running"
max_attempts node['aem'][instance_name]['startup']['max_attempts']
wait_between_attempts node['aem'][instance_name]['startup']['wait_between_attempts']
user node['aem'][instance_name]['admin_user']
password node['aem'][instance_name]['admin_password']
action :wait
end
end
else
aem_port_watcher node['aem'][instance_name][port] do
status_command "service aem-#{instance_name} status | grep running"
action :wait
end
end
end
1 change: 1 addition & 0 deletions recipes/_base_aem_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
chef_gem 'curb' do
compile_time false if Chef::Resource::ChefGem.method_defined?(:compile_time)
action :nothing
version node[:aem][:curb_version]
end.run_action(:install)

require 'curb'
Expand Down
63 changes: 34 additions & 29 deletions recipes/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
node.set[:aem][:author][:runnable_jar] = "aem-author-p#{node[:aem][:author][:port]}.jar"
end

#Install Service Pack
directory "#{node['aem']['author']['base_dir']}/install" do
owner node['aem']['aem_options']['RUNAS_USER']
mode '0755'
action :create
not_if { node['aem']['service_pack'].nil? || node['aem']['service_pack'].empty? }
end

remote_file "#{node['aem']['author']['base_dir']}/install/#{node['aem']['service_pack']}" do
source node['aem']['service_pack_url']
owner node['aem']['aem_options']['RUNAS_USER']
action :create_if_missing
not_if { node['aem']['service_pack'].nil? || node['aem']['service_pack'].empty? }
end

aem_init 'aem-author' do
service_name 'aem-author'
default_context node[:aem][:author][:default_context]
Expand All @@ -62,40 +77,30 @@
status_command 'service aem-author status | grep running'
supports status: true, stop: true, start: true, restart: true
action [:enable, :start]
notifies :wait, 'aem_startup_urls_watcher[author]', :immediately
end

if node[:aem][:version].to_f > 5.4
node[:aem][:author][:validation_urls].each do |url|
aem_url_watcher url do
validation_url url
status_command 'service aem-author status | grep running'
max_attempts node[:aem][:author][:startup][:max_attempts]
wait_between_attempts node[:aem][:author][:startup][:wait_between_attempts]
user node[:aem][:author][:admin_user]
password node[:aem][:author][:admin_password]
action :wait
end
end
else
aem_port_watcher '4502' do
status_command 'service aem-author status | grep running'
action :wait
end
aem_startup_urls_watcher 'author' do
action :nothing
end

unless node[:aem][:author][:new_admin_password].nil?
# Change admin password
aem_user node[:aem][:author][:admin_user] do
password node[:aem][:author][:new_admin_password]
admin_user node[:aem][:author][:admin_user]
admin_password node[:aem][:author][:admin_password]
port node[:aem][:author][:port]
aem_version node[:aem][:version]
action :set_password
end
aem_user node[:aem][:author][:admin_user] do
password node[:aem][:author][:new_admin_password]
admin_user node[:aem][:author][:admin_user]
admin_password node[:aem][:author][:admin_password]
port node[:aem][:author][:port]
aem_version node[:aem][:version]
action :set_password
only_if { !node[:aem][:author][:new_admin_password].nil? }
notifies :run, 'ruby_block[update author admin password attribute]', :immediately
end

node.set[:aem][:author][:admin_password] = node[:aem][:author][:new_admin_password]
node.set[:aem][:author][:new_admin_password] = nil
ruby_block 'update author admin password attribute' do
block do
node.set['aem']['author']['admin_password'] = node['aem']['author']['new_admin_password']
node.set['aem']['author']['new_admin_password'] = nil
end
only_if { !node[:aem][:author][:new_admin_password].nil? }
end

# delete the privileged users from geometrixx, if they're still there.
Expand Down
63 changes: 34 additions & 29 deletions recipes/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
node.set[:aem][:publish][:runnable_jar] = "aem-publish-p#{node[:aem][:publish][:port]}.jar"
end

#Install Service Pack
directory "#{node['aem']['publish']['base_dir']}/install" do
owner node['aem']['aem_options']['RUNAS_USER']
mode '0755'
action :create
not_if { node['aem']['service_pack'].nil? || node['aem']['service_pack'].empty? }
end

remote_file "#{node['aem']['publish']['base_dir']}/install/#{node['aem']['service_pack']}" do
source node['aem']['service_pack_url']
owner node['aem']['aem_options']['RUNAS_USER']
action :create_if_missing
not_if { node['aem']['service_pack'].nil? || node['aem']['service_pack'].empty? }
end

aem_init 'aem-publish' do
service_name 'aem-publish'
default_context node[:aem][:publish][:default_context]
Expand All @@ -62,40 +77,30 @@
status_command 'service aem-publish status | grep running'
supports status: true, stop: true, start: true, restart: true
action [:enable, :start]
notifies :wait, 'aem_startup_urls_watcher[publish]', :immediately
end

if node[:aem][:version].to_f > 5.4
node[:aem][:publish][:validation_urls].each do |url|
aem_url_watcher url do
validation_url url
status_command 'service aem-publish status | grep running'
max_attempts node[:aem][:publish][:startup][:max_attempts]
wait_between_attempts node[:aem][:publish][:startup][:wait_between_attempts]
user node[:aem][:publish][:admin_user]
password node[:aem][:publish][:admin_password]
action :wait
end
end
else
aem_port_watcher '4503' do
status_command 'service aem-publish status | grep running'
action :wait
end
aem_startup_urls_watcher 'publish' do
action :nothing
end

unless node[:aem][:publish][:new_admin_password].nil?
# Change admin password
aem_user node[:aem][:publish][:admin_user] do
password node[:aem][:publish][:new_admin_password]
admin_user node[:aem][:publish][:admin_user]
admin_password node[:aem][:publish][:admin_password]
port node[:aem][:publish][:port]
aem_version node[:aem][:version]
action :set_password
end
aem_user node[:aem][:publish][:admin_user] do
password node[:aem][:publish][:new_admin_password]
admin_user node[:aem][:publish][:admin_user]
admin_password node[:aem][:publish][:admin_password]
port node[:aem][:publish][:port]
aem_version node[:aem][:version]
action :set_password
only_if { !node[:aem][:publish][:new_admin_password].nil? }
notifies :run, 'ruby_block[update publish admin password attribute]', :immediately
end

node.set[:aem][:publish][:admin_password] = node[:aem][:publish][:new_admin_password]
node.set[:aem][:publish][:new_admin_password] = nil
ruby_block 'update publish admin password attribute' do
block do
node.set['aem']['publish']['admin_password'] = node['aem']['publish']['new_admin_password']
node.set['aem']['publish']['new_admin_password'] = nil
end
only_if { !node[:aem][:publish][:new_admin_password].nil? }
end

# delete the privileged users from geometrixx, if they're still there.
Expand Down
21 changes: 21 additions & 0 deletions resources/startup_urls_watcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Cookbook Name:: aem
# Resource:: startup_urls_watcher
#
# Copyright 2016, Critical Mass, Inc.
#
# Licensed 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.

actions :wait

attribute :instance_name, kind_of: String, name_attribute: true