forked from bryanwb/cookbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic version of ivy works w/ dynamic attrs
- Loading branch information
Showing
13 changed files
with
253 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,41 @@ Description | |
installs apache ivy and provides and lwrp for downloading jars and | ||
their dependencies from ivy and maven repositories | ||
|
||
Eventually should have an LWRP to define additional ivy and maven | ||
repositories to pull jars from | ||
|
||
Providers/Resources | ||
=================== | ||
|
||
* artifactId: if this is not specified, the resource's name is used | ||
* groupId: groupId for the artifact | ||
* version: version of the artifact | ||
* dest: the destination folder for the jar and its dependencies | ||
* dest_attr: This is funky, use a node attribute optionally with subdirectory | ||
* owner: the owner of the resulting file | ||
* mode: file permissions | ||
|
||
|
||
# Examples | ||
|
||
ivy "mysql-connector-java" do | ||
groupId "mysql" | ||
version "5.1.18" | ||
dest "/usr/local/tomcat/lib/" | ||
end | ||
|
||
ivy "mysql-connector-java" do | ||
groupId "mysql" | ||
version "5.1.18" | ||
dest_attr "tomcat_base/lib" | ||
end | ||
|
||
dest_attr resolves to "#{node[current_cookbook_name]['tomcat']['base']}/lib" | ||
|
||
## License and Author | ||
|
||
Author:: Bryan W. Berry (<[email protected]>) | ||
Copyright:: 2011, Bryan W. Berry | ||
Copyright:: 2012, Bryan W. Berry | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# Cookbook Name:: ivy | ||
# Provider:: default | ||
# | ||
# Author:: Bryan W. Berry <[email protected]> | ||
# Copyright 2012, Bryan W. Berry | ||
# | ||
# 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. | ||
# | ||
|
||
def resolve_dest(resource) | ||
# use a glob because file can have different extensions | ||
file_glob = "#{resource.artifactId}-#{resource.version}\.*" | ||
if resource.dest_attr | ||
dest_attrs = resource.dest_attr.split(':') | ||
subdirectory = dest_attrs[-1].match('/') ? dest_attrs.pop : "" | ||
node_attr = eval( "node['#{self.cookbook_name}']" + | ||
dest_attrs.map{ |attr| "['" + attr + "']" }.join('') ) | ||
dest = "#{node_attr}/#{subdirectory}" | ||
else | ||
dest = "#{resource.dest}" | ||
end | ||
"#{dest}/#{file_glob}" | ||
end | ||
|
||
action :install do | ||
full_name = [ new_resource.groupId, new_resource.artifactId, new_resource.version ].join(' ') | ||
dest = resolve_dest new_resource | ||
Chef::Log.debug("dest is #{dest}") | ||
dest_pattern = "#{dest}/[artifact]-[revision].[ext]" | ||
full_command = %Q{#{node['ivy']['command']} -dependency #{full_name} -retrieve #{dest_pattern} } | ||
Chef::Log.debug("dest is #{dest}") | ||
bash "get the dependency" do | ||
code <<-EOH | ||
#{full_command} | ||
chown #{new_resource.owner}:#{new_resource.owner} #{dest} | ||
chmod #{new_resource.mode.to_s} #{dest} | ||
EOH | ||
only_if { Dir.glob("#{dest}\.*").empty? } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Cookbook Name:: ivy | ||
# Resource:: default | ||
# | ||
# Author:: Bryan W. Berry <[email protected]> | ||
# Copyright 2012, Bryan W. Berry | ||
# | ||
# 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 :install | ||
|
||
attribute :artifactId, :kind_of => String | ||
attribute :groupId, :kind_of => String, :required => true | ||
attribute :version, :kind_of => String, :required => true | ||
attribute :dest, :kind_of => String | ||
attribute :dest_attr, :kind_of => String | ||
attribute :owner, :kind_of => String, :default => "root" | ||
attribute :mode, :kind_of => [String, Integer], :default => "0755" | ||
|
||
def initialize(*args) | ||
super | ||
# we can't use the node properties when initially specifying the resource | ||
@artifactId ||= @name | ||
@action = :install | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Overview | ||
======== | ||
|
||
This cookbook installs jira from Atlassian | ||
|
||
|
||
Attributes | ||
========== | ||
|
||
|
||
## License and Author | ||
|
||
Author:: Bryan W. Berry (<[email protected]>) | ||
copyright:: 2012, Bryan W. Berry | ||
|
||
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Cookbook Name:: jira | ||
# Description:: installs jira | ||
# Attributes:: default | ||
# Author:: Bryan W. Berry | ||
# | ||
# Copyright 2012, Bryan W. Berry | ||
# | ||
# 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. | ||
# | ||
|
||
default['jira']['user'] = "jira" | ||
default['jira']['war_url'] = "http://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-5.0-war.zip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
maintainer "Bryan W. Berry" | ||
maintainer_email "[email protected]" | ||
license "Apache 2.0" | ||
description "Installs/Configures jira" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.0.1" | ||
|
||
%w{ java ark tomcat }.each do |cb| | ||
depends cb | ||
end | ||
|
||
%w{ debian ubuntu centos redhat fedora }.each do |os| | ||
supports os | ||
end | ||
|
||
recipe "jira::default", "Installs and configures jira" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Cookbook Name:: jira | ||
# Description:: installs jira | ||
# Recipe:: default | ||
# Author:: Bryan W. Berry | ||
# | ||
# Copyright 2012, Bryan W. Berry | ||
# | ||
# 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. | ||
# | ||
|
||
include_recipe "ark" | ||
include_recipe "tomcat::base" | ||
include_recipe "ivy" | ||
base = "/tmp/" | ||
|
||
t = tomcat "jira" do | ||
user node['jira']['user'] | ||
action :install | ||
end | ||
|
||
# get mysql connector | ||
ivy "mysql-connector-java" do | ||
groupId "mysql" | ||
version "5.1.18" | ||
dest_attr ":tomcat:base:/lib" | ||
end | ||
|
||
# ark "jira_war" do | ||
# release_url node['jira']['war_url'] | ||
# version "5.0" | ||
# install_dir "/usr/local/tomcat/jira/webapps/ROOT" | ||
# no_symlink true | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters