Vagrant configuration\!

This commit is contained in:
Preston Lee 2014-10-06 18:47:56 -07:00
parent 507ea9bedf
commit a744665bcc
158 changed files with 11484 additions and 0 deletions

6
.gitignore vendored
View File

@ -3,3 +3,9 @@
*.log *.log
*.log* *.log*
nohup.out nohup.out
.DS_Store
# Vagrant stuff.
.vagrant
/data
/chef/tmp

111
Vagrantfile vendored Normal file
View File

@ -0,0 +1,111 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu/trusty64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network"
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
config.ssh.forward_agent = true
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "data", '/data'
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
#
# View the documentation for the provider you're using for more
# information on available options.
# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
config.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "./chef/cookbooks"
chef.roles_path = "./chef/roles"
chef.data_bags_path = "./chef/data_bags"
chef.add_recipe 'nmap'
chef.add_recipe 'mysql::server'
chef.add_recipe 'mysql::client'
chef.add_recipe 'tomcat'
chef.add_recipe 'tomcat::users' # Currently broken :( https://github.com/opscode-cookbooks/tomcat/pull/79
pw = "MySQLpassword"
chef.json = {
java: {
install_flavor: 'oracle',
jdk_version: 8,
oracle: {
accept_oracle_download_terms: true
}
},
tomcat: {
base_version: 7,
proxy_port: 80,
# ssl_port: 443,
authbind: 'yes'
},
mysql: {
version: '5.6',
server_root_password: pw,
server_debian_password: pw,
server_repl_password: pw,
allow_remote_root: true
}
}
end
require 'fileutils'
build_dir = File.join('data', 'build')
Dir.glob('**/target/*.war').each do |f|
FileUtils.cp(f, build_dir)
end
# Deploy any/all built .war files.
config.vm.provision 'shell', inline: 'cp /data/build/*.war /var/lib/tomcat7/webapps'
# Set MySQL to start automatically at boot, and fire it up.
config.vm.provision 'shell', inline: 'update-rc.d mysql defaults'
config.vm.provision 'shell', inline: 'service mysql restart'
end

10
chef/Cheffile Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env ruby
#^syntax detection
site 'https://supermarket.getchef.com/api/v1'
# cookbook 'emacs24-nox'
cookbook 'nmap'
cookbook 'java'
cookbook 'mysql'
cookbook 'tomcat'

23
chef/Cheffile.lock Normal file
View File

@ -0,0 +1,23 @@
SITE
remote: https://supermarket.getchef.com/api/v1
specs:
chef-sugar (2.3.0)
java (1.28.0)
mysql (5.5.3)
yum-mysql-community (>= 0.0.0)
nmap (0.1.0)
openssl (2.0.0)
chef-sugar (>= 0.0.0)
tomcat (0.16.2)
java (>= 0.0.0)
openssl (>= 0.0.0)
yum (3.3.2)
yum-mysql-community (0.1.10)
yum (>= 3.0)
DEPENDENCIES
java (>= 0)
mysql (>= 0)
nmap (>= 0)
tomcat (>= 0)

View File

@ -0,0 +1,92 @@
Chef Sugar Changelog
=========================
This file is used to list changes made in each version of the chef-sugar cookbook and gem.
v2.3.0 (2014-09-24)
-------------------
### Improvements
- Add `vmware?` matcher
- Allow the attribute DSL to access parent attributes
### Bug Fixes
- Return `true` or `false` from all Boolean methods (instead of `nil` or truthy values)
v2.2.0 (2014-08-20)
-------------------
### Improvements
- Add `smartos?` matcher
- Add `omnios?` matcher
v2.1.0 (2014-06-26)
-------------------
### Improvements
- Add `solaris2?` matcher
- Add `aix?` matcher
- Add 'lxc?' matcher
### Bug Fixes
- Fix a bug in namespace memoization during attribute initialization
v2.0.0 (2014-06-16)
-------------------
### Breaking
- Remove `not_linux?` method
- Remove `not_windows?` method
### Improvements
- Miscellaneous spelling fixes
- Update a failing unit test for `installed?`
- Add Mac OS X to the list of platforms (Yosemite)
- Upgrade to RSpec 3
- Fix `which` (and `installed?` and `installed_at_version?`) when given an absolute path
- Fix `linux?` check to only return true on real linuxes
v1.3.0 (2014-05-05)
-------------------
- Check both `$stdout` and `$stderr` in `version_for`
- Add additional platform versions
- Make `includes_recipe?` a top-level API (instead of just Node)
- Match on the highest version number instead of direct equality checking on platform versions
- Define `Object#blank?` as a core extension
- Define `String#flush` as a core extension
- Remove Stove
v1.2.6 (2014-03-16)
-------------------
- Fix a bug in `vagrant?` returning false on newer Vagrant versions
- Remove Coveralls
v1.2.4 (2014-03-13)
-------------------
- See (1.2.2), but I botched the release
v1.2.2 (2014-03-13)
-------------------
- Fix a critical bug with `encrypted_data_bag_item` using the wrong key
v1.2.0 (2014-03-09)
-------------------
- Add `namespace` functionality for specifying attributes in a DSL
- Add constraints helpers for comparing version strings
- Add `require_chef_gem` to safely require and degrade if a gem is not installed
- Add `deep_fetch` and `deep_fetch!` to fetch deeply nested keys
- Accept an optional secret key in `encrypted_data_bag_item` helper and raise a helpful error if one is not set (NOTE: this changes the airity of the method, but it's backward-compatible because Ruby is magic)
- Add Stove for releasing
- Updated copyrights for 2014
v1.1.0 (2013-12-10)
-------------------
- Add `cloudstack?` helper
- Add data bag helpers
- Remove foodcritic checks
- Upgrade development gem versions
- Randomize spec order
v1.0.1 (2013-10-15)
-------------------
- Add development recipe
- Add `compile_time`, `before`, and `after` filters
v1.0.0 (2013-10-15)
-------------------
- First public release

View File

@ -0,0 +1,441 @@
Chef::Sugar
================
[![Gem Version](http://img.shields.io/gem/v/chef-sugar.svg)][gem]
[![Build Status](http://img.shields.io/travis/sethvargo/chef-sugar.svg)][travis]
[![Dependency Status](http://img.shields.io/gemnasium/sethvargo/chef-sugar.svg)][gemnasium]
[![Code Climate](http://img.shields.io/codeclimate/github/sethvargo/chef-sugar.svg)][codeclimate]
[![Gittip](http://img.shields.io/gittip/sethvargo.svg)][gittip]
[gem]: https://rubygems.org/gems/chef-sugar
[travis]: http://travis-ci.org/sethvargo/chef-suguar
[gemnasium]: https://gemnasium.com/sethvargo/chef-sugar
[codeclimate]: https://codeclimate.com/github/sethvargo/chef-sugar
[gittip]: https://www.gittip.com/sethvargo
Chef Sugar is a Gem & Chef Recipe that includes series of helpful sugar of the Chef core and other resources to make a cleaner, more lean recipe DSL, enforce DRY principles, and make writing Chef recipes an awesome experience!
Installation
------------
If you want to develop/hack on chef-sugar, please see the Contributing.md.
If you are using Berkshelf, add `chef-sugar` to your `Berksfile`:
```ruby
cookbook 'chef-sugar'
```
Otherwise, you can use `knife` or download the tarball directly from the community site:
```ruby
knife cookbook site install chef-sugar
```
Usage
-----
In order to use Chef Sugar in your Chef Recipes, you'll first need to include it:
```ruby
include_recipe 'chef-sugar::default'
```
Alternatively you can put it in a base role or recipe and it will be included subsequently.
Requiring the Chef Sugar Gem will automatically extend the Recipe DSL, `Chef::Resource`, and `Chef::Provider` with helpful convenience methods.
### Module Method
If you are working outside of the Recipe DSL, you can use the module methods instead of the Recipe DSL. In general, the module methods have the same name as their Recipe-DSL counterparts, but require the node object as a parameter. For example:
In a Recipe:
```ruby
# cookbook/recipes/default.rb
do_something if windows?
```
In a Library as a singleton:
```ruby
# cookbook/libraries/default.rb
def only_on_windows(&block)
yield if Chef::Sugar::PlatformFamily.windows?(@node)
end
```
In a Library as a Mixin:
```ruby
# cookbook/libraries/default.rb
include Chef::Sugar::PlatformFamily
def only_on_windows(&block)
yield if windows?(@node)
end
```
API
---
**Note:** For the most extensive API documentation, please see the YARD documentation.
### Architecture
**Note:** Some of the architecture commands begin with an underscore (`_`) because Ruby does not permit methods to start with a numeric.
- `_64_bit?`
- `_32_bit?`
#### Examples
```ruby
execute 'build[my binary]' do
command '...'
not_if { _64_bit? }
end
```
### Cloud
- `azure?`
- `cloud?`
- `ec2?`
- `eucalyptus?`
- `gce?`
- `linode?`
- `openstack?`
- `cloudstack?`
- `rackspace?`
#### Examples
```ruby
template '/tmp/config' do
variables(
# See also: best_ip_for
ipaddress: cloud? ? node['local_ipv4'] : node['public_ipv4']
)
end
```
### Core Extensions
**Note:** Core extensions are **not** included by default. You must require the `chef/sugar/core_extensions` module manually to gain access to these APIs:
```ruby
require 'chef/sugar/core_extensions'
```
- `String#satisfies?`
- `String#satisfied_by?`
- `Array#satisfied_by?`
- `Object#blank?`
#### Examples
```ruby
# Checking version constraints
'1.0.0'.satisfies?('~> 1.0') #=> true
'~> 1.0'.satisfied_by?('1.0') #=> true
```
```ruby
# Check for an object's presence
''.blank? #=> true
['hello'].blank? #=> false
```
### Data Bag
- `encrypted_data_bag_item` - a handy DSL method for loading encrypted data bag items the same way you load a regular data bag item; this requires `Chef::Config[:encrypted_data_bag_secret]` is set!
- `encrypted_data_bag_item_for_environment` - find the data bag entry for the current node's Chef environment.
#### Examples
```ruby
encrypted_data_bag_item('accounts', 'hipchat')
```
```ruby
encrypted_data_bag_item_for_environment('accounts', 'github')
```
### Attributes
Chef Sugar adds more Chef-like DSL to attribute definitions. Instead of using the Ruby hash syntax, you can define attributes using nested namespaces. This DSL may be more friendly to non-Ruby developers. It can safely be mixed-and-matched with the standard syntax.
```ruby
# This is functionally the same as default['apache2']['config']['root'] = '/var/www'
namespace 'apache2' do
namespace 'config' do
root '/var/www'
end
end
```
```ruby
# Specify multiple keys instead of nesting namespaces
namespace 'apache2', 'config' do
root '/var/www'
end
```
```ruby
# Specify different nested precedence levels
namespace 'apache2', precedence: normal do
namespace 'config', precedence: override do
root '/var/www' #=> override['apache2']['config']['root'] = '/var/www'
end
end
```
### Constraints
- `constraints` - create a new constraint (or requirement) that can be used to test version validations.
- `chef_version` - (DSL only) a wrapper for `version(Chef::VERSION)`
- `version` - create a new version that can be used to test constraint validation.
#### Examples
```ruby
# Check if a version is satisfied by a constraint
version('1.2.3').satisfies?('~> 1.2.0')
```
```ruby
# Check if a constraint is satisfied by a version
constraint('~> 1.2.0').satisfied_by?('1.2.3')
```
```ruby
# Support multiple constraints
version('1.2.3').satisfies?('> 1.2', '< 2.0')
constraint('> 1.2', '< 2.0').satisfied_by?('1.2.3')
```
```ruby
# Only perform an operation if Chef is at a certain version
package 'apache2' do
not_if { chef_version.satisfies?('~> 11.0') } # Ignore Chef 11
end
```
### Kernel
- `require_chef_gem` - "safely" require a gem. Loading a gem with Chef is sometimes difficult and confusing. The errors that Chef produces are also sometimes not very intuitive. In the event you require a gem to exist on the system, you can use `require_chef_gem`, which will attempt to require the gem and then produce helpful output if the gem is not installed:
Chef could not load the gem `#{name}'! You may need to install the gem
manually with `gem install #{name}', or include a recipe before you can
use this resource. Please consult the documentation for this cookbook
for proper usage.
#### Examples
```ruby
# LWRP
require_chef_gem 'pry'
```
```ruby
class Chef
class Provider
class MyProvider > Provider
require_chef_gem 'pry'
end
end
end
```
### IP
- `best_ip_for` - determine the best IP address for the given "other" node, preferring local IP addresses over public ones.
#### Examples
```ruby
redis = search('node', 'role:redis').first
template '/tmp/config' do
variables(
ipaddress: best_ip_for(redis)
)
end
```
### Node
- `deep_fetch` - safely fetch a nested attribute.
- `deep_fetch!` - fetch a nested attribute, raising a more semantic error if the key does not exist.
- `in?` - determine if the node is in the given Chef environment.
#### Examples
```ruby
credentials = if in?('production')
Chef::EncryptedDataBag.new('...')
else
data_bag('...')
end
```
```ruby
node.deep_fetch('apache2', 'config', 'root') => node['apache2']['config']['root']
```
### Platform
- `amazon_linux?`
- `centos?`
- `linux_mint?`
- `oracle_linux?`
- `redhat_enterprise_linux?`
- `scientific_linux?`
- `ubuntu?`
- `solaris2?`
- `aix?`
- `smartos?`
- `omnios?`
There are also a series of dynamically defined matchers that map named operating system release versions and comparison operators in the form "#{platform}\_#{operator}\_#{name}?". For example:
- `debian_after_squeeze?`
- `linuxmint_after_or_at_olivia?`
- `mac_os_x_lion?`
- `ubuntu_before_lucid?`
- `ubuntu_before_or_at_maverick?`
To get a full list, run the following in IRB:
```ruby
require 'chef/sugar'
puts Chef::Sugar::Platform.instance_methods
```
#### Examples
```ruby
if ubuntu?
execute 'apt-get update'
end
```
### Platform Family
- `arch_linux?`
- `debian?`
- `fedora?`
- `freebsd?`
- `gentoo?`
- `linux?`
- `mac_os_x?`
- `openbsd?`
- `rhel?`
- `slackware?`
- `suse?`
- `windows?`
#### Examples
```ruby
node['attribute'] = if windows?
'C:\Foo\BarDrive'
else
'/foo/bar_drive'
end
```
### Ruby
**Note:** The applies to the Ruby found at `node['languages']['ruby']`.
- `ruby_20?`
- `ruby_19?`
#### Examples
```ruby
log 'This has been known to fail on Ruby 2.0' if ruby_20?
```
### Run Context
- `includes_recipe?` - determines if the current run context includes the recipe
```ruby
if includes_recipe?('apache2::default')
apache_module 'my_module' do
# ...
end
end
```
### Shell
- `which`
- `dev_null`
- `installed?`
- `installed_at_version?`
- `version_for`
#### Examples
```ruby
log "Using `mongo` at `#{which('mongo')}`"
if installed?('apt')
execute 'apt-get update'
end
execute 'install[thing]' do
command "... 2>&1 #{dev_null}"
not_if { installed_at_version?('thing', node['thing']['version']) }
end
log "Skipping git install, version is at #{version_for('mongo', '-v')}"
```
### Vagrant
- `vagrant?`
#### Examples
```ruby
http_request 'http://...' do
not_if { vagrant? }
end
```
### Virtualization
- `lxc?`
- `vmware?`
#### Examples
```ruby
service 'ntpd' do
action [:enable, :start]
not_if { lxc? }
end
```
### Filters
- `compile_time` - accepts a block of resources to run at compile time
- `before` - insert resource in the collection before the given resource
- `after` - insert resource in the collection after the given resource
#### Examples
```ruby
compile_time do
package 'apache2'
end
# This is equivalent to
package 'apache2' do
action :nothing
end.run_action(:install)
```
```ruby
before 'service[apache2]' do
log 'I am before the apache 2 service fires!'
end
```
```ruby
after 'service[apache2]' do
log 'I am after the apache 2 service fires!'
end
```
License & Authors
-----------------
- Author: Seth Vargo (sethvargo@gmail.com)
```text
Copyright 2013-2014 Seth Vargo
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.
```

View File

@ -0,0 +1,29 @@
{
"name": "chef-sugar",
"version": "2.3.0",
"description": "Installs chef-sugar. Please see the chef-sugar Ruby gem for more information.",
"long_description": "Chef Sugar is a Gem & Chef Recipe that includes series of helpful syntactic\nsugars on top of the Chef core and other resources to make a cleaner, more lean\nrecipe DSL, enforce DRY principles, and make writing Chef recipes an awesome and\nfun experience!\n\nFor the most up-to-date information and documentation, please visit the [Chef\nSugar project page on GitHub](https://github.com/sethvargo/chef-sugar).\n",
"maintainer": "Seth Vargo",
"maintainer_email": "sethvargo@gmail.com",
"license": "Apache 2.0",
"platforms": {
},
"dependencies": {
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"attributes": {
},
"groupings": {
},
"recipes": {
}
}

View File

@ -0,0 +1,17 @@
name 'chef-sugar'
maintainer 'Seth Vargo'
maintainer_email 'sethvargo@gmail.com'
license 'Apache 2.0'
description 'Installs chef-sugar. Please see the chef-sugar ' \
'Ruby gem for more information.'
long_description <<-EOH
Chef Sugar is a Gem & Chef Recipe that includes series of helpful syntactic
sugars on top of the Chef core and other resources to make a cleaner, more lean
recipe DSL, enforce DRY principles, and make writing Chef recipes an awesome and
fun experience!
For the most up-to-date information and documentation, please visit the [Chef
Sugar project page on GitHub](https://github.com/sethvargo/chef-sugar).
EOH
version '2.3.0'

View File

@ -0,0 +1,25 @@
#
# Cookbook Name:: chef-sugar
# Recipe:: default
#
# Copyright 2013-2014, Seth Vargo <sethvargo@gmail.com>
#
# 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.
#
chef_gem('chef-sugar') do
version '2.3.0'
action :nothing
end.run_action(:install)
require 'chef/sugar'

21
chef/cookbooks/java/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
*.tmp
*.bk
*.bkup
.kitchen.local.yml
Berksfile.lock
Gemfile.lock
.bundle/
.cache/
.kitchen/
.vagrant/
.vagrant.d/
bin/
tmp/
vendor/

View File

@ -0,0 +1,108 @@
---
driver:
name: vagrant
require_chef_omnibus: true
customize:
memory: 1024
provisioner:
name: chef_solo
attributes:
java:
ark_retries: 2
ark_retry_delay: 10
platforms:
- name: ubuntu-14.04
run_list:
- recipe[apt]
driver:
box: opscode-ubuntu-14.04
- name: ubuntu-13.10
driver:
box: opscode-ubuntu-13.10
run_list:
- recipe[apt]
- name: ubuntu-12.04
driver:
box: opscode-ubuntu-12.04
run_list:
- recipe[apt]
- name: ubuntu-10.04
driver:
box: opscode-ubuntu-10.04
run_list:
- recipe[apt]
- name: debian-6.0.8
driver:
box: opscode-debian-6.0.8
run_list:
- recipe[apt]
- name: debian-7.4
driver:
box: opscode-debian-7.4
run_list:
- recipe[apt]
- name: centos-6.5
driver:
box: opscode-centos-6.5
- name: centos-5.10
driver:
box: opscode-centos-5.10
- name: fedora-19
driver:
box: opscode-fedora-19
suites:
- name: openjdk
excludes:
- fedora-19
run_list:
- recipe[java::default]
- name: openjdk-7
excludes:
- ubuntu-10.04
- debian-6.0.8
run_list:
- recipe[java::default]
attributes:
java:
jdk_version: "7"
- name: oracle
run_list:
- recipe[java::default]
attributes:
java:
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
- name: oracle-7
run_list:
- recipe[java::default]
attributes:
java:
jdk_version: "7"
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
- name: oracle-8
run_list:
- recipe[java::default]
attributes:
java:
jdk_version: "8"
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
- name: oracle-direct
run_list:
- recipe[java::oracle]
attributes:
java:
oracle:
accept_oracle_download_terms: true
- name: openjdk-direct
run_list:
- recipe[java::openjdk]
excludes:
- fedora-19

View File

@ -0,0 +1,7 @@
source "https://supermarket.getchef.com"
metadata
group :integration do
cookbook 'apt', '~> 2.0'
cookbook 'windows', '~> 1.12'
end

View File

@ -0,0 +1,362 @@
Java Cookbook CHANGELOG
=======================
This file is used to list changes made in each version of the Java cookbook.
v1.28.0 - 9/6/2014
-------
### Improvement
- Allow setting of group to extracted java files.
### Bug
- Add -no-same-owner parameter to tar extract to avoid issues when the chef cache dir is on an NFS mounted drive.
- In the ark provider, it doesn't compare the MD5 sum with the right value which causes Java cookbook always download tarball from oracle server
v1.27.0 - 8/22/2014
-------
- Update Oracle JDK8 to version 8u20
v1.26.0 - 8/16/2014
-------
- **[#201](https://github.com/agileorbit-cookbooks/java/pull/201)** - Allow pinning of package versions for openjdk
- **[#198](https://github.com/agileorbit-cookbooks/java/pull/198)** - Update Oracle JDK7 to version 7u67
- **[#189](https://github.com/agileorbit-cookbooks/java/pull/184)** - Support specific version and name for Oracle RPM
v1.25.0 - 8/1/2014
-------
### Improvement
- **[#189](https://github.com/agileorbit-cookbooks/java/pull/189)** - Resource ark -> attribute bin_cmds default value
- **[#168](https://github.com/agileorbit-cookbooks/java/pull/168)** - Add option to put JAVA_HOME in /etc/environment
- **[#172](https://github.com/agileorbit-cookbooks/java/pull/172)** - Allow ark to pull from http and files ending in .gz.
### Documentation
- Recommendations for inclusion in community cookbooks
- Production Deployment with Oracle Java
- Update testing instructions for chefdk
- Various Readme formatting.
### Misc
- Use Supermarket endpoint in berksfile
- rspec cleanup
- Adding ubuntu-14.04 to test suite
v1.24.0 - 7/25/2014
-------
New Cookbook maintainer! **[Agile Orbit](http://agileorbit.com)**
### Improvement
- **[#192](https://github.com/agileorbit-cookbooks/java/pull/192)** - Bump JDK7 URLs to 7u65
- **[#191](https://github.com/agileorbit-cookbooks/java/pull/192)** - Upgrade Oracle's Java 8 to u11
- **[#188](https://github.com/agileorbit-cookbooks/java/pull/188)** - Allow for alternatives priority to be set from attribute.
- **[#176](https://github.com/agileorbit-cookbooks/java/pull/176)** - Change ownership of extracted files
- **[#169](https://github.com/agileorbit-cookbooks/java/pull/169)** - Add retries and retry_delay parameters to java_ark LWRP
- **[#167](https://github.com/agileorbit-cookbooks/java/pull/167)** - default: don't fail when using java 8 on windows
- **[#165](https://github.com/agileorbit-cookbooks/java/pull/165)** - Support for Server JRE
- **[#158](https://github.com/agileorbit-cookbooks/java/pull/158)** - Updated README for accepting oracle terms
- **[#157](https://github.com/agileorbit-cookbooks/java/pull/157)** -Remove VirtualBox specific box_urls
- List AgileOrbit as the maintainer (AgileOrbit took over from Socrata in July 2014)
v1.23.0 - 7/25/2014
-------
- Tagged but never published to community cookbooks. All changes rolled into 1.24.0
v1.22.0
-------
### Improvement
- **[#148](https://github.com/socrata-cookbooks/java/pull/148)** - Add support for Oracle JDK 1.8.0
- **[#150](https://github.com/socrata-cookbooks/java/pull/150)** - Make use of Chef's cache directory instead of /tmp
- **[#151](https://github.com/socrata-cookbooks/java/pull/151)** - Update Test Kitchen suites
- **[#154](https://github.com/socrata-cookbooks/java/pull/154)** - Add safety check for JDK 8 on non-Oracle
v1.21.2
-------
### Bug
- **[#146](https://github.com/socrata-cookbooks/java/pull/146)** - Update Oracle accept-license-terms cookie format
v1.21.0
-------
### Improvement
- **[#143](https://github.com/socrata-cookbooks/java/pull/143)** - Symlink /usr/lib/jvm/default-java for both OpenJDK and Oracle
- **[#144](https://github.com/socrata-cookbooks/java/pull/144)** - Remove /var/lib/alternatives/#{cmd} before calling alternatives (Hopefully fixes sporadic issues when setting alternatives)
- **[Make default_java_symlink conditional on set_default attribute](https://github.com/socrata-cookbooks/java/commit/e300e235a463382a5022e1dddaac674930b4d138)**
v1.20.0
-------
### Improvement
- **[#137](https://github.com/socrata-cookbooks/java/pull/137)** - Create /usr/lib/jvm/default-java on Debian
- **[#138](https://github.com/socrata-cookbooks/java/pull/138)** - allow wrapping cookbook without providing templates
- **[#140](https://github.com/socrata-cookbooks/java/pull/140)** - Adds set_default attribute to toggle setting JDK as default
### Bug
- **[#141](https://github.com/socrata-cookbooks/java/pull/141)** - set java_home correctly for oracle_rpm
v1.19.2
-------
### Improvement
- **[#129](https://github.com/socrata-cookbooks/java/pull/129)** - Upgrade to ChefSpec 3
- Rewrite unit tests for better coverage and to work with ChefSpec 3 (various commits)
- List Socrata as the maintainer (Socrata took over from Opscode in December 2013)
### Bug
- **[#133](https://github.com/socrata-cookbooks/java/pull/133)** - Allow jdk_version to be a string or number
- **[#131](https://github.com/socrata-cookbooks/java/pull/131)** - Fix JDK install on Windows
- **[Fix openjdk_packages on Arch Linux](https://github.com/socrata-cookbooks/java/commit/677bee7b9bf08988596d40ac65e75984a86bda99)**
v1.19.0
-------
Refactor the cookbook to better support wrapper cookbooks and other cookbook authoring patterns.
### Improvement
- **[#123](https://github.com/socrata-cookbooks/java/pull/123)** - Update documentation & add warning for issue 122
- **[#124](https://github.com/socrata-cookbooks/java/pull/124)** - Refactor default recipe to better enable wrapper cookbooks
- **[#125](https://github.com/socrata-cookbooks/java/pull/125)** - Removes the attribute to purge deprecated packages
- **[#127](https://github.com/socrata-cookbooks/java/pull/127)** - Add safety check if attributes are unset
- **[Adds tests for directly using openjdk and oracle recipes](https://github.com/socrata-cookbooks/java/commit/794df596959d65a1a6d5f6c52688bffd8de6bff4)**
- **[Adds recipes to README](https://github.com/socrata-cookbooks/java/commit/76d52114bb9df084174d43fed143123b1cdbae16)**
- **[The Opscode CCLA is no longer required](https://github.com/socrata-cookbooks/java/commit/ce4ac25caa8383f185c25c4e32cafef8c0453376)**
- **[Adds tests for openjdk-7 and oracle-7](https://github.com/socrata-cookbooks/java/commit/9c38af241f68b3198cde4ad6fe2b4cb752062009)**
### Bug
- **[#119](https://github.com/socrata-cookbooks/java/pull/119)** - Use java_home instead of java_location for update-alternatives
- **[Fix java_home for rhel and fedora](https://github.com/socrata-cookbooks/java/commit/71dadbd1bfe2eab50ff21cdab4ded97877911cc4)**
v1.18.0
-------
### Improvement
- **[#118](https://github.com/socrata-cookbooks/java/pull/118)** - Upgrade to 7u51
- **[#117](https://github.com/socrata-cookbooks/java/pull/117)** - Suggest windows and aws
v1.17.6
-------
### Bug
- Revert **[COOK-4165](https://tickets.opscode.com/browse/COOK-4165)** - The headers option was only added to remote_file in Chef 11.6.0, meaning this change breaks older clients.
v1.17.4
-------
### Bug
- **[#111](https://github.com/socrata-cookbooks/java/pull/111)** - Fix alternatives for centos
### Improvement
- **[COOK-4165](https://tickets.opscode.com/browse/COOK-4165)** - Replace curl with remote_file with cookie header
- **[#110](https://github.com/socrata-cookbooks/java/pull/110)** - Update openjdk to use the alternatives resource
v1.17.2
-------
### Bug
- **[COOK-4136](https://tickets.opscode.com/browse/COOK-4136)** - Add md5 parameter to java_ark resource
v1.17.0
-------
- **[COOK-4114](https://tickets.opscode.com/browse/COOK-4114)** - Test Kitchen no longer works after merging Pull Request #95 for openjdk tests on Debian/Ubuntu
- **[COOK-4124](https://tickets.opscode.com/browse/COOK-4124)** - update-alternatives fails to run
- **[#81](https://github.com/socrata/java/pull/81)** - Ensure local directory hierarchy
- **[#97](https://github.com/socrata/java/pull/97)** - Expose LWRP state attributes
- **[#99](https://github.com/socrata/java/pull/99)** - support for MD5 checksum
- **[#106](https://github.com/socrata/java/pull/106)** - Fixed windows case to prevent bad java_home variable setting
- **[Update checksums to the officially-published ones from Oracle](https://github.com/socrata/java/commit/b9e1df24caeb6e22346d2d415b3b4384f15d4ffd)**
- **[Further test kitchen fixes to use the default recipe](https://github.com/socrata/java/commit/01c0b432705d9cfa6d2dfeaa380983e3f604069f)**
v1.16.4
-------
### Bug
- **[#103](https://github.com/socrata/java/pull/103)** - set alternatives when using ibm_tar recipe
- **[#104](https://github.com/socrata/java/pull/104)** - Specify windows attributes in attribute files
v1.16.2
-------
### Improvement
- **[COOK-3488](https://tickets.opscode.com/browse/COOK-3488)** - set alternatives for ibm jdk
- **[COOK-3764](https://tickets.opscode.com/browse/COOK-3764)** - IBM Java installer needs 'rpm' package on Ubuntu
### Bug
- **[COOK-3857](https://tickets.opscode.com/browse/COOK-3857)** - do not unescape the java windows url before parsing it
- **[#95](https://github.com/socrata/java/pull/95)** - fixes update-alternatives for openjdk installs
- **[#100](https://github.com/socrata/java/pull/100)** - Use escaped quotes for Windows INSTALLDIR
v1.16.0
-------
### Improvement
- **[COOK-3823](https://tickets.opscode.com/browse/COOK-3823)** - Upgrade to JDK 7u45-b18
v1.15.4
-------
[COOK-4210] - remove unneeded run_command to prevent zombie processes
v1.15.2
-------
[CHEF-4210] remove unneeded run_command to prevent zombie processes
v1.15.0
-------
### Bug
- Fixing version number. Accidently released at 0.15.x instead of 1.15.x
v0.15.2
-------
### FIX
- [COOK-3908] - Fixing JAVA_HOME on Ubuntu 10.04
v1.14.0
-------
### Bug
- **[COOK-3704](https://tickets.opscode.com/browse/COOK-3704)** - Fix alternatives when the package is already installed
- **[COOK-3668](https://tickets.opscode.com/browse/COOK-3668)** - Fix a condition that would result in an error executing action `run` on resource 'bash[update-java-alternatives]'
- **[COOK-3569](https://tickets.opscode.com/browse/COOK-3569)** - Fix bad checksum length
- **[COOK-3541](https://tickets.opscode.com/browse/COOK-3541)** - Fix an issue where Java cookbook installs both JDK 6 and JDK 7 when JDK 7 is specified
- **[COOK-3518](https://tickets.opscode.com/browse/COOK-3518)** - Allow Windoes recipe to download from signed S3 url
- **[COOK-2996](https://tickets.opscode.com/browse/COOK-2996)** - Fix a failure on Centos 6.4 and Oracle JDK 7
### Improvement
- **[COOK-2793](https://tickets.opscode.com/browse/COOK-2793)** - Improve Windows support
v1.13.0
-------
### Bug
- **[COOK-3295](https://tickets.opscode.com/browse/COOK-3295)** - Add default `platform_family` option in Java helper
- **[COOK-3277](https://tickets.opscode.com/browse/COOK-3277)** - Fix support for Fedora
### Improvement
- **[COOK-3278](https://tickets.opscode.com/browse/COOK-3278)** - Upgrade to Oracle Java 7u25
- **[COOK-3029](https://tickets.opscode.com/browse/COOK-3029)** - Add Oracle RPM support
- **[COOK-2931](https://tickets.opscode.com/browse/COOK-2931)** - Add support for the platform `xenserver`
- **[COOK-2154](https://tickets.opscode.com/browse/COOK-2154)** - Add SmartOS support
v1.12.0
-------
### Improvement
- [COOK-2154]: Add SmartOS support to java::openjdk recipe
- [COOK-3278]: upgrade to Oracle Java 7u25
### Bug
- [COOK-2931]: Adding support for the platform 'xenserver' (for installations of java in DOM0)
- [COOK-3277]: java cookbook fails on Fedora
v1.11.6
-------
### Bug
- [COOK-2847]: Java cookbook does not have opensuse support
- [COOK-3142]: Syntax Errors spec/default_spec.rb:4-8
v1.11.4
-------
### Bug
- [COOK-2989]: `bash[update-java-alternatives]` resource uses wrong attribute
v1.11.2
-------
### Bug
- Use SHA256 checksums for Oracle downloads, not SHA1.
v1.11.0
-------
This version brings a wealth of tests and (backwards-compatible) refactoring, plus some new features (updated Java, IBM recipe).
### Sub-task
- [COOK-2897]: Add ibm recipe to java cookbook
- [COOK-2903]: move java_home resources to their own recipe
- [COOK-2904]: refactor ruby_block "update-java-alternatives"
- [COOK-2905]: use platform_family in java cookbook
- [COOK-2920]: add chefspec to java cookbook
### Task
- [COOK-2902]: Refactor java cookbook
### Improvement
- [COOK-2900]: update JDK to JDK 7u21, 6u45
v1.10.2
-------
- [COOK-2415] - Fixed deprecation warnings in ark provider and openjdk recipe by using Chef::Mixin::ShellOut instead of Chef::ShellOut
v1.10.0
-------
- [COOK-2400] - Allow java ark :url to be https
- [COOK-2436] - Upgrade needed for oracle jdk in java cookbook
v1.9.6
------
- [COOK-2412] - add support for Oracle Linux
v1.9.4
------
- [COOK-2083] - Run set-env-java-home in Java cookbook only if necessary
- [COOK-2332] - ark provider does not allow for *.tgz tarballs to be used
- [COOK-2345] - Java cookbook fails on CentOS6 (update-java-alternatives)
v1.9.2
------
- [COOK-2306] - FoodCritic fixes for java cookbook
v1.9.0
------
- [COOK-2236] - Update the Oracle Java version in the Java cookbook to release 1.7u11
v1.8.2
------
- [COOK-2205] - Fix for missing /usr/lib/jvm/default-java on Debian
v1.8.0
------
- [COOK-2095] - Add windows support
v1.7.0
------
- [COOK-2001] - improvements for Oracle update-alternatives
- When installing an Oracle JDK it is now registered with a higher
priority than OpenJDK. (Related to COOK-1131.)
- When running both the oracle and oracle_i386 recipes, alternatives
are now created for both JDKs.
- Alternatives are now created for all binaries listed in version
specific attributes. (Related to COOK-1563 and COOK-1635.)
- When installing Oracke JDKs on Ubuntu, create .jinfo files for use
with update-java-alternatives. Commands to set/install
alternatives now only run if needed.
v1.6.4
------
- [COOK-1930] - fixed typo in attribute for java 5 on i586
v1.6.2
------
- whyrun support in `java_ark` LWRP
- CHEF-1804 compatibility
- [COOK-1786]- install Java 6u37 and Java 7u9
- [COOK-1819] -incorrect warning text about `node['java']['oracle']['accept_oracle_download_terms']`
v1.6.0
------
- [COOK-1218] - Install Oracle JDK from Oracle download directly
- [COOK-1631] - set JAVA_HOME in openjdk recipe
- [COOK-1655] - Install correct architecture on Amazon Linux
v1.5.4
------
- [COOK-885] - update alternatives called on wrong file
- [COOK-1607] - use shellout instead of execute resource to update alternatives
v1.5.2
------
- [COOK-1200] - remove sun-java6-jre on Ubuntu before installing Oracle's Java
- [COOK-1260] - fails on Ubuntu 12.04 64bit with openjdk7
- [COOK-1265] - Oracle Java should symlink the jar command
v1.5.0
------
- [COOK-1146] - Oracle now prevents download of JDK via non-browser
- [COOK-1114] - fix File.exists?
v1.4.2
------
- [COOK-1051] - fix attributes typo and platform case switch consistency
v1.4.0
------
- [COOK-858] - numerous updates: handle jdk6 and 7, switch from sun to oracle, make openjdk default, add `java_ark` LWRP.
- [COOK-942] - FreeBSD support
- [COOK-520] - ArchLinux support

View File

@ -0,0 +1,12 @@
Contributing
============
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. [**Add tests!**](https://github.com/agileorbit-cookbooks/java/blob/master/TESTING.md)
5. Push to the branch (`git push origin my-new-feature`)
6. Create new Pull Request
As this cookbook is no longer maintained by Chef, you **do not** need to sign any sort of contributor agreement. Simply make your change and open a pull request.
Contributions will only be accepted if they are fully tested as specified in [TESTING.md](https://github.com/agileorbit-cookbooks/java/blob/master/TESTING.md)

View File

@ -0,0 +1,11 @@
source 'https://rubygems.org'
gem 'berkshelf', '~> 2.0'
gem 'chefspec', '~> 3.1'
gem 'foodcritic', '~> 3.0'
gem 'rubocop', '~> 0.12'
group :integration do
gem 'test-kitchen', '~> 1.2.1'
gem 'kitchen-vagrant', '~> 0.14.0'
end

201
chef/cookbooks/java/LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@ -0,0 +1,393 @@
java
=====
This cookbook installs a Java JDK/JRE. It defaults to installing
OpenJDK, but it can also install Oracle and IBM JDKs.
Usage
-----
Simply include the `java` recipe wherever you would like Java installed, such as a run list (`recipe[java]`) or a cookbook (`include_recipe 'java'`). By default, OpenJDK 6 is installed. The `install_flavor` attribute is used to determine which JDK to install (OpenJDK, Oracle, IBM, or Windows), and `jdk_version` specifies which version to install (currently 6 and 7 are supported for all JDK types, 8 for Oracle only).
### Examples
To install Oracle Java 7 (note that when installing Oracle JDK, `accept_oracle_download_terms` must be set -- see below for details):
```ruby
name "java"
description "Install Oracle Java"
default_attributes(
"java" => {
"install_flavor" => "oracle",
"jdk_version" => "7",
"oracle" => {
"accept_oracle_download_terms" => true
}
}
)
run_list(
"recipe[java]"
)
```
To install IBM flavored Java:
```ruby
name "java"
description "Install IBM Java on Ubuntu"
default_attributes(
"java" => {
"install_flavor" => "ibm",
"ibm" => {
"accept_ibm_download_terms" => true,
"url" => "http://fileserver.example.com/ibm-java-x86_64-sdk-7.0-4.1.bin",
"checksum" => "The SHA256 checksum of the bin"
}
}
)
run_list(
"recipe[java]"
)
```
Requirements
-----
Chef 0.10.10+ and Ohai 6.10+ for `platform_family` use.
### Platform
* Debian, Ubuntu
* CentOS, Red Hat, Fedora, Scientific, Amazon, XenServer
* ArchLinux
* FreeBSD
* SmartOS
* Windows
Attributes
-----
See `attributes/default.rb` for default values.
* `node['java']['install_flavor']` - Flavor of JVM you would like
installed (`oracle`, `oracle_rpm`, `openjdk`, `ibm`, `windows`), default `openjdk`
on Linux/Unix platforms, `windows` on Windows platforms.
* `node['java']['jdk_version']` - JDK version to install, defaults to
`'6'`.
* `node['java']['java_home']` - Default location of the
"`$JAVA_HOME`".
* `node['java']['set_etc_environment']` - Optionally sets
JAVA_HOME in `/etc/environment` for Default `false`.
* `node['java']['openjdk_packages']` - Array of OpenJDK package names
to install in the `java::openjdk` recipe. This is set based on the
platform.
* `node['java']['tarball']` - Name of the tarball to retrieve from
your internal repository, default `jdk1.6.0_29_i386.tar.gz`
* `node['java']['tarball_checksum']` - Checksum for the tarball, if
you use a different tarball, you also need to create a new sha256
checksum
* `node['java']['jdk']` - Version and architecture specific attributes
for setting the URL on Oracle's site for the JDK, and the checksum of
the .tar.gz.
* `node['java']['oracle']['accept_oracle_download_terms']` - Indicates
that you accept Oracle's EULA
* `node['java']['windows']['url']` - The internal location of your
java install for windows
* `node['java']['windows']['package_name']` - The package name used by
windows_package to check in the registry to determine if the install
has already been run
* `node['java']['windows']['checksum']` - The checksum for the package to
download on Windows machines (default is nil, which does not perform
checksum validation)
* `node['java']['ibm']['url']` - The URL which to download the IBM
JDK/SDK. See the `ibm` recipe section below.
* `node['java']['ibm']['accept_ibm_download_terms']` - Indicates that
you accept IBM's EULA (for `java::ibm`)
* `node['java']['oracle_rpm']['type']` - Type of java RPM (`jre` or `jdk`), default `jdk`
* `node['java']['oracle_rpm']['package_version']` - optional, can be set
to pin a version different from the up-to-date one available in the YUM repo,
it might be needed to also override the node['java']['java_home'] attribute
to a value consistent with the defined version
* `node['java']['oracle_rpm']['package_name']` - optional, can be set
to define a package name different from the RPM published by Oracle.
* `node['java']['accept_license_agreement']` - Indicates that you accept
the EULA for openjdk package installation.
* `node['java']['set_default']` - Indicates whether or not you want the
JDK installed to be default on the system. Defaults to true.
Recipes
-----
### default
Include the default recipe in a run list or recipe to get `java`. By default
the `openjdk` flavor of Java is installed, but this can be changed by
using the `install_flavor` attribute. By default on Windows platform
systems, the `install_flavor` is `windows`.
OpenJDK is the default because of licensing changes made upstream by
Oracle. See notes on the `oracle` recipe below.
NOTE: In most cases, including just the default recipe will be sufficient.
It's possible to include the install_type recipes directly, as long as
the necessary attributes (such as java_home) are set.
### set_attributes_from_version
Sets default attributes based on the JDK version. This is included by `default.rb`. This logic must be in
a recipe instead of attributes/default.rb. See [#95](https://github.com/agileorbit-cookbooks/java/pull/95)
for details.
### default_java_symlink
Updates /usr/lib/jvm/default-java to point to JAVA_HOME.
### purge_packages
Purges deprecated Sun Java packages.
### openjdk
This recipe installs the `openjdk` flavor of Java. It also uses the
`alternatives` system on RHEL/Debian families to set the default Java.
On platforms such as SmartOS that require the acceptance of a license
agreement during package installation, set
`node['java']['accept_license_agreement']` to true in order to indicate
that you accept the license.
### oracle
This recipe installs the `oracle` flavor of Java. This recipe does not
use distribution packages as Oracle changed the licensing terms with
JDK 1.6u27 and prohibited the practice for both RHEL and Debian family
platforms.
As of 26 March 2012 you can no longer directly download the JDK from
Oracle's website without using a special cookie. This cookbook uses
that cookie to download the oracle recipe on your behalf, however the
`java::oracle` recipe forces you to set either override the
`node['java']['oracle']['accept_oracle_download_terms']` to true or
set up a private repository accessible by HTTP.
override the `accept_oracle_download_terms` in, e.g., `roles/base.rb`
```ruby
default_attributes(
:java => {
:oracle => {
"accept_oracle_download_terms" => true
}
}
)
```
For both RHEL and Debian families, this recipe pulls the binary
distribution from the Oracle website, and installs it in the default
`JAVA_HOME` for each distribution. For Debian, this is
`/usr/lib/jvm/default-java`. For RHEl, this is `/usr/lib/jvm/java`.
After putting the binaries in place, the `java::oracle` recipe updates
`/usr/bin/java` to point to the installed JDK using the
`update-alternatives` script. This is all handled in the `java_ark`
LWRP.
### oracle_i386
This recipe installs the 32-bit Java virtual machine without setting
it as the default. This can be useful if you have applications on the
same machine that require different versions of the JVM.
This recipe operates in a similar manner to `java::oracle`.
### oracle_rpm
This recipe installs the Oracle JRE or JDK provided by a custom YUM
repositories.
It also uses the `alternatives` system on RHEL families to set
the default Java.
### windows
Because there is no easy way to pull the java msi off oracle's site,
this recipe requires you to host it internally on your own http repo.
**IMPORTANT NOTE**
If you use the `windows` recipe, you'll need to make sure you've uploaded
the `aws` and `windows` cookbooks. As of version 1.18.0, this cookbook
references them with `suggests` instead of `depends`, as they are only
used by the `windows` recipe.
### ibm
The `java::ibm` recipe is used to install the IBM version of Java.
Note that IBM requires you to create an account *and* log in to
download the binary installer for your platform. You must accept the
license agreement with IBM to use their version of Java. In this
cookbook, you indicate this by setting
`node['java']['ibm']['accept_ibm_download_terms']` to `true`. You must
also host the binary on your own HTTP server to have an automated
installation. The `node['java']['ibm']['url']` attribute must be set
to a valid https/http URL; the URL is checked for validity in the recipe.
At this time the `java::ibm` recipe does not support multiple SDK
installations.
Resources/Providers
-----
### java_ark
This cookbook contains the `java_ark` LWRP. Generally speaking this
LWRP is deprecated in favor of `ark` from the
[ark cookbook](https://github.com/opscode-cookbooks/ark), but it is
still used in this cookbook for handling the Oracle JDK installation.
By default, the extracted directory is extracted to
`app_root/extracted_dir_name` and symlinked to `app_root/default`
#### Actions
- `:install`: extracts the tarball and makes necessary symlinks
- `:remove`: removes the tarball and run update-alternatives for all
symlinked `bin_cmds`
#### Attribute Parameters
- `url`: path to tarball, .tar.gz, .bin (oracle-specific), and .zip
currently supported
- `checksum`: SHA256 checksum, not used for security but avoid
redownloading the archive on each chef-client run
- `app_home`: the default for installations of this type of
application, for example, `/usr/lib/tomcat/default`. If your
application is not set to the default, it will be placed at the same
level in the directory hierarchy but the directory name will be
`app_root/extracted_directory_name + "_alt"`
- `app_home_mode`: file mode for app_home, is an integer
- `bin_cmds`: array of binary commands that should be symlinked to
`/usr/bin`, examples are mvn, java, javac, etc. These cmds must be in
the `bin` subdirectory of the extracted folder. Will be ignored if this
`java_ark` is not the default
- `owner`: owner of extracted directory, set to "root" by default
- `group`: group of extracted directory, set to `:owner` by default
- `default`: whether this the default installation of this package,
boolean true or false
#### Examples
```ruby
# install jdk6 from Oracle
java_ark "jdk" do
url 'http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-x64.bin'
checksum 'a8603fa62045ce2164b26f7c04859cd548ffe0e33bfc979d9fa73df42e3b3365'
app_home '/usr/local/java/default'
bin_cmds ["java", "javac"]
action :install
end
```
### java_alternatives
The `java_alternatives` LWRP uses `update-alternatives` command
to set and unset command alternatives for various Java tools
such as java, javac, etc.
#### Actions
- `:set`: set alternatives for Java tools
- `:unset`: unset alternatives for Java tools
#### Attribute Parameters
- `java_location`: Java installation location.
- `bin_cmds`: array of Java tool names to set or unset alternatives on.
- `default`: whether to set the Java tools as system default. Boolean, defaults to `true`.
- `priority`: priority of the alternatives. Integer, defaults to `1061`.
#### Examples
```ruby
# set alternatives for java and javac commands
java_alternatives "set java alternatives" do
java_location '/usr/local/java'
bin_cmds ["java", "javac"]
action :set
end
```
Production Deployment with Oracle Java
-----
Oracle has been known to change the behavior of its download site frequently. It is recommended you store the archives on an artifact server or s3 bucket. You can then override the attributes in a cookbook, role, or environment:
```ruby
default['java']['jdk_version'] = '7'
default['java']['install_flavor'] = 'oracle'
default['java']['jdk']['7']['x86_64']['url'] = 'http://artifactory.example.com/artifacts/jdk-7u65-linux-x64.tar.gz'
default['java']['oracle']['accept_oracle_download_terms'] = true
```
Recommendations for inclusion in community cookbooks
-----
This cookbook is a dependency for many other cookbooks in the Java/Chef sphere. Here are some guidelines for including it into other cookbooks:
### Allow people to not use this cookbook
Many users manage Java on their own or have systems that already have java installed. Give these users an option to skip this cookbook, for example:
```ruby
include_recipe 'java' if node['maven']['install_java']
```
This would allow a users of the maven cookbook to choose if they want the maven cookbook to install java for them or leave that up to the consumer.
Another good example is from the [Jenkins Cookbook Java recipe](https://github.com/opscode-cookbooks/jenkins/commit/ca2a69d982011dc1bec6a6d0ee4da5c1a1599864).
### Pinning to major version of cookbook and Java
This cookbook follows semver. It is recommended to pin at the major version of this cookbook when including it in other cookbooks, eg: `depends 'java', '~> 1.0'`
It is acceptable to set the `node['java']['jdk_version']` to a specific version if required for your software to run, eg software xyz requires Java 8 to run. Refrain from pinning to specific patches of the JDK to allow users to consume security updates.
Development
-----
This cookbook uses
[test-kitchen](https://github.com/opscode/test-kitchen) for
integration tests and
[ChefSpec/RSpec](https://github.com/sethvargo/chefspec) for unit tests.
See [TESTING.md](https://github.com/agileorbit-cookbooks/java/blob/master/TESTING.md) for testing instructions.
At this time due to licensing concerns, the IBM recipe is not set up
in test kitchen. If you would like to test this locally, copy
.kitchen.yml to .kitchen.local.yml and add the following suite:
```yml
suites:
- name: ibm
run_list: ["recipe[java]"]
attributes:
java:
install_flavor: "ibm"
ibm:
accept_ibm_download_terms: true
url: "http://jenkins/ibm-java-x86_64-sdk-7.0-4.1.bin"
checksum: the-sha256-checksum
```
Log into the IBM DeveloperWorks site to download a copy of the IBM
Java SDK you wish to use/test, host it on an internal HTTP server, and
calculate the SHA256 checksum to use in the suite.
License and Author
-----
* Author: Seth Chisamore (<schisamo@opscode.com>)
* Author: Bryan W. Berry (<bryan.berry@gmail.com>)
* Author: Joshua Timberman (<joshua@opscode.com>)
* Author: Eric Helgeson (<erichelgeson@gmail.com>)
Copyright: 2014, Agile Orbit, LLC
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.

View File

@ -0,0 +1,41 @@
Testing the java cookbook
=====
This cookbook includes both unit tests via [ChefSpec](https://github.com/sethvargo/chefspec) and integration tests via [Test Kitchen](https://github.com/test-kitchen/test-kitchen). Contributions to this cookbook will only be accepted if all tests pass successfully:
```bash
kitchen test
chef exec rspec
```
Setting up the test environment
-----
Install the latest version of [Vagrant](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (free) or [VMWare Fusion](http://www.vmware.com/products/fusion) (paid).
The Chef tooling (chefspec/test kitchen/etc) is managed by the [Chef Development Kit](http://downloads.getchef.com/chef-dk/) - Version 0.2.0-2.
Clone the latest version of the cookbook from the repository.
```bash
git clone git@github.com:agileorbit-cookbooks/java.git
cd java
```
Running ChefSpec
-----
ChefSpec unit tests are located in `spec`. Each recipe has a `recipename_spec.rb` file that contains unit tests for that recipe. Your new functionality or bug fix should have corresponding test coverage - if it's a change, make sure it doesn't introduce a regression (existing tests should pass). If it's a change or introduction of new functionality, add new tests as appropriate.
To run ChefSpec for the whole cookbook:
`chef exec rspec`
To run ChefSpec for a specific recipe:
`chef exec rspec spec/set_java_home_spec.rb`
Running Test Kitchen
-----
Test Kitchen test suites are defined in [.kitchen.yml](https://github.com/agileorbit-cookbooks/java/blob/master/.kitchen.yml). Running `kitchen test` will cause Test Kitchen to spin up each platform VM in turn, running the `java::default` recipe with differing parameters in order to test all possible combinations of platform, install_flavor, and JDK version. If the Chef run completes successfully, corresponding tests in `test/integration` are executed. These must also pass.

View File

@ -0,0 +1,131 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: java
# Attributes:: default
#
# Copyright 2010, Opscode, 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.
# default jdk attributes
default['java']['jdk_version'] = '6'
default['java']['arch'] = kernel['machine'] =~ /x86_64/ ? "x86_64" : "i586"
default['java']['openjdk_packages'] = []
default['java']['openjdk_version'] = nil
default['java']['accept_license_agreement'] = false
default['java']['set_default'] = true
default['java']['alternatives_priority'] = 1062
default['java']['set_etc_environment'] = false
# the following retry parameters apply when downloading oracle java
default['java']['ark_retries'] = 0
default['java']['ark_retry_delay'] = 2
case node['platform_family']
when "windows"
default['java']['install_flavor'] = "windows"
default['java']['windows']['url'] = nil
default['java']['windows']['checksum'] = nil
default['java']['windows']['package_name'] = "Java(TM) SE Development Kit 7 (64-bit)"
else
default['java']['install_flavor'] = "openjdk"
end
case node['java']['install_flavor']
when 'ibm', 'ibm_tar'
default['java']['ibm']['url'] = nil
default['java']['ibm']['checksum'] = nil
default['java']['ibm']['accept_ibm_download_terms'] = false
default['java']['java_home'] = "/opt/ibm/java"
default['java']['ibm']['6']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "HtmlConverter", "idlj", "jar", "jarsigner",
"java", "javac", "javadoc", "javah", "javap", "javaws", "jconsole", "jcontrol", "jdb", "jdmpview",
"jrunscript", "keytool", "native2ascii", "policytool", "rmic", "rmid", "rmiregistry",
"schemagen", "serialver", "tnameserv", "wsgen", "wsimport", "xjc" ]
default['java']['ibm']['7']['bin_cmds'] = node['java']['ibm']['6']['bin_cmds'] + [ "pack200", "unpack200" ]
when 'oracle_rpm'
# type of java RPM : jdk or jre
default['java']['oracle_rpm']['type'] = 'jdk'
# optional, can be overriden to pin to a version different
# from the up-to-date.
default['java']['oracle_rpm']['package_version'] = nil
# optional, some distros re-package the official Oracle's RPM
# with a different name
default['java']['oracle_rpm']['package_name'] = nil
# set the JAVA_HOME path, it may be overriden
# when a package version is provided.
default['java']['java_home'] = "/usr/java/latest"
end
# if you change this to true, you can download directly from Oracle
default['java']['oracle']['accept_oracle_download_terms'] = false
# direct download paths for oracle, you have been warned!
# jdk6 attributes
default['java']['jdk']['6']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "HtmlConverter", "idlj", "jar", "jarsigner",
"java", "javac", "javadoc", "javah", "javap", "javaws", "jconsole", "jcontrol", "jdb", "jhat",
"jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
"keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
"schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc"]
# x86_64
default['java']['jdk']['6']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin'
default['java']['jdk']['6']['x86_64']['checksum'] = '6b493aeab16c940cae9e3d07ad2a5c5684fb49cf06c5d44c400c7993db0d12e8'
# i586
default['java']['jdk']['6']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/6u45-b06/jdk-6u45-linux-i586.bin'
default['java']['jdk']['6']['i586']['checksum'] = 'd53b5a2518d80e1d95565f0adda54eee229dc5f4a1d1a3c2f7bf5045b168a357'
# jdk7 attributes
default['java']['jdk']['7']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac",
"javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb",
"jhat", "jinfo", "jmap", "jps", "jrunscript", "jsadebugd", "jstack", "jstat", "jstatd", "jvisualvm",
"keytool", "native2ascii", "orbd", "pack200", "policytool", "rmic", "rmid", "rmiregistry",
"schemagen", "serialver", "servertool", "tnameserv", "unpack200", "wsgen", "wsimport", "xjc"]
# Oracle doesn't seem to publish SHA256 checksums for Java releases, so we use MD5 instead.
# Official checksums for the latest release can be found at http://www.oracle.com/technetwork/java/javase/downloads/java-se-binaries-checksum-1956892.html
# x86_64
default['java']['jdk']['7']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.tar.gz'
default['java']['jdk']['7']['x86_64']['checksum'] = '81e3e2df33e13781e5fac5756ed90e67'
# i586
default['java']['jdk']['7']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-i586.tar.gz'
default['java']['jdk']['7']['i586']['checksum'] = '715b0e8ba2a06bded75f6a92427e2701'
# jdk8 attributes
default['java']['jdk']['8']['bin_cmds'] = [ "appletviewer", "apt", "ControlPanel", "extcheck", "idlj", "jar", "jarsigner", "java", "javac",
"javadoc", "javafxpackager", "javah", "javap", "javaws", "jcmd", "jconsole", "jcontrol", "jdb",
"jdeps", "jhat", "jinfo", "jjs", "jmap", "jmc", "jps", "jrunscript", "jsadebugd", "jstack",
"jstat", "jstatd", "jvisualvm", "keytool", "native2ascii", "orbd", "pack200", "policytool",
"rmic", "rmid", "rmiregistry", "schemagen", "serialver", "servertool", "tnameserv",
"unpack200", "wsgen", "wsimport", "xjc"]
# Oracle doesn't seem to publish SHA256 checksums for Java releases, so we use MD5 instead.
# Official checksums for the latest release can be found at http://www.oracle.com/technetwork/java/javase/downloads/javase8-binaries-checksum-2133161.html
# x86_64
default['java']['jdk']['8']['x86_64']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz'
default['java']['jdk']['8']['x86_64']['checksum'] = 'ec7f89dc3697b402e2c851d0488f6299'
# i586
default['java']['jdk']['8']['i586']['url'] = 'http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-i586.tar.gz'
default['java']['jdk']['8']['i586']['checksum'] = '5dafdef064e18468f21c65051a6918d7'

View File

@ -0,0 +1,120 @@
#
# Author:: Joshua Timberman <joshua@opscode.com>
# Copyright:: Copyright (c) 2013, Opscode, Inc. <legal@opscode.com>
#
# 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.
#
require 'chef/version_constraint'
require 'uri'
require 'pathname'
module Opscode
class OpenJDK
attr_accessor :java_home, :jdk_version
def initialize(node)
@node = node.to_hash
@java_home = @node['java']['java_home'] || '/usr/lib/jvm/default-java'
@jdk_version = @node['java']['jdk_version'].to_s || '6'
end
def java_location
File.join(java_home_parent(@java_home), openjdk_path, 'bin/java')
end
def alternatives_priority
if @jdk_version == '6'
# 'accepted' default for java 6
1061
elsif @jdk_version == '7'
# i just made this number up
1100
elsif @jdk_version.to_i > 7
# just a guard against the incoming java 8
# so this cookbook will actually work for.. new versions of java
1110
else
# it's not 6, it's not 7, it's not newer than
# 7, but we probably want to install it, so
# override 6's priority. arbitrary number.
1062
end
end
def java_home_parent(java_home)
Pathname.new(java_home).parent.to_s
end
def openjdk_path
case @node['platform_family']
when 'debian'
'java-%s-openjdk%s/jre' % [@jdk_version, arch_dir]
when 'rhel', 'fedora'
'jre-1.%s.0-openjdk%s' % [@jdk_version, arch_dir]
when 'smartos'
'jre'
else
'jre'
end
end
def arch_dir
@node['kernel']['machine'] == 'x86_64' ? sixty_four : thirty_two
end
def sixty_four
case @node['platform_family']
when 'debian'
old_version? ? '' : '-amd64'
when 'rhel', 'fedora'
'.x86_64'
else
'-x86_64'
end
end
def thirty_two
case @node['platform_family']
when 'debian'
old_version? ? '' : '-i386'
else
''
end
end
# This method is used above (#sixty_four, #thirty_two) so we know
# whether to specify the architecture as part of the path name.
def old_version?
case @node['platform']
when 'ubuntu'
Chef::VersionConstraint.new("< 11.0").include?(@node['platform_version'])
when 'debian'
Chef::VersionConstraint.new("< 7.0").include?(@node['platform_version'])
end
end
end
end
class Chef
class Recipe
def valid_ibm_jdk_uri?(url)
url =~ ::URI::ABS_URI && %w[file http https].include?(::URI.parse(url).scheme)
end
def platform_requires_license_acceptance?
%w(smartos).include?(node.platform)
end
end
end

View File

@ -0,0 +1,5 @@
if defined?(ChefSpec)
def set_java_alternatives(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:java_alternatives, :set, resource_name)
end
end

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
name "java"
maintainer "Agile Orbit"
maintainer_email "info@agileorbit.com"
license "Apache 2.0"
description "Installs Java runtime."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.28.0"
recipe "java::default", "Installs Java runtime"
recipe "java::default_java_symlink", "Updates /usr/lib/jvm/default-java"
recipe "java::ibm", "Installs the JDK for IBM"
recipe "java::ibm_tar", "Installs the JDK for IBM from a tarball"
recipe "java::openjdk", "Installs the OpenJDK flavor of Java"
recipe "java::oracle", "Installs the Oracle flavor of Java"
recipe "java::oracle_i386", "Installs the 32-bit jvm without setting it as the default"
recipe "java::oracle_rpm", "Installs the Oracle RPM flavor of Java"
recipe "java::purge_packages", "Purges old Sun JDK packages"
recipe "java::set_attributes_from_version", "Sets various attributes that depend on jdk_version"
recipe "java::set_java_home", "Sets the JAVA_HOME environment variable"
recipe "java::windows", "Installs the JDK on Windows"
%w{
debian
ubuntu
centos
redhat
scientific
fedora
amazon
arch
oracle
freebsd
windows
suse
xenserver
smartos
}.each do |os|
supports os
end
suggests "windows"
suggests "aws"

View File

@ -0,0 +1,79 @@
#
# Cookbook Name:: java
# Provider:: alternatives
#
# 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.
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
action :set do
if new_resource.bin_cmds
# I couldn't find a way to cleanly avoid repeating this variable declaration in both :set and :unset
alternatives_cmd = node['platform_family'] == 'rhel' ? 'alternatives' : 'update-alternatives'
new_resource.bin_cmds.each do |cmd|
bin_path = "/usr/bin/#{cmd}"
alt_path = "#{new_resource.java_location}/bin/#{cmd}"
priority = new_resource.priority
if !::File.exist?(alt_path)
Chef::Log.debug "Skipping setting alternative for #{cmd}. Command #{alt_path} does not exist."
next
end
# install the alternative if needed
alternative_exists = shell_out("#{alternatives_cmd} --display #{cmd} | grep #{alt_path}").exitstatus == 0
unless alternative_exists
description = "Add alternative for #{cmd}"
converge_by(description) do
Chef::Log.debug "Adding alternative for #{cmd}"
shell_out("rm /var/lib/alternatives/#{cmd}")
install_cmd = shell_out("#{alternatives_cmd} --install #{bin_path} #{cmd} #{alt_path} #{priority}")
unless install_cmd.exitstatus == 0
Chef::Application.fatal!(%Q[ set alternative failed ])
end
end
new_resource.updated_by_last_action(true)
end
# set the alternative if default
if new_resource.default
alternative_is_set = shell_out("#{alternatives_cmd} --display #{cmd} | grep \"link currently points to #{alt_path}\"").exitstatus == 0
unless alternative_is_set
description = "Set alternative for #{cmd}"
converge_by(description) do
Chef::Log.debug "Setting alternative for #{cmd}"
set_cmd = shell_out("#{alternatives_cmd} --set #{cmd} #{alt_path}")
unless set_cmd.exitstatus == 0
Chef::Application.fatal!(%Q[ set alternative failed ])
end
end
new_resource.updated_by_last_action(true)
end
end
end
end
end
action :unset do
# I couldn't find a way to cleanly avoid repeating this variable declaration in both :set and :unset
alternatives_cmd = node['platform_family'] == 'rhel' ? 'alternatives' : 'update-alternatives'
new_resource.bin_cmds.each do |cmd|
alt_path = "#{new_resource.java_location}/bin/#{cmd}"
cmd = shell_out("#{alternatives_cmd} --remove #{cmd} #{alt_path}")
if cmd.exitstatus == 0
new_resource.updated_by_last_action(true)
end
end
end

View File

@ -0,0 +1,251 @@
#
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
# Cookbook Name:: java
# Provider:: ark
#
# Copyright 2011, 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.
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
def whyrun_supported?
true
end
def parse_app_dir_name url
file_name = url.split('/')[-1]
# funky logic to parse oracle's non-standard naming convention
# for jdk1.6
if file_name =~ /^(jre|jdk|server-jre).*$/
major_num = file_name.scan(/\d/)[0]
update_token = file_name.scan(/u(\d+)/)[0]
update_num = update_token ? update_token[0] : "0"
# pad a single digit number with a zero
if update_num.length < 2
update_num = "0" + update_num
end
package_name = (file_name =~ /^server-jre.*$/) ? "jdk" : file_name.scan(/[a-z]+/)[0]
if update_num == "00"
app_dir_name = "#{package_name}1.#{major_num}.0"
else
app_dir_name = "#{package_name}1.#{major_num}.0_#{update_num}"
end
else
app_dir_name = file_name.split(/(.tgz|.tar.gz|.zip)/)[0]
app_dir_name = app_dir_name.split("-bin")[0]
end
[app_dir_name, file_name]
end
def oracle_downloaded?(download_path, new_resource)
if ::File.exists? download_path
require 'digest'
if new_resource.checksum =~ /^[0-9a-f]{32}$/
downloaded_md5 = Digest::MD5.file(download_path).hexdigest
downloaded_md5 == new_resource.checksum
else
downloaded_sha = Digest::SHA256.file(download_path).hexdigest
downloaded_sha == new_resource.checksum
end
else
return false
end
end
def download_direct_from_oracle(tarball_name, new_resource)
download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}"
cookie = "oraclelicense=accept-securebackup-cookie"
if node['java']['oracle']['accept_oracle_download_terms']
# install the curl package
p = package "curl" do
action :nothing
end
# no converge_by block since the package provider will take care of this run_action
p.run_action(:install)
description = "download oracle tarball straight from the server"
converge_by(description) do
Chef::Log.debug "downloading oracle tarball straight from the source"
cmd = shell_out!(
%Q[ curl --create-dirs -L --retry #{new_resource.retries} --retry-delay #{new_resource.retry_delay} --cookie "#{cookie}" #{new_resource.url} -o #{download_path} ]
)
end
else
Chef::Application.fatal!("You must set the attribute node['java']['oracle']['accept_oracle_download_terms'] to true if you want to download directly from the oracle site!")
end
end
action :install do
app_dir_name, tarball_name = parse_app_dir_name(new_resource.url)
app_root = new_resource.app_home.split('/')[0..-2].join('/')
app_dir = app_root + '/' + app_dir_name
if new_resource.group
app_group = new_resource.group
else
app_group = new_resource.owner
end
unless new_resource.default
Chef::Log.debug("processing alternate jdk")
app_dir = app_dir + "_alt"
app_home = new_resource.app_home + "_alt"
else
app_home = new_resource.app_home
end
unless ::File.exists?(app_dir)
Chef::Log.info "Adding #{new_resource.name} to #{app_dir}"
require 'fileutils'
unless ::File.exists?(app_root)
description = "create dir #{app_root} and change owner to #{new_resource.owner}:#{app_group}"
converge_by(description) do
FileUtils.mkdir app_root, :mode => new_resource.app_home_mode
FileUtils.chown new_resource.owner, app_group, app_root
end
end
if new_resource.url =~ /^http:\/\/download.oracle.com.*$/
download_path = "#{Chef::Config[:file_cache_path]}/#{tarball_name}"
if oracle_downloaded?(download_path, new_resource)
Chef::Log.debug("oracle tarball already downloaded, not downloading again")
else
download_direct_from_oracle tarball_name, new_resource
end
else
Chef::Log.debug("downloading tarball from an unofficial repository")
r = remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do
source new_resource.url
checksum new_resource.checksum
retries new_resource.retries
retry_delay new_resource.retry_delay
mode 0755
action :nothing
end
#no converge by on run_action remote_file takes care of it.
r.run_action(:create_if_missing)
end
description = "extract compressed data into Chef file cache path and
move extracted data to #{app_dir}"
converge_by(description) do
case tarball_name
when /^.*\.bin/
cmd = shell_out(
%Q[ cd "#{Chef::Config[:file_cache_path]}";
bash ./#{tarball_name} -noregister
] )
unless cmd.exitstatus == 0
Chef::Application.fatal!("Failed to extract file #{tarball_name}!")
end
when /^.*\.zip/
cmd = shell_out(
%Q[ unzip "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -d "#{Chef::Config[:file_cache_path]}" ]
)
unless cmd.exitstatus == 0
Chef::Application.fatal!("Failed to extract file #{tarball_name}!")
end
when /^.*\.(tar.gz|tgz)/
cmd = shell_out(
%Q[ tar xvzf "#{Chef::Config[:file_cache_path]}/#{tarball_name}" -C "#{Chef::Config[:file_cache_path]}" --no-same-owner]
)
unless cmd.exitstatus == 0
Chef::Application.fatal!("Failed to extract file #{tarball_name}!")
end
end
cmd = shell_out(
%Q[ mv "#{Chef::Config[:file_cache_path]}/#{app_dir_name}" "#{app_dir}" ]
)
unless cmd.exitstatus == 0
Chef::Application.fatal!(%Q[ Command \' mv "#{Chef::Config[:file_cache_path]}/#{app_dir_name}" "#{app_dir}" \' failed ])
end
# change ownership of extracted files
FileUtils.chown_R new_resource.owner, app_group, app_root
end
new_resource.updated_by_last_action(true)
end
#set up .jinfo file for update-java-alternatives
java_name = app_home.split('/')[-1]
jinfo_file = "#{app_root}/.#{java_name}.jinfo"
if platform_family?("debian") && !::File.exists?(jinfo_file)
description = "Add #{jinfo_file} for debian"
converge_by(description) do
Chef::Log.debug "Adding #{jinfo_file} for debian"
template jinfo_file do
cookbook "java"
source "oracle.jinfo.erb"
variables(
:priority => new_resource.alternatives_priority,
:bin_cmds => new_resource.bin_cmds,
:name => java_name,
:app_dir => app_home
)
action :create
end
end
new_resource.updated_by_last_action(true)
end
#link app_home to app_dir
Chef::Log.debug "app_home is #{app_home} and app_dir is #{app_dir}"
current_link = ::File.symlink?(app_home) ? ::File.readlink(app_home) : nil
if current_link != app_dir
description = "Symlink #{app_dir} to #{app_home}"
converge_by(description) do
Chef::Log.debug "Symlinking #{app_dir} to #{app_home}"
FileUtils.rm_f app_home
FileUtils.ln_sf app_dir, app_home
end
end
#update-alternatives
java_alternatives 'set-java-alternatives' do
java_location app_home
bin_cmds new_resource.bin_cmds
priority new_resource.alternatives_priority
default new_resource.default
action :set
end
end
action :remove do
app_dir_name, tarball_name = parse_app_dir_name(new_resource.url)
app_root = new_resource.app_home.split('/')[0..-2].join('/')
app_dir = app_root + '/' + app_dir_name
unless new_resource.default
Chef::Log.debug("processing alternate jdk")
app_dir = app_dir + "_alt"
app_home = new_resource.app_home + "_alt"
else
app_home = new_resource.app_home
end
if ::File.exists?(app_dir)
java_alternatives 'unset-java-alternatives' do
java_location app_home
bin_cmds new_resource.bin_cmds
action :unset
end
description = "remove #{new_resource.name} at #{app_dir}"
converge_by(description) do
Chef::Log.info "Removing #{new_resource.name} at #{app_dir}"
FileUtils.rm_rf app_dir
end
new_resource.updated_by_last_action(true)
end
end

View File

@ -0,0 +1,28 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Cookbook Name:: java
# Recipe:: default
#
# Copyright 2008-2011, Opscode, 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.
#
if node['java']['install_flavor'] != 'windows'
if node['java']['jdk_version'].to_i == 8 and node['java']['install_flavor'] != 'oracle'
Chef::Application.fatal!("JDK 8 is currently only provided with the Oracle JDK")
end
end
include_recipe "java::set_attributes_from_version"
include_recipe "java::#{node['java']['install_flavor']}"

View File

@ -0,0 +1,19 @@
# Cookbook Name:: java
# Recipe:: default_java_symlink
#
# 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.
link '/usr/lib/jvm/default-java' do
to node['java']['java_home']
not_if { node['java']['java_home'] == '/usr/lib/jvm/default-java' }
end

View File

@ -0,0 +1,76 @@
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Cookbook Name:: java
# Recipe:: ibm
#
# Copyright 2013, Opscode, 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.
require 'uri'
source_url = node['java']['ibm']['url']
jdk_uri = ::URI.parse(source_url)
jdk_filename = ::File.basename(jdk_uri.path)
unless valid_ibm_jdk_uri?(source_url)
raise "You must set the attribute `node['java']['ibm']['url']` to a valid HTTP URI"
end
# "installable package" installer needs rpm on Ubuntu
if platform_family?('debian') && jdk_filename !~ /archive/
package "rpm" do
action :install
end
end
template "#{Chef::Config[:file_cache_path]}/installer.properties" do
source "ibm_jdk.installer.properties.erb"
only_if { node['java']['ibm']['accept_ibm_download_terms'] }
end
remote_file "#{Chef::Config[:file_cache_path]}/#{jdk_filename}" do
source source_url
mode 00755
if node['java']['ibm']['checksum']
checksum node['java']['ibm']['checksum']
action :create
else
action :create_if_missing
end
notifies :run, "execute[install-ibm-java]", :immediately
end
java_alternatives 'set-java-alternatives' do
java_location node['java']['java_home']
default node['java']['set_default']
case node['java']['jdk_version'].to_s
when "6"
bin_cmds node['java']['ibm']['6']['bin_cmds']
when "7"
bin_cmds node['java']['ibm']['7']['bin_cmds']
end
action :nothing
end
execute "install-ibm-java" do
cwd Chef::Config[:file_cache_path]
environment({
"_JAVA_OPTIONS" => "-Dlax.debug.level=3 -Dlax.debug.all=true",
"LAX_DEBUG" => "1"
})
command "./#{jdk_filename} -f ./installer.properties -i silent"
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
creates "#{node['java']['java_home']}/jre/bin/java"
end
include_recipe "java::set_java_home"

View File

@ -0,0 +1,70 @@
# Cookbook Name:: java
# Recipe:: ibm_tar
#
# Copyright 2013, Opscode, 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.
require 'uri'
source_url = node['java']['ibm']['url']
jdk_uri = ::URI.parse(source_url)
jdk_filename = ::File.basename(jdk_uri.path)
unless valid_ibm_jdk_uri?(source_url)
raise "You must set the attribute `node['java']['ibm']['url']` to a valid URI"
end
unless jdk_filename =~ /\.(tar.gz|tgz)$/
raise "The attribute `node['java']['ibm']['url']` must specify a .tar.gz file"
end
remote_file "#{Chef::Config[:file_cache_path]}/#{jdk_filename}" do
source source_url
mode 00755
if node['java']['ibm']['checksum']
checksum node['java']['ibm']['checksum']
action :create
else
action :create_if_missing
end
notifies :create, "directory[create-java-home]", :immediately
notifies :run, "execute[untar-ibm-java]", :immediately
end
directory "create-java-home" do
path node['java']['java_home']
mode 00755
recursive true
end
java_alternatives 'set-java-alternatives' do
java_location node['java']['java_home']
default node['java']['set_default']
case node['java']['jdk_version'].to_s
when "6"
bin_cmds node['java']['ibm']['6']['bin_cmds']
when "7"
bin_cmds node['java']['ibm']['7']['bin_cmds']
end
action :nothing
end
execute "untar-ibm-java" do
cwd Chef::Config[:file_cache_path]
command "tar xzf ./#{jdk_filename} -C #{node['java']['java_home']} --strip 1"
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
creates "#{node['java']['java_home']}/jre/bin/java"
end
include_recipe "java::set_java_home"

View File

@ -0,0 +1,72 @@
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Author:: Joshua Timberman (<joshua@opscode.com>)
#
# Cookbook Name:: java
# Recipe:: openjdk
#
# Copyright 2010-2013, Opscode, 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.
unless node.recipe?('java::default')
Chef::Log.warn("Using java::default instead is recommended.")
# Even if this recipe is included by itself, a safety check is nice...
[ node['java']['openjdk_packages'], node['java']['java_home'] ].each do |v|
if v.nil? or v.empty?
include_recipe "java::set_attributes_from_version"
end
end
end
jdk = Opscode::OpenJDK.new(node)
if platform_requires_license_acceptance?
file "/opt/local/.dlj_license_accepted" do
owner "root"
group "root"
mode "0400"
action :create
only_if { node['java']['accept_license_agreement'] }
end
end
node['java']['openjdk_packages'].each do |pkg|
package pkg do
version node['java']['openjdk_version'] if node['java']['openjdk_version']
end
end
if platform_family?('debian', 'rhel', 'fedora')
java_alternatives 'set-java-alternatives' do
java_location jdk.java_home
default node['java']['set_default']
priority jdk.alternatives_priority
case node['java']['jdk_version'].to_s
when "6"
bin_cmds node['java']['jdk']['6']['bin_cmds']
when "7"
bin_cmds node['java']['jdk']['7']['bin_cmds']
end
action :set
end
end
if node['java']['set_default'] and platform_family?('debian')
include_recipe 'java::default_java_symlink'
end
# We must include this recipe AFTER updating the alternatives or else JAVA_HOME
# will not point to the correct java.
include_recipe 'java::set_java_home'

View File

@ -0,0 +1,67 @@
#
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
# Cookbook Name:: java
# Recipe:: oracle
#
# Copyright 2011, 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.
unless node.recipe?('java::default')
Chef::Log.warn("Using java::default instead is recommended.")
# Even if this recipe is included by itself, a safety check is nice...
if node['java']['java_home'].nil? or node['java']['java_home'].empty?
include_recipe "java::set_attributes_from_version"
end
end
java_home = node['java']["java_home"]
arch = node['java']['arch']
case node['java']['jdk_version'].to_s
when "6"
tarball_url = node['java']['jdk']['6'][arch]['url']
tarball_checksum = node['java']['jdk']['6'][arch]['checksum']
bin_cmds = node['java']['jdk']['6']['bin_cmds']
when "7"
tarball_url = node['java']['jdk']['7'][arch]['url']
tarball_checksum = node['java']['jdk']['7'][arch]['checksum']
bin_cmds = node['java']['jdk']['7']['bin_cmds']
when "8"
tarball_url = node['java']['jdk']['8'][arch]['url']
tarball_checksum = node['java']['jdk']['8'][arch]['checksum']
bin_cmds = node['java']['jdk']['8']['bin_cmds']
end
if tarball_url =~ /example.com/
Chef::Application.fatal!("You must change the download link to your private repository. You can no longer download java directly from http://download.oracle.com without a web broswer")
end
include_recipe "java::set_java_home"
java_ark "jdk" do
url tarball_url
default node['java']['set_default']
checksum tarball_checksum
app_home java_home
bin_cmds bin_cmds
alternatives_priority node['java']['alternatives_priority']
retries node['java']['ark_retries']
retry_delay node['java']['ark_retry_delay']
action :install
end
if node['java']['set_default'] and platform_family?('debian')
include_recipe 'java::default_java_symlink'
end

View File

@ -0,0 +1,67 @@
#
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
# Cookbook Name:: java
# Recipe:: oracle_i386
#
# Copyright 2010-2011, Opscode, 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.
unless node.recipe?('java::default')
Chef::Log.warn("Using java::default instead is recommended.")
# Even if this recipe is included by itself, a safety check is nice...
if node['java']['java_home'].nil? or node['java']['java_home'].empty?
include_recipe "java::set_attributes_from_version"
end
end
java_home = node['java']["java_home"]
case node['java']['jdk_version'].to_s
when "6"
tarball_url = node['java']['jdk']['6']['i586']['url']
tarball_checksum = node['java']['jdk']['6']['i586']['checksum']
bin_cmds = node['java']['jdk']['6']['bin_cmds']
when "7"
tarball_url = node['java']['jdk']['7']['i586']['url']
tarball_checksum = node['java']['jdk']['7']['i586']['checksum']
bin_cmds = node['java']['jdk']['7']['bin_cmds']
when "8"
tarball_url = node['java']['jdk']['8']['i586']['url']
tarball_checksum = node['java']['jdk']['8']['i586']['checksum']
bin_cmds = node['java']['jdk']['8']['bin_cmds']
end
include_recipe "java::set_java_home"
yum_package "glibc" do
arch "i686"
only_if { platform_family?( "rhel", "fedora" ) }
end
java_ark "jdk-alt" do
url tarball_url
default node['java']['set_default']
checksum tarball_checksum
app_home java_home
bin_cmds bin_cmds
retries node['java']['ark_retries']
retry_delay node['java']['ark_retries']
action :install
default false
end
if node['java']['set_default'] and platform_family?('debian')
include_recipe 'java::default_java_symlink'
end

View File

@ -0,0 +1,58 @@
# Author:: Christophe Arguel (<christophe.arguel@free.fr>)
#
# Cookbook Name:: java
# Recipe:: oracle_rpm
#
# Copyright 2013, Christophe Arguel <christophe.arguel@free.fr>
#
# 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 'java::set_java_home'
slave_cmds = case node['java']['oracle_rpm']['type']
when 'jdk'
%W[appletviewer apt ControlPanel extcheck idlj jar jarsigner javac javadoc javafxpackager javah javap java-rmi.cgi javaws jcmd jconsole jcontrol jdb jhat jinfo jmap jps jrunscript jsadebugd jstack jstat jstatd jvisualvm keytool native2ascii orbd pack200 policytool rmic rmid rmiregistry schemagen serialver servertool tnameserv unpack200 wsgen wsimport xjc]
when 'jre'
%W[ControlPanel java_vm javaws jcontrol keytool orbd pack200 policytool rmid rmiregistry servertool tnameserv unpack200]
else
Chef::Application.fatal "Unsupported oracle RPM type (#{node['java']['oracle_rpm']['type']})"
end
if platform_family?('rhel', 'fedora') and node['java']['set_default']
bash 'update-java-alternatives' do
java_home = node['java']['java_home']
java_location = File.join(java_home, "bin", "java")
slave_lines = slave_cmds.inject("") do |slaves, cmd|
slaves << "--slave /usr/bin/#{cmd} #{cmd} #{File.join(java_home, "bin", cmd)} \\\n"
end
code <<-EOH.gsub(/^\s+/, '')
update-alternatives --install /usr/bin/java java #{java_location} 1061 \
#{slave_lines} && \
update-alternatives --set java #{java_location}
EOH
action :nothing
end
end
package_name = node['java']['oracle_rpm']['package_name'] || node['java']['oracle_rpm']['type']
package package_name do
action :install
version node['java']['oracle_rpm']['package_version'] if node['java']['oracle_rpm']['package_version']
notifies :run, 'bash[update-java-alternatives]', :immediately if platform_family?('rhel', 'fedora') and node['java']['set_default']
end

View File

@ -0,0 +1,20 @@
# Cookbook Name:: java
# Recipe:: purge_packages
#
# 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.
%w[sun-java6-jdk sun-java6-bin sun-java6-jre].each do |pkg|
package pkg do
action :purge
end
end

View File

@ -0,0 +1,53 @@
# Cookbook Name:: java
# Recipe:: set_attributes_from_version
#
# 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.
# Calculate variables that depend on jdk_version
# If you need to override this in an attribute file you must use
# force_default or higher precedence.
case node['platform_family']
when "rhel", "fedora"
case node['java']['install_flavor']
when "oracle"
node.default['java']['java_home'] = "/usr/lib/jvm/java"
when "oracle_rpm"
node.default['java']['java_home'] = "/usr/java/latest"
else
node.default['java']['java_home'] = "/usr/lib/jvm/java-1.#{node['java']['jdk_version']}.0"
end
node.default['java']['openjdk_packages'] = ["java-1.#{node['java']['jdk_version']}.0-openjdk", "java-1.#{node['java']['jdk_version']}.0-openjdk-devel"]
when "freebsd"
node.default['java']['java_home'] = "/usr/local/openjdk#{node['java']['jdk_version']}"
node.default['java']['openjdk_packages'] = ["openjdk#{node['java']['jdk_version']}"]
when "arch"
node.default['java']['java_home'] = "/usr/lib/jvm/java-#{node['java']['jdk_version']}-openjdk"
node.default['java']['openjdk_packages'] = ["openjdk#{node['java']['jdk_version']}"]
when "debian"
node.default['java']['java_home'] = "/usr/lib/jvm/java-#{node['java']['jdk_version']}-#{node['java']['install_flavor']}"
# Newer Debian & Ubuntu adds the architecture to the path
if node['platform'] == 'debian' && Chef::VersionConstraint.new(">= 7.0").include?(node['platform_version']) ||
node['platform'] == 'ubuntu' && Chef::VersionConstraint.new(">= 12.04").include?(node['platform_version'])
node.default['java']['java_home'] = "#{node['java']['java_home']}-#{node['kernel']['machine'] == 'x86_64' ? 'amd64' : 'i386'}"
end
node.default['java']['openjdk_packages'] = ["openjdk-#{node['java']['jdk_version']}-jdk", "openjdk-#{node['java']['jdk_version']}-jre-headless"]
when "smartos"
node.default['java']['java_home'] = "/opt/local/java/sun6"
node.default['java']['openjdk_packages'] = ["sun-jdk#{node['java']['jdk_version']}", "sun-jre#{node['java']['jdk_version']}"]
when "windows"
# Do nothing otherwise we will fall through to the else and set java_home to an invalid path, causing the installer to popup a dialog
else
node.default['java']['java_home'] = "/usr/lib/jvm/default-java"
node.default['java']['openjdk_packages'] = ["openjdk-#{node['java']['jdk_version']}-jdk"]
end

View File

@ -0,0 +1,44 @@
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Cookbook Name:: java
# Recipe:: set_java_home
#
# Copyright 2013, Opscode, 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.
ruby_block "set-env-java-home" do
block do
ENV["JAVA_HOME"] = node['java']['java_home']
end
not_if { ENV["JAVA_HOME"] == node['java']['java_home'] }
end
directory "/etc/profile.d" do
mode 00755
end
file "/etc/profile.d/jdk.sh" do
content "export JAVA_HOME=#{node['java']['java_home']}"
mode 00755
end
if node['java']['set_etc_environment']
ruby_block "Set JAVA_HOME in /etc/environment" do
block do
file = Chef::Util::FileEdit.new("/etc/environment")
file.insert_line_if_no_match(/^JAVA_HOME=/, "JAVA_HOME=#{node['java']['java_home']}")
file.search_file_replace_line(/^JAVA_HOME=/, "JAVA_HOME=#{node['java']['java_home']}")
file.write_file
end
end
end

View File

@ -0,0 +1,77 @@
#
# Author:: Kendrick Martin (<kendrick.martin@webtrends.com>)
# Cookbook Name:: java
# Recipe:: windows
#
# Copyright 2008-2012 Webtrends, 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.
#
require 'uri'
Chef::Log.fatal("No download url set for java installer.") unless node['java'] && node['java']['windows'] && node['java']['windows']['url']
pkg_checksum = node['java']['windows']['checksum']
aws_access_key_id = node['java']['windows']['aws_access_key_id']
aws_secret_access_key = node['java']['windows']['aws_secret_access_key']
uri = ::URI.parse(node['java']['windows']['url'])
cache_file_path = File.join(Chef::Config[:file_cache_path], File.basename(::URI.unescape(uri.path)))
if aws_access_key_id && aws_secret_access_key
include_recipe 'aws::default' # install right_aws gem for aws_s3_file
aws_s3_file cache_file_path do
aws_access_key_id aws_access_key_id
aws_secret_access_key aws_secret_access_key
checksum pkg_checksum if pkg_checksum
bucket node['java']['windows']['bucket']
remote_path node['java']['windows']['remote_path']
backup false
action :create
end
else
remote_file cache_file_path do
checksum pkg_checksum if pkg_checksum
source node['java']['windows']['url']
backup false
action :create
end
end
if node['java'].attribute?("java_home")
java_home_win = win_friendly_path(node['java']['java_home'])
# The EXE installer expects escaped quotes, so we need to double escape
# them here. The final string looks like :
# /v"/qn INSTALLDIR=\"C:\Program Files\Java\""
additional_options = "/v\"/qn INSTALLDIR=\\\"#{java_home_win}\\\"\""
env "JAVA_HOME" do
value java_home_win
end
# update path
windows_path "#{java_home_win}\\bin" do
action :add
end
end
windows_package node['java']['windows']['package_name'] do
source cache_file_path
checksum node['java']['windows']['checksum']
action :install
installer_type :custom
options "/s #{additional_options}"
end

View File

@ -0,0 +1,29 @@
#
# Cookbook Name:: java
# Provider:: alternatives
#
# 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 :set, :unset
attribute :java_location, :kind_of => String, :default => nil
attribute :bin_cmds, :kind_of => Array, :default => nil
attribute :default, :equal_to => [true, false], :default => true
attribute :priority, :kind_of => Integer, :default => 1061
# we have to set default for the supports attribute
# in initializer since it is a 'reserved' attribute name
def initialize(*args)
super
@action = :set
end

View File

@ -0,0 +1,55 @@
#
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
# Cookbook Name:: java
# Resource:: ark
#
# Copyright 2011, 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, :remove
state_attrs :alternatives_priority,
:app_home,
:app_home_mode,
:bin_cmds,
:checksum,
:md5,
:default,
:mirrorlist,
:owner,
:group,
:url
attribute :url, :regex => /^(file|http|https?):\/\/.*(gz|tar.gz|tgz|bin|zip)$/, :default => nil
attribute :mirrorlist, :kind_of => Array, :default => nil
attribute :checksum, :regex => /^[0-9a-f]{32}$|^[a-zA-Z0-9]{40,64}$/, :default => nil
attribute :md5, :regex => /^[0-9a-f]{32}$|^[a-zA-Z0-9]{40,64}$/, :default => nil
attribute :app_home, :kind_of => String, :default => nil
attribute :app_home_mode, :kind_of => Integer, :default => 0755
attribute :bin_cmds, :kind_of => Array, :default => []
attribute :owner, :default => 'root'
# Will default to :owner if :group is not passed
attribute :group, :default => nil
attribute :default, :equal_to => [true, false], :default => true
attribute :alternatives_priority, :kind_of => Integer, :default => 1
attribute :retries, :kind_of => Integer, :default => 0
attribute :retry_delay, :kind_of => Integer, :default => 2
# we have to set default for the supports attribute
# in initializer since it is a 'reserved' attribute name
def initialize(*args)
super
@action = :install
@supports = {:report => true, :exception => true}
end

View File

@ -0,0 +1,3 @@
INSTALLER_UI=silent
USER_INSTALL_DIR=<%= node['java']['java_home'] %>
-fileOverwrite_<%= node['java']['java_home'] %>_uninstall/uninstall.lax=Yes

View File

@ -0,0 +1,6 @@
name=<%= @name %>
priority=<%= @priority %>
section=main
<% @bin_cmds.each do |cmd| -%>jdk <%= cmd %> <%= @app_dir %>/bin/<%= cmd %>
<% end -%>

View File

@ -0,0 +1,434 @@
mysql Cookbook CHANGELOG
========================
This file is used to list changes made in each version of the mysql cookbook.
v5.5.3 (2014-09-24)
------------------
- Reverting back to Upstart on Ubuntu 14.04
v5.5.2 (2014-09-8)
------------------
- Reverting commit that broke Debian pass_string
v5.5.1 (2014-09-2)
------------------
- Switching Ubuntu service provider to use SysVinit instead of Upstart
v5.5.0 (2014-08-27)
-------------------
- Adding package version and action parameters to mysql_service resource
- Fixing Debian pass_string
v5.4.4 (2014-08-27)
-------------------
- Changing module namespace to MysqlCookbook
v5.4.3 (2014-08-25)
-------------------
- More refactoring. Moving helper function bits into resource parsed_parameters
v5.4.2 (2014-08-25)
-------------------
- Moving provider local variables into definitions for RHEL provider
v5.4.1 (2014-08-25)
-------------------
- Refactoring resources into the LWRP style with parsed parameters
- Moving provider local variables into definitions
v5.4.0 (2014-08-25)
-------------------
- #212 - support for centos-7 (mysql55 and mysql56)
- Adding (untested) Debian-6 support
- Adding Suse support to metadata.rb
- Adding ability to change MySQL root password
- Added libmysqlclient-devel package to SuSE client provider
- Appeasing AppArmor
- Reducing duplication in client provider
v5.3.6 (2014-06-18)
-------------------
- Fixing pid path location. Updating tests to include real RHEL
v5.3.4 (2014-06-16)
-------------------
- Fixing specs for Amazon Linux server package names
v5.3.2 (2014-06-16)
-------------------
- Fixing Amazon Linux support
v5.3.0 (2014-06-11)
-------------------
- #189 - Fix server_repl_password description
- #191 - Adding support for server55 and server56 on el-6
- #193 - Fix syntax in mysql_service example
- #199 - Adding Suse support
v5.2.12 (2014-05-19)
--------------------
PR #192 - recipes/server.rb should honor parameter node['mysql']['version']
v5.2.10 (2014-05-15)
--------------------
- COOK-4394 - restore freebsd support
v5.2.8 (2014-05-15)
-------------------
- [COOK-4653] - Missing mySQL 5.6 support for Ubuntu 14.04
v5.2.6 (2014-05-07)
-------------------
- [COOK-4625] - Fix password resource parameter consumption on Debian and Ubuntu
- Fix up typos and version numbers in PLATFORMS.md
- Fix up specs from COOK-4613 changes
v5.2.4 (2014-05-02)
-------------------
- [COOK-4613] - Fix permissions on mysql data_dir to allow global access to mysql.sock
v5.2.2 (2014-04-24)
-------------------
- [COOK-4564] - Using positive tests for datadir move
v5.2.0 (2014-04-22)
-------------------
- [COOK-4551] - power grants.sql from resource parameters
v5.1.12 (2014-04-21)
--------------------
- [COOK-4554] - Support for Debian Sid
v5.1.10 (2014-04-21)
--------------------
- [COOK-4565] Support for Ubuntu 14.04
- [COOK-4565] Adding Specs and TK platform
- Removing non-LTS 13.10 specs and TK platform
v5.1.8 (2014-04-12)
-------------------
Adding Ubuntu 13.04 to Platforminfo
v5.1.6 (2014-04-11)
-------------------
- [COOK-4548] - Add template[/etc/mysql/debian.cnf] to Ubuntu provider
v5.1.4 (2014-04-11)
-------------------
- [COOK-4547] - Shellescape server_root_password
v5.1.2 (2014-04-09)
-------------------
- [COOK-4519] - Fix error in run_dir for Ubuntu
- [COOK-4531] - Fix pid and run_dir for Debian
v5.1.0 (2014-04-08)
-------------------
[COOK-4523] - Allow for both :restart and :reload
v5.0.6 (2014-04-07)
-------------------
- [COOK-4519] - Updating specs to reflect pid file change on Ubuntu
v5.0.4 (2014-04-07)
-------------------
- [COOK-4519] - Fix path to pid file on Ubuntu
v5.0.2 (2014-04-01)
-------------------
- Moving server_deprecated into recipes directory
v5.0.0 (2014-03-31)
-------------------
- Rewriting as a library cookbook
- Exposing mysql_service and mysql_client resources
- User now needs to supply configuration
- Moving attribute driven recipe to server-deprecated
v4.1.2 (2014-02-28)
-------------------
- [COOK-4349] - Fix invalid platform check
- [COOK-4184] - Better handling of Ubuntu upstart service
- [COOK-2100] - Changing innodb_log_file_size tunable results in inability to start MySQL
v4.1.1 (2014-02-25)
-------------------
- **[COOK-2966] - Address foodcritic failures'
- **[COOK-4182] - Template parse failure in /etc/init/mysql.conf (data_dir)'
- **[COOK-4198] - Added missing tunable'
- **[COOK-4206] - create root@127.0.0.1, as well as root@localhost'
v4.0.20 (2014-01-18)
--------------------
* [COOK-3931] - MySQL Server Recipe Regression for Non-LTS Ubuntu Versions
* [COOK-3945] - MySQL cookbook fails on Ubuntu 13.04/13.10
* [COOK-3966] - mysql::server recipe can't find a template with debian 7.x
* [COOK-3985] - Missing /etc/mysql/debian.cnf template on mysql::_server_debian.rb recipe (mysql 4.0.4)
* [COOK-3974] - debian.cnf not updated
* [COOK-4001] - Pull request: Fixes for broken mysql::server on Debian
* [COOK-4071] - Mysql cookbook doesn't work on debian 7.2
v4.0.14
-------
Fixing style cops
v4.0.12
-------
### Bug
- **[COOK-4068](https://tickets.opscode.com/browse/COOK-4068)** - rework MySQL Windows recipe
### Improvement
- **[COOK-3801](https://tickets.opscode.com/browse/COOK-3801)** - Add innodb_adaptive_flushing_method and innodb_adaptive_checkpoint
v4.0.10
-------
fixing metadata version error. locking to 3.0
v4.0.8
------
Locking yum dependency to '< 3'
v4.0.6
------
# Bug
- [COOK-3943] Notifying service restart on grants update
v4.0.4
------
[COOK-3952] - Adding 'recursive true' to directory resources
v4.0.2
------
### BUGS
- Adding support for Amazon Linux in attributes/server_rhel.rb
- Fixing bug where unprivileged users cannot connect over a local socket. Adding integration test.
- Fixing bug in mysql_grants_cmd generation
v4.0.0
------
- [COOK-3928] Heavily refactoring for readability. Moving platform implementation into separate recipes
- Moving integration tests from minitest to serverspec, removing "improper" tests
- Moving many attributes into the ['mysql']['server']['whatever'] namespace
- [COOK-3481] - Merged Lucas Welsh's Windows bits and moved into own recipe
- [COOK-3697] - Adding security hardening attributes
- [COOK-3780] - Fixing data_dir on Debian and Ubuntu
- [COOK-3807] - Don't use execute[assign-root-password] on Debian and Ubuntu
- [COOK-3881] - Fixing /etc being owned by mysql user
v3.0.12
-------
### Bug
- **[COOK-3752](https://tickets.opscode.com/browse/COOK-3752)** - mysql service fails to start in mysql::server recipe
v3.0.10
-------
- Fix a failed release attempt for v3.0.8
v3.0.8
------
### Bug
- **[COOK-3749](https://tickets.opscode.com/browse/COOK-3749)** - Fix a regression with Chef 11-specific features
v3.0.6
------
### Bug
- **[COOK-3674](https://tickets.opscode.com/browse/COOK-3674)** - Fix an issue where the MySQL server fails to set the root password correctly when `data_dir` is a non-default value
- **[COOK-3647](https://tickets.opscode.com/browse/COOK-3647)** - Fix README typo (databas => database)
- **[COOK-3477](https://tickets.opscode.com/browse/COOK-3477)** - Fix log-queries-not-using-indexes not working
- **[COOK-3436](https://tickets.opscode.com/browse/COOK-3436)** - Pull percona repo in compilation phase
- **[COOK-3208](https://tickets.opscode.com/browse/COOK-3208)** - Fix README typo (LitenPort => ListenPort)
- **[COOK-3149](https://tickets.opscode.com/browse/COOK-3149)** - Create my.cnf before installing
- **[COOK-2681](https://tickets.opscode.com/browse/COOK-2681)** - Fix log_slow_queries for 5.5+
- **[COOK-2606](https://tickets.opscode.com/browse/COOK-2606)** - Use proper bind address on cloud providers
### Improvement
- **[COOK-3498](https://tickets.opscode.com/browse/COOK-3498)** - Add support for replicate_* variables in my.cnf
v3.0.4
------
### Bug
- **[COOK-3310](https://tickets.opscode.com/browse/COOK-3310)** - Fix missing `GRANT` option
- **[COOK-3233](https://tickets.opscode.com/browse/COOK-3233)** - Fix escaping special characters
- **[COOK-3156](https://tickets.opscode.com/browse/COOK-3156)** - Fix GRANTS file when `remote_root_acl` is specified
- **[COOK-3134](https://tickets.opscode.com/browse/COOK-3134)** - Fix Chef 11 support
- **[COOK-2318](https://tickets.opscode.com/browse/COOK-2318)** - Remove redundant `if` block around `node.mysql.tunable.log_bin`
v3.0.2
------
### Bug
- [COOK-2158]: apt-get update is run twice at compile time
- [COOK-2832]: mysql grants.sql file has errors depending on attrs
- [COOK-2995]: server.rb is missing a platform_family comparison value
### Sub-task
- [COOK-2102]: `innodb_flush_log_at_trx_commit` value is incorrectly set based on CPU count
v3.0.0
------
**Note** This is a backwards incompatible version with previous versions of the cookbook. Tickets that introduce incompatibility are COOK-2615 and COOK-2617.
- [COOK-2478] - Duplicate 'read_only' server attribute in base and tunable
- [COOK-2471] - Add tunable to set slave_compressed_protocol for reduced network traffic
- [COOK-1059] - Update attributes in mysql cookbook to support missing options for my.cnf usable by Percona
- [COOK-2590] - Typo in server recipe to do with conf_dir and confd_dir
- [COOK-2602] - Add `lower_case_table_names` tunable
- [COOK-2430] - Add a tunable to create a network ACL when allowing `remote_root_access`
- [COOK-2619] - mysql: isamchk deprecated
- [COOK-2515] - Better support for SUSE distribution for mysql cookbook
- [COOK-2557] - mysql::percona_repo attributes missing and key server typo
- [COOK-2614] - Duplicate `innodb_file_per_table`
- [COOK-2145] - MySQL cookbook should remove anonymous and password less accounts
- [COOK-2553] - Enable include directory in my.cnf template for any platform
- [COOK-2615] - Rename `key_buffer` to `key_buffer_size`
- [COOK-2626] - Percona repo URL is being constructed incorrectly
- [COOK-2616] - Unneeded attribute thread_cache
- [COOK-2618] - myisam-recover not using attribute value
- [COOK-2617] - open-files is a duplicate of open-files-limit
v2.1.2
------
- [COOK-2172] - Mysql cookbook duplicates `binlog_format` configuration
v2.1.0
------
- [COOK-1669] - Using platform("ubuntu") in default attributes always returns true
- [COOK-1694] - Added additional my.cnf fields and reorganized cookbook to avoid race conditions with mysql startup and sql script execution
- [COOK-1851] - Support server-id and binlog_format settings
- [COOK-1929] - Update msyql server attributes file because setting attributes without specifying a precedence is deprecated
- [COOK-1999] - Add read_only tunable useful for replication slave servers
v2.0.2
------
- [COOK-1967] - mysql: trailing comma in server.rb platform family
v2.0.0
------
**Important note for this release**
Under Chef Solo, you must set the node attributes for the root, debian and repl passwords or the run will completely fail. See COOK-1737 for background on this.
- [COOK-1390] - MySQL service cannot start after reboot
- [COOK-1610] - Set root password outside preseed (blocker for drop-in mysql replacements)
- [COOK-1624] - Mysql cookbook fails to even compile on windows
- [COOK-1669] - Using platform("ubuntu") in default attributes always returns true
- [COOK-1686] - Add mysql service start
- [COOK-1687] - duplicate `innodb_buffer_pool_size` attribute
- [COOK-1704] - mysql cookbook fails spec tests when minitest-handler cookbook enabled
- [COOK-1737] - Fail a chef-solo run when `server_root_password`, `server_debian_password`, and/or `server_repl_password` is not set
- [COOK-1769] - link to database recipe in mysql README goes to old opscode/cookbooks repo instead of opscode-cookbook organization
- [COOK-1963] - use `platform_family`
v1.3.0
------
**Important note for this release**
This version no longer installs Ruby bindings in the client recipe by default. Use the ruby recipe if you'd like the RubyGem. If you'd like packages from your distribution, use them in your application's specific cookbook/recipe, or modify the client packages attribute. This resolves the following tickets:
- COOK-932
- COOK-1009
- COOK-1384
Additionally, this cookbook now has tests (COOK-1439) for use under test-kitchen.
The following issues are also addressed in this release.
- [COOK-1443] - MySQL (>= 5.1.24) does not support `innodb_flush_method` = fdatasync
- [COOK-1175] - Add Mac OS X support
- [COOK-1289] - handle additional tunable attributes
- [COOK-1305] - add auto-increment-increment and auto-increment-offset attributes
- [COOK-1397] - make the port an attribute
- [COOK-1439] - Add MySQL cookbook tests for test-kitchen support
- [COOK-1236] - Move package names into attributes to allow percona to free-ride
- [COOK-934] - remove deprecated mysql/libraries/database.rb, use the database cookbook instead.
- [COOK-1475] - fix restart on config change
v1.2.6
------
- [COOK-1113] - Use an attribute to determine if upstart is used
- [COOK-1121] - Add support for Windows
- [COOK-1140] - Fix conf.d on Debian
- [COOK-1151] - Fix server_ec2 handling /var/lib/mysql bind mount
- [COOK-1321] - Document setting password attributes for solo
v1.2.4
------
- [COOK-992] - fix FATAL nameerror
- [COOK-827] - `mysql:server_ec2` recipe can't mount `data_dir`
- [COOK-945] - FreeBSD support
v1.2.2
------
- [COOK-826] mysql::server recipe doesn't quote password string
- [COOK-834] Add 'scientific' and 'amazon' platforms to mysql cookbook
v1.2.1
------
- [COOK-644] Mysql client cookbook 'package missing' error message is confusing
- [COOK-645] RHEL6/CentOS6 - mysql cookbook contains 'skip-federated' directive which is unsupported on MySQL 5.1
v1.2.0
------
- [COOK-684] remove mysql_database LWRP
v1.0.8
------
- [COOK-633] ensure "cloud" attribute is available
v1.0.7
------
- [COOK-614] expose all mysql tunable settings in config
- [COOK-617] bind to private IP if available
v1.0.6
------
- [COOK-605] install mysql-client package on ubuntu/debian
v1.0.5
------
- [COOK-465] allow optional remote root connections to mysql
- [COOK-455] improve platform version handling
- externalize conf_dir attribute for easier cross platform support
- change datadir attribute to data_dir for consistency
v1.0.4
------
- fix regressions on debian platform
- [COOK-578] wrap root password in quotes
- [COOK-562] expose all tunables in my.cnf

View File

@ -0,0 +1,215 @@
MySQL cookbook
=====================
The MySQL cookbook exposes the `mysql_service` and `mysql_client`
resources. These resources are utilized by the `mysql::client`
and `mysql::server` recipes, or can be consumed in other recipes by
depending on the MySQL cookbook.
This cookbook does its best to follow platform native idioms at all
times. This means things like logs, pid files, sockets, and service
managers work "as expected" by an administrator familiar with a given
platform.
Scope
-----
This cookbook is concerned with the "MySQL Community Server",
particularly those shipped with F/OSS Unix and Linux distributions. It
does not address forks and value-added repackaged MySQL distributions
like Drizzle, MariaDB, or Percona.
This cookbook does not try to encompass every single configuration
option available for MySQL. Instead, it provides a "just enough" to
get a MySQL server running, then allows the user to specify additional
custom configuration.
Requirements
------------
* Chef 11 or higher
* Ruby 1.9 (preferably from the Chef full-stack installer)
Resources
---------------------
The resources that ship in this cookbook are examples of 'singleton
resources'. This means that there can only be one instance of them
configured on a machine. The providers that handle the implementation
of the `mysql_service` and `mysql_client` resources do so by following
platform native idioms. These usually only allow for one instance of a
service to be running at a given time.
### mysql_service
The `mysql_service` resource configures the basic plumbing
needed to run a simple mysql_service with a minimal configuration.
Please note that when using `notifies` or `subscribes`, the resource
is `mysql_service`. This means that this cookbook does _not_ setup
`service[mysql]`.
### Example
mysql_service 'default' do
version '5.1'
port '3307'
data_dir '/data'
template_source 'custom.erb'
allow_remote_root true
root_network_acl ['10.9.8.7/6', '1.2.3.4/5']
remove_anonymous_users false
remove_test_database false
server_root_password 'decrypt_me_from_a_databag_maybe'
server_repl_password 'sync_me_baby_one_more_time'
action :create
end
The `version` parameter will allow the user to select from the
versions available for the platform, where applicable. When omitted,
it will install the default MySQL version for the target platform.
Available version numbers are `5.0`, `5.1`, `5.5`, and `5.6`,
depending on platform. See PLATFORMS.md for details.
The `port` parameter determines the listen port for the mysqld
service. When omitted, it will default to '3306'.
The `data_dir` parameter determines where the actual data files are
kept on the machine. This is useful when mounting external storage.
When omitted, it will default to the platform's native location.
The `template_source` parameter allows the user to override the
default minimal template used by the `mysql_service` resource. When
omitted, it will select one shipped with the cookbook based on the
MySQL version.
The `allow_remote_root` parameter allows the user to specify whether
remote connections from the mysql root user. When set to true, it is
recommended that it be used in combination with the `root_network_acl`
parameter. When omitted, it will default to false.
The `remove_anonymous_users` parameter allows the user to remove
anonymous users often installed by default with during the mysql db
initialization. When omitted, it defaults to true.
The `remove_test_database` parameter allows the user to specify
whether or not the test database is removed. When omitted, it defaults
to true.
The `root_network_acl` parameter allows the user to specify a list of
subnets to accept connections for the root user from. When omitted, it
defaults to none.
The `server_root_password` parameter allows the user to specify the
root password for the mysql database. This can be set explicitly in a
recipe, driven from a node attribute, or from data_bags. When omitted,
it defaults to `ilikerandompasswords`. Please be sure to change it.
The `server_debian_password` parameter allows the user to specify the
debian-sys-maint users password, used in log rotations and service
management on Debian and Debian derived platforms.
The `server_repl_password` parameter allows the user to specify the
password used by `'repl'@'%'`, used in clustering scenarios. When
omitted, it does not create the repl user or set a password.
The mysql_service resource supports :create, :restart, and :reload actions.
### mysql_client
The `mysql_client` resource installs or removes the MySQL client binaries and
development libraries
Recipes
-------
### mysql::server
This recipe calls a `mysql_service` resource, passing parameters
from node attributes.
### mysql::client
This recipe calls a `mysql_client` resource, with action :create
Usage
-----
The `mysql::server` recipe and `mysql_service` resources are designed to
provide a minimal configuration. The default `my.cnf` dropped off has
an `!includedir` directive. Site-specific configuration should be
placed in the platform's native location.
### run_list
Include `'recipe[mysql::server]'` or `'recipe[mysql::client]'` in your run_list.
### Wrapper cookbook
node.set['mysql']['server_root_password'] = 'yolo'
node.set['mysql']['port'] = '3308'
node.set['mysql']['data_dir'] = '/data'
include_recipe 'mysql::server'
template '/etc/mysql/conf.d/mysite.cnf' do
owner 'mysql'
owner 'mysql'
source 'mysite.cnf.erb'
notifies :restart, 'mysql_service[default]'
end
### Used directly in a recipe
template '/etc/mysql/conf.d/mysite.cnf' do
owner 'mysql'
owner 'mysql'
source 'mysite.cnf.erb'
notifies :restart, 'mysql_service[default]'
end
mysql_service 'default' do
version '5.5'
port '3307'
data_dir '/data'
template_source 'custom.erb'
action :create
end
Attributes
----------
default['mysql']['service_name'] = 'default'
default['mysql']['server_root_password'] = 'ilikerandompasswords'
default['mysql']['server_debian_password'] = 'postinstallscriptsarestupid'
default['mysql']['data_dir'] = '/var/lib/mysql'
default['mysql']['port'] = '3306'
### used in grants.sql
default['mysql']['allow_remote_root'] = false
default['mysql']['remove_anonymous_users'] = true
default['mysql']['root_network_acl'] = nil
License & Authors
-----------------
- Author:: Joshua Timberman (<joshua@opscode.com>)
- Author:: AJ Christensen (<aj@opscode.com>)
- Author:: Seth Chisamore (<schisamo@opscode.com>)
- Author:: Brian Bianco (<brian.bianco@gmail.com>)
- Author:: Jesse Howarth (<him@jessehowarth.com>)
- Author:: Andrew Crump (<andrew@kotirisoftware.com>)
- Author:: Christoph Hartmann (<chris@lollyrock.com>)
- Author:: Sean OMeara (<someara@opscode.com>)
```text
Copyright:: 2009-2014 Chef Software, 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.
```
=)

View File

@ -0,0 +1,26 @@
#
default['mysql']['service_name'] = 'default'
# passwords
default['mysql']['server_root_password'] = 'ilikerandompasswords'
default['mysql']['server_debian_password'] = nil
default['mysql']['server_repl_password'] = nil
# used in grants.sql
default['mysql']['allow_remote_root'] = false
default['mysql']['remove_anonymous_users'] = true
default['mysql']['root_network_acl'] = nil
case node['platform']
when 'smartos'
default['mysql']['data_dir'] = '/opt/local/lib/mysql'
else
default['mysql']['data_dir'] = '/var/lib/mysql'
end
# port
default['mysql']['port'] = '3306'
# server package version and action
default['mysql']['server_package_version'] = nil
default['mysql']['server_package_action'] = 'install'

View File

@ -0,0 +1,201 @@
module Opscode
module Mysql
module Helpers
def package_name_for(platform, platform_family, platform_version, version)
keyname = keyname_for(platform, platform_family, platform_version)
PlatformInfo.mysql_info[platform_family][keyname][version]['package_name']
rescue NoMethodError
nil
end
def keyname_for(platform, platform_family, platform_version)
case
when platform_family == 'rhel'
platform == 'amazon' ? platform_version : platform_version.to_i.to_s
when platform_family == 'suse'
platform_version
when platform_family == 'fedora'
platform_version
when platform_family == 'debian'
if platform == 'ubuntu'
platform_version
elsif platform_version =~ /sid$/
platform_version
else
platform_version.to_i.to_s
end
when platform_family == 'smartos'
platform_version
when platform_family == 'omnios'
platform_version
when platform_family == 'freebsd'
platform_version.to_i.to_s
end
rescue NoMethodError
nil
end
end
class PlatformInfo
def self.mysql_info
@mysql_info ||= {
'rhel' => {
'5' => {
'5.0' => {
'package_name' => 'mysql-server'
},
'5.1' => {
'package_name' => 'mysql51-mysql-server'
},
'5.5' => {
'package_name' => 'mysql55-mysql-server'
}
},
'6' => {
'5.1' => {
'package_name' => 'mysql-server'
},
'5.5' => {
'package_name' => 'mysql-community-server'
},
'5.6' => {
'package_name' => 'mysql-community-server'
}
},
'7' => {
'5.5' => {
'package_name' => 'mysql-community-server'
},
'5.6' => {
'package_name' => 'mysql-community-server'
}
},
'2013.03' => {
'5.5' => {
'package_name' => 'mysql-server'
}
},
'2013.09' => {
'5.1' => {
'package_name' => 'mysql-server'
},
'5.5' => {
'package_name' => 'mysql-community-server'
},
'5.6' => {
'package_name' => 'mysql-community-server'
}
},
'2014.03' => {
'5.1' => {
'package_name' => 'mysql51-server'
},
'5.5' => {
'package_name' => 'mysql-community-server'
},
'5.6' => {
'package_name' => 'mysql-community-server'
}
}
},
'fedora' => {
'19' => {
'5.5' => {
'package_name' => 'community-mysql-server'
}
},
'20' => {
'5.5' => {
'package_name' => 'community-mysql-server'
}
}
},
'suse' => {
'11.3' => {
'5.5' => {
'package_name' => 'mysql'
}
}
},
'debian' => {
'6' => {
'5.1' => {
'package_name' => 'mysql-server-5.1'
}
},
'7' => {
'5.5' => {
'package_name' => 'mysql-server-5.5'
}
},
'jessie/sid' => {
'5.5' => {
'package_name' => 'mysql-server-5.5'
}
},
'10.04' => {
'5.1' => {
'package_name' => 'mysql-server-5.1'
}
},
'12.04' => {
'5.5' => {
'package_name' => 'mysql-server-5.5'
}
},
'13.04' => {
'5.5' => {
'package_name' => 'mysql-server-5.5'
}
},
'13.10' => {
'5.5' => {
'package_name' => 'mysql-server-5.5'
}
},
'14.04' => {
'5.5' => {
'package_name' => 'mysql-server-5.5'
},
'5.6' => {
'package_name' => 'mysql-server-5.6'
}
}
},
'smartos' => {
'5.11' => {
'5.5' => {
'package_name' => 'mysql-server'
},
'5.6' => {
'package_name' => 'mysql-server'
}
}
},
'omnios' => {
'151006' => {
'5.5' => {
'package_name' => 'database/mysql-55'
},
'5.6' => {
'package_name' => 'database/mysql-56'
}
}
},
'freebsd' => {
'9' => {
'5.5' => {
'package_name' => 'mysql55-server'
}
},
'10' => {
'5.5' => {
'package_name' => 'mysql55-server'
}
}
}
}
end
end
end
end

View File

@ -0,0 +1,41 @@
module MysqlCookbook
module Helpers
module Debian
def include_dir
include_dir = '/etc/mysql/conf.d'
include_dir
end
def pid_file
pid_file = '/var/run/mysqld/mysql.pid'
pid_file
end
def prefix_dir
prefix_dir = '/usr'
prefix_dir
end
def run_dir
run_dir = '/var/run/mysqld'
run_dir
end
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
pass_string
end
def socket_file
socket_file = '/var/run/mysqld/mysqld.sock'
socket_file
end
end
end
end

View File

@ -0,0 +1,46 @@
module MysqlCookbook
module Helpers
module Fedora
def include_dir
include_dir = '/etc/my.cnf.d'
include_dir
end
def lc_messages_dir
lc_messages_dir = nil
lc_messages_dir
end
def pid_file
pid_file = '/var/run/mysqld/mysqld.pid'
pid_file
end
def prefix_dir
prefix_dir = '/usr'
prefix_dir
end
def run_dir
run_dir = '/var/run/mysqld'
run_dir
end
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
pass_string
end
def socket_file
socket_file = '/var/lib/mysql/mysql.sock'
socket_file
end
end
end
end

View File

@ -0,0 +1,56 @@
module MysqlCookbook
module Helpers
module FreeBSD
def base_dir
base_dir = '/usr/local'
base_dir
end
def include_dir
include_dir = '/usr/local/etc/mysql/conf.d'
include_dir
end
def my_cnf
my_cnf = '/usr/local/etc/my.cnf'
my_cnf
end
def pid_file
pid_file = '/var/db/mysql/mysqld.pid'
pid_file
end
def prefix_dir
prefix_dir = '/usr/local'
prefix_dir
end
def rc_name
rc_name = 'mysql-server'
rc_name
end
def run_dir
run_dir = '/var/run/mysqld'
run_dir
end
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
pass_string
end
def socket_file
socket_file = '/tmp/mysqld.sock'
socket_file
end
end
end
end

View File

@ -0,0 +1,61 @@
module MysqlCookbook
module Helpers
module OmniOS
def base_dir
base_dir = "/opt/mysql#{pkg_ver_string}"
base_dir
end
def include_dir
include_dir = "/opt/mysql#{pkg_ver_string}/etc/mysql/conf.d"
include_dir
end
def my_cnf
case new_resource.parsed_version
when '5.5'
my_cnf = "#{base_dir}/etc/my.cnf"
when '5.6'
my_cnf = "#{base_dir}/my.cnf"
end
my_cnf
end
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
pass_string
end
def pid_file
pid_file = '/var/run/mysql/mysql.pid'
pid_file
end
def pkg_ver_string
pkg_ver_string = new_resource.parsed_version.gsub('.', '')
pkg_ver_string
end
def prefix_dir
prefix_dir = "/opt/mysql#{pkg_ver_string}"
prefix_dir
end
def run_dir
run_dir = '/var/run/mysql'
run_dir
end
def socket_file
socket_file = '/tmp/mysql.sock'
socket_file
end
end
end
end

View File

@ -0,0 +1,116 @@
module MysqlCookbook
module Helpers
module Rhel
def base_dir
case node['platform_version'].to_i
when 5
case new_resource.parsed_version
when '5.0'
base_dir = ''
when '5.1'
base_dir = '/opt/rh/mysql51/root'
when '5.5'
base_dir = '/opt/rh/mysql55/root'
end
end
base_dir
end
def include_dir
case node['platform_version'].to_i
when 2014, 2013, 7, 6
include_dir = '/etc/mysql/conf.d'
when 5
include_dir = "#{base_dir}/etc/mysql/conf.d"
end
include_dir
end
def prefix_dir
case node['platform_version'].to_i
when 2014, 2013, 7, 6
prefix_dir = '/usr'
when 5
case new_resource.parsed_version
when '5.0'
prefix_dir = '/usr'
when '5.1'
prefix_dir = '/opt/rh/mysql51/root/usr'
when '5.5'
prefix_dir = '/opt/rh/mysql55/root/usr'
end
end
prefix_dir
end
def lc_messages_dir
case node['platform_version'].to_i
when 2014, 2013, 7, 6, 5
lc_messages_dir = nil
end
lc_messages_dir
end
def run_dir
case node['platform_version'].to_i
when 2014, 2013, 7, 6
run_dir = '/var/run/mysqld'
when 5
case new_resource.parsed_version
when '5.0'
run_dir = '/var/run/mysqld'
when '5.1'
run_dir = '/opt/rh/mysql51/root/var/run/mysqld/'
when '5.5'
run_dir = '/opt/rh/mysql55/root/var/run/mysqld/'
end
end
run_dir
end
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
pass_string
end
def pid_file
case node['platform_version'].to_i
when 2014, 2013, 7, 6, 5
pid_file = '/var/run/mysqld/mysql.pid'
end
pid_file
end
def socket_file
case node['platform_version'].to_i
when 2014, 2013, 7, 6, 5
socket_file = '/var/lib/mysql/mysql.sock'
end
socket_file
end
def service_name
case node['platform_version'].to_i
when 2014, 2013, 7, 6
service_name = 'mysqld'
when 5
case new_resource.parsed_version
when '5.0'
service_name = 'mysqld'
when '5.1'
service_name = 'mysql51-mysqld'
when '5.5'
service_name = 'mysql55-mysqld'
end
end
service_name
end
end
end
end

View File

@ -0,0 +1,41 @@
module MysqlCookbook
module Helpers
module SmartOS
def include_dir
include_dir = "#{prefix_dir}/etc/mysql/conf.d"
include_dir
end
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open("#{prefix_dir}/etc/.mysql_root").read.chomp if ::File.exist?("#{prefix_dir}/etc/.mysql_root")
pass_string
end
def pid_file
pid_file = '/var/mysql/mysql.pid'
pid_file
end
def prefix_dir
prefix_dir = '/opt/local'
prefix_dir
end
def run_dir
run_dir = '/var/run/mysql'
run_dir
end
def socket_file
socket_file = '/tmp/mysql.sock'
socket_file
end
end
end
end

View File

@ -0,0 +1,16 @@
module MysqlCookbook
module Helpers
module Suse
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
pass_string
end
end
end
end

View File

@ -0,0 +1,41 @@
module MysqlCookbook
module Helpers
module Ubuntu
def include_dir
include_dir = '/etc/mysql/conf.d'
include_dir
end
def pid_file
pid_file = '/var/run/mysqld/mysql.pid'
pid_file
end
def prefix_dir
prefix_dir = '/usr'
prefix_dir
end
def run_dir
run_dir = '/var/run/mysqld'
run_dir
end
def pass_string
if new_resource.parsed_server_root_password.empty?
pass_string = ''
else
pass_string = '-p' + Shellwords.escape(new_resource.parsed_server_root_password)
end
pass_string = '-p' + ::File.open('/etc/.mysql_root').read.chomp if ::File.exist?('/etc/.mysql_root')
pass_string
end
def socket_file
socket_file = '/var/run/mysqld/mysqld.sock'
socket_file
end
end
end
end

View File

@ -0,0 +1,17 @@
if defined?(ChefSpec)
def create_mysql_client(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client, :create, resource_name)
end
def delete_mysql_client(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client, :delete, resource_name)
end
def create_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :create, resource_name)
end
def enable_mysql_service(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :enable, resource_name)
end
end

View File

@ -0,0 +1,31 @@
class Chef
class Provider
class MysqlClient < Chef::Provider::LWRPBase
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :create do
packages.each do |p|
package p do
action :install
end
end
end
action :delete do
packages.each do |p|
package p do
action :remove
end
end
end
def packages
%w()
end
end
end
end

View File

@ -0,0 +1,13 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class Debian < Chef::Provider::MysqlClient
def packages
%w(mysql-client libmysqlclient-dev)
end
end
end
end
end

View File

@ -0,0 +1,13 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class Fedora < Chef::Provider::MysqlClient
def packages
%w(community-mysql community-mysql-devel)
end
end
end
end
end

View File

@ -0,0 +1,13 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class FreeBSD < Chef::Provider::MysqlClient
def packages
%w(mysql55-client)
end
end
end
end
end

View File

@ -0,0 +1,13 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class Omnios < Chef::Provider::MysqlClient
def packages
%w(database/mysql-55 database/mysql-55/library)
end
end
end
end
end

View File

@ -0,0 +1,13 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class Rhel < Chef::Provider::MysqlClient
def packages
%w(mysql mysql-devel)
end
end
end
end
end

View File

@ -0,0 +1,13 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class Smartos < Chef::Provider::MysqlClient
def packages
%w(mysql-client)
end
end
end
end
end

View File

@ -0,0 +1,35 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class Suse < Chef::Provider::MysqlClient
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :create do
converge_by 'suse pattern' do
%w(mysql-client libmysqlclient-devel).each do |p|
package p do
action :install
end
end
end
end
action :delete do
converge_by 'suse pattern' do
%w(mysql-client libmysqlclient-devel).each do |p|
package p do
action :remove
end
end
end
end
end
end
end
end

View File

@ -0,0 +1,13 @@
require 'chef/provider/lwrp_base'
class Chef
class Provider
class MysqlClient
class Ubuntu < Chef::Provider::MysqlClient
def packages
%w(mysql-client-5.5 libmysqlclient-dev)
end
end
end
end
end

View File

@ -0,0 +1,8 @@
class Chef
class Provider
class MysqlService < Chef::Provider::LWRPBase
def action_create
end
end
end
end

View File

@ -0,0 +1,184 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_debian'
class Chef
class Provider
class MysqlService
class Debian < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::Debian
action :create do
package 'debconf-utils' do
action :install
end
directory '/var/cache/local/preseeding' do
owner 'root'
group 'root'
mode '0755'
action :create
recursive true
end
template '/var/cache/local/preseeding/mysql-server.seed' do
cookbook 'mysql'
source 'debian/mysql-server.seed.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[preseed mysql-server]', :immediately
end
execute 'preseed mysql-server' do
command '/usr/bin/debconf-set-selections /var/cache/local/preseeding/mysql-server.seed'
action :nothing
end
# package automatically initializes database and starts service.
# ... because that's totally super convenient.
package new_resource.parsed_package_name do
action :install
end
# service
service 'mysql' do
provider Chef::Provider::Service::Init::Debian
supports :restart => true
action [:start, :enable]
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
template '/etc/mysql_grants.sql' do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]'
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < /etc/mysql_grants.sql"
command cmd
action :nothing
notifies :run, 'execute[create root marker]'
end
template '/etc/mysql/debian.cnf' do
cookbook 'mysql'
source 'debian/debian.cnf.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
end
#
directory include_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
directory run_dir do
owner 'mysql'
group 'mysql'
mode '0755'
action :create
recursive true
end
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
template '/etc/mysql/my.cnf' do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file,
:socket_file => socket_file,
:port => new_resource.parsed_port,
:include_dir => include_dir
)
action :create
notifies :run, 'bash[move mysql data to datadir]'
notifies :restart, 'service[mysql]'
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
service mysql stop \
&& mv /var/lib/mysql/* #{new_resource.parsed_data_dir}
EOH
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
action :nothing
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << ' > /etc/.mysql_root'
cmd << ' ;/bin/chmod 0600 /etc/.mysql_root'
command cmd
action :nothing
end
end
end
action :restart do
service 'mysql' do
provider Chef::Provider::Service::Init::Debian
supports :restart => true
action :restart
end
end
action :reload do
service 'mysql' do
provider Chef::Provider::Service::Init::Debian
action :reload
end
end
end
end
end

View File

@ -0,0 +1,148 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_fedora'
class Chef
class Provider
class MysqlService
class Fedora < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::Fedora
action :create do
package new_resource.parsed_package_name do
action new_resource.parsed_package_action
version new_resource.parsed_package_version
end
directory include_dir do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory run_dir do
owner 'mysql'
group 'mysql'
mode '0755'
action :create
recursive true
end
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0755'
action :create
recursive true
end
service 'mysqld' do
supports :restart => true
action [:start, :enable]
end
execute 'wait for mysql' do
command "until [ -S #{socket_file} ] ; do sleep 1 ; done"
timeout 10
action :run
end
template '/etc/mysql_grants.sql' do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]'
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < /etc/mysql_grants.sql"
command cmd
action :nothing
notifies :run, 'execute[create root marker]'
end
template '/etc/my.cnf' do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:data_dir => new_resource.parsed_data_dir,
:include_dir => include_dir,
:lc_messages_dir => lc_messages_dir,
:pid_file => pid_file,
:port => new_resource.parsed_port,
:prefix_dir => prefix_dir,
:socket_file => socket_file
)
action :create
notifies :run, 'bash[move mysql data to datadir]'
notifies :restart, 'service[mysqld]'
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
service mysqld stop \
&& for i in `ls /var/lib/mysql | grep -v mysql.sock` ; do mv /var/lib/mysql/$i #{new_resource.parsed_data_dir} ; done
EOH
action :nothing
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << ' > /etc/.mysql_root'
cmd << ' ;/bin/chmod 0600 /etc/.mysql_root'
command cmd
action :nothing
end
end
end
action :restart do
service 'mysqld' do
supports :restart => true
action :restart
end
end
action :reload do
service 'mysqld' do
action :reload
end
end
end
end
end

View File

@ -0,0 +1,134 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_debian'
include Opscode::Mysql::Helpers
class Chef
class Provider
class MysqlService
class FreeBSD < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::FreeBSD
action :create do
package new_resource.parsed_package_name do
action :install
end
[include_dir, new_resource.parsed_data_dir].each do |dir|
directory dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
end
template my_cnf do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:base_dir => base_dir,
:include_dir => include_dir,
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file,
:socket_file => socket_file,
:port => new_resource.parsed_port,
:lc_messages_dir => "#{base_dir}/share/mysql"
)
action :create
notifies :restart, 'service[mysql]'
end
execute 'initialize mysql database' do
cwd new_resource.parsed_data_dir
command "#{prefix_dir}/bin/mysql_install_db --basedir=#{base_dir} --user=mysql"
creates "#{new_resource.parsed_data_dir}/mysql/user.frm"
end
service 'mysql' do
service_name rc_name
supports :status => true, :restart => true, :reload => false
action [:start, :enable]
end
execute 'wait for mysql' do
command "while [ ! -S #{socket_file} ] ; do sleep 1 ; done"
timeout 10
action :run
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
template '/etc/mysql_grants.sql' do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group node['root_group']
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]'
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < /etc/mysql_grants.sql"
command cmd
retries 5
retry_delay 2
action :nothing
notifies :run, 'execute[create root marker]'
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << ' > /etc/.mysql_root'
cmd << ' ;/bin/chmod 0600 /etc/.mysql_root'
command cmd
action :nothing
end
end
end
action :restart do
service 'mysql' do
service_name rc_name
supports :restart => true
action :restart
end
end
action :reload do
service 'mysql' do
service_name rc_name
supports :reload => true
action :reload
end
end
end
end
end

View File

@ -0,0 +1,213 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_omnios'
include Opscode::Mysql::Helpers
class Chef
class Provider
class MysqlService
class Omnios < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::OmniOS
action :create do
package new_resource.parsed_package_name do
action :install
end
directory include_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
directory run_dir do
owner 'mysql'
group 'mysql'
mode '0755'
action :create
recursive true
end
# data_dir
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data/mysql" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data/test" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
template my_cnf do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:base_dir => base_dir,
:include_dir => include_dir,
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file,
:socket_file => socket_file,
:port => new_resource.parsed_port,
:lc_messages_dir => "#{base_dir}/share"
)
action :create
notifies :run, 'bash[move mysql data to datadir]'
notifies :restart, 'service[mysql]'
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
/usr/sbin/svcadm disable mysql \
&& mv /var/mysql/* #{new_resource.parsed_data_dir}
EOH
action :nothing
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
end
execute 'initialize mysql database' do
cwd new_resource.parsed_data_dir
command "#{prefix_dir}/scripts/mysql_install_db --basedir=#{base_dir} --user=mysql"
creates "#{new_resource.parsed_data_dir}/mysql/user.frm"
end
template '/lib/svc/method/mysqld' do
cookbook 'mysql'
source 'omnios/svc.method.mysqld.erb'
cookbook 'mysql'
owner 'root'
group 'root'
mode '0555'
variables(
:base_dir => base_dir,
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file
)
action :create
end
template '/tmp/mysql.xml' do
cookbook 'mysql'
source 'omnios/mysql.xml.erb'
owner 'root'
mode '0644'
variables(:version => new_resource.parsed_version)
action :create
notifies :run, 'execute[import mysql manifest]', :immediately
end
execute 'import mysql manifest' do
command 'svccfg import /tmp/mysql.xml'
action :nothing
end
service 'mysql' do
supports :restart => true
action [:start, :enable]
end
execute 'wait for mysql' do
command "until [ -S #{socket_file} ] ; do sleep 1 ; done"
timeout 10
action :run
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
template '/etc/mysql_grants.sql' do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]'
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < /etc/mysql_grants.sql"
command cmd
retries 5
retry_delay 2
action :nothing
notifies :run, 'execute[create root marker]'
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << ' > /etc/.mysql_root'
cmd << ' ;/bin/chmod 0600 /etc/.mysql_root'
command cmd
action :nothing
end
end
action :restart do
service 'mysql' do
supports :restart => true
action :restart
end
end
action :reload do
service 'mysql' do
supports :reload => true
action :reload
end
end
end
end
end
end

View File

@ -0,0 +1,162 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_rhel'
class Chef
class Provider
class MysqlService
class Rhel < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::Rhel
action :create do
# we need to enable the yum-mysql-community repository to get packages
unless node['platform_version'].to_i == 5
case new_resource.parsed_version
when '5.5'
recipe_eval do
run_context.include_recipe 'yum-mysql-community::mysql55'
end
when '5.6'
recipe_eval do
run_context.include_recipe 'yum-mysql-community::mysql56'
end
end
end
package new_resource.parsed_package_name do
action new_resource.parsed_package_action
version new_resource.parsed_package_version
end
directory include_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
directory run_dir do
owner 'mysql'
group 'mysql'
mode '0755'
recursive true
action :create
end
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0755'
recursive true
action :create
end
service service_name do
supports :restart => true
action [:start, :enable]
end
execute 'wait for mysql' do
command "until [ -S #{socket_file} ] ; do sleep 1 ; done"
timeout 10
action :run
end
template '/etc/mysql_grants.sql' do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]'
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < /etc/mysql_grants.sql"
command cmd
action :nothing
notifies :run, 'execute[create root marker]'
end
template "#{base_dir}/etc/my.cnf" do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:base_dir => base_dir,
:data_dir => new_resource.parsed_data_dir,
:include_dir => include_dir,
:lc_messages_dir => lc_messages_dir,
:pid_file => pid_file,
:port => new_resource.parsed_port,
:socket_file => socket_file
)
action :create
notifies :run, 'bash[move mysql data to datadir]'
notifies :restart, "service[#{service_name}]"
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
service #{service_name} stop \
&& for i in `ls #{base_dir}/var/lib/mysql | grep -v mysql.sock` ; do mv #{base_dir}/var/lib/mysql/$i #{new_resource.parsed_data_dir} ; done
EOH
action :nothing
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << ' > /etc/.mysql_root'
cmd << ' ;/bin/chmod 0600 /etc/.mysql_root'
command cmd
action :nothing
end
end
action :restart do
service service_name do
supports :restart => true
action :restart
end
end
action :reload do
service service_name do
action :reload
end
end
end
end
end
end

View File

@ -0,0 +1,208 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_smartos'
class Chef
class Provider
class MysqlService
class Smartos < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::SmartOS
action :create do
package new_resource.parsed_package_name do
version new_resource.parsed_version
action :install
end
directory include_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
directory run_dir do
owner 'mysql'
group 'mysql'
mode '0755'
action :create
recursive true
end
# data_dir
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data/mysql" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
directory "#{new_resource.parsed_data_dir}/data/test" do
owner 'mysql'
group 'mysql'
mode '0750'
action :create
recursive true
end
# FIXME: support user supplied template
template "#{prefix_dir}/etc/my.cnf" do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file,
:socket_file => socket_file,
:port => new_resource.parsed_port,
:include_dir => include_dir
)
action :create
notifies :run, 'bash[move mysql data to datadir]', :immediately
notifies :restart, 'service[mysql]'
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
/usr/sbin/svcadm disable mysql \
&& mv /opt/local/lib/mysql/* #{new_resource.parsed_data_dir}
EOH
action :nothing
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
end
execute 'initialize mysql database' do
cwd new_resource.parsed_data_dir
command "#{prefix_dir}/bin/mysql_install_db --datadir=#{new_resource.parsed_data_dir} --user=mysql"
creates "#{new_resource.parsed_data_dir}/mysql/user.frm"
end
template '/opt/local/lib/svc/method/mysqld' do
cookbook 'mysql'
source 'smartos/svc.method.mysqld.erb'
owner 'root'
group 'root'
mode '0555'
variables(
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file
)
action :create
end
template '/tmp/mysql.xml' do
cookbook 'mysql'
source 'smartos/mysql.xml.erb'
owner 'root'
group 'root'
mode '0644'
variables(:version => new_resource.parsed_version)
action :create
notifies :run, 'execute[import mysql manifest]', :immediately
end
execute 'import mysql manifest' do
command 'svccfg import /tmp/mysql.xml'
action :nothing
end
service 'mysql' do
supports :reload => true
action [:start, :enable]
end
execute 'wait for mysql' do
command "until [ -S #{socket_file} ] ; do sleep 1 ; done"
timeout 10
action :run
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
template "#{prefix_dir}/etc/mysql_grants.sql" do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]', :immediately
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < #{prefix_dir}/etc/mysql_grants.sql"
command cmd
action :nothing
notifies :run, 'execute[create root marker]'
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << " > #{prefix_dir}/etc/.mysql_root"
cmd << " ;/bin/chmod 0600 #{prefix_dir}/etc/.mysql_root"
command cmd
action :nothing
end
end
action :restart do
service 'mysql' do
supports :restart => true
action :restart
end
end
action :reload do
service 'mysql' do
supports :reload => true
action :reload
end
end
end
end
end
end

View File

@ -0,0 +1,169 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers'
require_relative 'helpers_suse'
extend Opscode::Mysql::Helpers
class Chef
class Provider
class MysqlService
class Suse < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::Suse
action :create do
package 'mysql' do
action :install
end
file '/etc/mysqlaccess.conf' do
action :delete
end
file '/etc/mysql/default_plugins.cnf' do
action :delete
end
file '/etc/mysql/secure_file_priv.conf' do
action :delete
end
directory '/etc/mysql/conf.d' do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
directory '/var/run/mysql' do
owner 'mysql'
group 'mysql'
mode '0755'
recursive true
action :create
end
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0755'
recursive true
action :create
end
template '/etc/my.cnf' do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:data_dir => new_resource.parsed_data_dir,
:include_dir => '/etc/mysql/conf.d',
:pid_file => '/var/run/mysql/mysql.pid',
:port => new_resource.parsed_port,
:socket_file => '/var/lib/mysql/mysql.sock'
)
action :create
notifies :run, 'bash[move mysql data to datadir]'
notifies :restart, 'service[mysql]'
end
execute 'initialize mysql database' do
cwd new_resource.parsed_data_dir
command '/usr/bin/mysql_install_db --user=mysql'
creates "#{new_resource.parsed_data_dir}/mysql/user.frm"
action :run
end
service 'mysql' do
supports :restart => true, :reload => true
action [:start, :enable]
notifies :run, 'execute[wait for mysql]', :immediately
end
execute 'wait for mysql' do
command 'until [ -S /var/lib/mysql/mysql.sock ] ; do sleep 1 ; done'
timeout 10
action :nothing
end
template '/etc/mysql_grants.sql' do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]'
end
execute 'install-grants' do
cmd = '/usr/bin/mysql'
cmd << ' -u root '
cmd << "#{pass_string} < /etc/mysql_grants.sql"
command cmd
action :nothing
notifies :run, 'execute[create root marker]'
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
service mysql stop \
&& for i in `ls /var/lib/mysql | grep -v mysql.sock` ; do mv /var/lib/mysql/$i #{new_resource.parsed_data_dir} ; done
EOH
action :nothing
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
end
execute 'assign-root-password' do
cmd = '/usr/bin/mysqladmin'
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "/usr/bin/mysql -u root -e 'show databases;'"
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << ' > /etc/.mysql_root'
cmd << ' ;/bin/chmod 0600 /etc/.mysql_root'
command cmd
action :nothing
end
end
end
action :restart do
service 'mysql' do
supports :restart => true
action :restart
end
end
action :reload do
service 'mysql' do
supports :reload => true
action :reload
end
end
end
end
end

View File

@ -0,0 +1,210 @@
require 'chef/provider/lwrp_base'
require 'shellwords'
require_relative 'helpers_ubuntu'
class Chef
class Provider
class MysqlService
class Ubuntu < Chef::Provider::MysqlService
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
include MysqlCookbook::Helpers::Ubuntu
action :create do
package 'debconf-utils' do
action :install
end
directory '/var/cache/local/preseeding' do
owner 'root'
group 'root'
mode '0755'
action :create
recursive true
end
template '/var/cache/local/preseeding/mysql-server.seed' do
cookbook 'mysql'
source 'debian/mysql-server.seed.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[preseed mysql-server]', :immediately
end
execute 'preseed mysql-server' do
command '/usr/bin/debconf-set-selections /var/cache/local/preseeding/mysql-server.seed'
action :nothing
end
# package automatically initializes database and starts service.
# ... because that's totally super convenient.
package new_resource.parsed_package_name do
action new_resource.parsed_package_action
version new_resource.parsed_package_version
end
# service
service 'mysql' do
provider Chef::Provider::Service::Upstart
supports :restart => true
action [:start, :enable]
end
execute 'assign-root-password' do
cmd = "#{prefix_dir}/bin/mysqladmin"
cmd << ' -u root password '
cmd << Shellwords.escape(new_resource.parsed_server_root_password)
command cmd
action :run
only_if "#{prefix_dir}/bin/mysql -u root -e 'show databases;'"
end
template '/etc/mysql_grants.sql' do
cookbook 'mysql'
source 'grants/grants.sql.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
notifies :run, 'execute[install-grants]'
end
execute 'install-grants' do
cmd = "#{prefix_dir}/bin/mysql"
cmd << ' -u root '
cmd << "#{pass_string} < /etc/mysql_grants.sql"
command cmd
action :nothing
notifies :run, 'execute[create root marker]'
end
# apparmor
directory '/etc/apparmor.d' do
owner 'root'
group 'root'
mode '0755'
action :create
end
template '/etc/apparmor.d/usr.sbin.mysqld' do
cookbook 'mysql'
source 'apparmor/usr.sbin.mysqld.erb'
owner 'root'
group 'root'
mode '0644'
action :create
notifies :reload, 'service[apparmor-mysql]', :immediately
end
service 'apparmor-mysql' do
service_name 'apparmor'
action :nothing
supports :reload => true
end
template '/etc/mysql/debian.cnf' do
cookbook 'mysql'
source 'debian/debian.cnf.erb'
owner 'root'
group 'root'
mode '0600'
variables(:config => new_resource)
action :create
end
#
directory include_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
directory run_dir do
owner 'mysql'
group 'mysql'
mode '0755'
action :create
recursive true
end
directory new_resource.parsed_data_dir do
owner 'mysql'
group 'mysql'
mode '0750'
recursive true
action :create
end
template '/etc/mysql/my.cnf' do
if new_resource.parsed_template_source.nil?
source "#{new_resource.parsed_version}/my.cnf.erb"
cookbook 'mysql'
else
source new_resource.parsed_template_source
end
owner 'mysql'
group 'mysql'
mode '0600'
variables(
:data_dir => new_resource.parsed_data_dir,
:pid_file => pid_file,
:socket_file => socket_file,
:port => new_resource.parsed_port,
:include_dir => include_dir
)
action :create
notifies :run, 'bash[move mysql data to datadir]'
notifies :restart, 'service[mysql]'
end
bash 'move mysql data to datadir' do
user 'root'
code <<-EOH
service mysql stop \
&& mv /var/lib/mysql/* #{new_resource.parsed_data_dir}
EOH
action :nothing
creates "#{new_resource.parsed_data_dir}/ibdata1"
creates "#{new_resource.parsed_data_dir}/ib_logfile0"
creates "#{new_resource.parsed_data_dir}/ib_logfile1"
end
execute 'create root marker' do
cmd = '/bin/echo'
cmd << " '#{Shellwords.escape(new_resource.parsed_server_root_password)}'"
cmd << ' > /etc/.mysql_root'
cmd << ' ;/bin/chmod 0600 /etc/.mysql_root'
command cmd
action :nothing
end
end
end
action :restart do
service 'mysql' do
provider Chef::Provider::Service::Upstart
supports :restart => true
action :restart
end
end
action :reload do
service 'mysql' do
provider Chef::Provider::Service::Upstart
supports :reload => true
action :reload
end
end
end
end
end

View File

@ -0,0 +1,11 @@
require 'chef/resource/lwrp_base'
class Chef
class Resource
class MysqlClient < Chef::Resource::LWRPBase
self.resource_name = :mysql_client
actions :create, :delete
default_action :create
end
end
end

View File

@ -0,0 +1,136 @@
require 'chef/resource/lwrp_base'
require_relative 'helpers'
class Chef
class Resource
class MysqlService < Chef::Resource::LWRPBase
self.resource_name = :mysql_service
actions :create, :restart, :reload
default_action :create
attribute :allow_remote_root, :kind_of => [TrueClass, FalseClass], :default => false
attribute :data_dir, :kind_of => String, :default => nil
attribute :package_name, :kind_of => String, :default => nil
attribute :port, :kind_of => String, :default => '3306'
attribute :remove_anonymous_users, :kind_of => [TrueClass, FalseClass], :default => true
attribute :remove_test_database, :kind_of => [TrueClass, FalseClass], :default => true
attribute :root_network_acl, :kind_of => Array, :default => []
attribute :server_debian_password, :kind_of => String, :default => 'gnuslashlinux4ev4r'
attribute :server_repl_password, :kind_of => String, :default => nil
attribute :server_root_password, :kind_of => String, :default => 'ilikerandompasswords'
attribute :service_name, :kind_of => String, :name_attribute => true
attribute :template_source, :kind_of => String, :default => nil
attribute :version, :kind_of => String, :default => nil
attribute :package_version, :kind_of => String, :default => nil
attribute :package_action, :kind_of => String, :default => nil
end
include Opscode::Mysql::Helpers
def parsed_allow_remote_root
return allow_remote_root unless allow_remote_root.nil?
end
def parsed_data_dir
return data_dir if data_dir
case node['platform_family']
when 'rhel', 'fedora', 'suse', 'debian', 'omnios'
data_dir = '/var/lib/mysql'
when 'smartos'
data_dir = '/opt/local/lib/mysql'
when 'freebsd'
data_dir = '/var/db/mysql'
end
data_dir
end
def parsed_package_name
return package_name if package_name
package_name_for(
node['platform'],
node['platform_family'],
node['platform_version'],
parsed_version
)
end
def parsed_package_version
return package_version if package_version
end
def parsed_package_action
return package_action if package_action
end
def parsed_port
return port if port
end
def parsed_remove_anonymous_users
return remove_anonymous_users unless remove_anonymous_users.nil?
end
def parsed_remove_test_database
return remove_test_database unless remove_test_database.nil?
end
def parsed_root_network_acl
return root_network_acl if root_network_acl
end
def parsed_server_debian_password
return server_debian_password if server_debian_password
end
def parsed_server_repl_password
return server_repl_password if server_repl_password
end
def parsed_server_root_password
return server_root_password if server_root_password
end
def parsed_service_name
return service_name if service_name
end
def parsed_template_source
return template_source if template_source
end
def parsed_version
return version if version
case node['platform_family']
when 'rhel'
case node['platform_version'].to_i
when 5
default_version = '5.0'
when 2013, 6
default_version = '5.1'
when 2014, 7
default_version = '5.5'
end
when 'fedora'
default_version = '5.5'
when 'suse'
default_version = '5.5'
when 'debian'
return '5.1' if node['platform_version'].to_i == 6
return '5.5' if node['platform_version'].to_i == 7
case node['platform_version']
when 'jessie/sid', '12.04', '13.04', '13.10', '14.04'
default_version = '5.5'
when '10.04'
default_version = '5.1'
end
when 'smartos'
default_version = '5.5'
when 'omnios'
default_version = '5.5'
when 'freebsd'
default_version = '5.5'
end
default_version
end
end
end

View File

@ -0,0 +1,30 @@
# provider mappings
# client
Chef::Platform.set :platform => :debian, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Debian
Chef::Platform.set :platform => :fedora, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Fedora
Chef::Platform.set :platform => :freebsd, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::FreeBSD
Chef::Platform.set :platform => :omnios, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Omnios
Chef::Platform.set :platform => :rhel, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :amazon, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :redhat, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :centos, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :oracle, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :scientific, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Rhel
Chef::Platform.set :platform => :smartos, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Smartos
Chef::Platform.set :platform => :suse, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Suse
Chef::Platform.set :platform => :ubuntu, :resource => :mysql_client, :provider => Chef::Provider::MysqlClient::Ubuntu
# service
Chef::Platform.set :platform => :debian, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Debian
Chef::Platform.set :platform => :fedora, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Fedora
Chef::Platform.set :platform => :freebsd, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::FreeBSD
Chef::Platform.set :platform => :omnios, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Omnios
Chef::Platform.set :platform => :amazon, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :redhat, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :centos, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :oracle, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :scientific, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Rhel
Chef::Platform.set :platform => :smartos, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Smartos
Chef::Platform.set :platform => :suse, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Suse
Chef::Platform.set :platform => :ubuntu, :resource => :mysql_service, :provider => Chef::Provider::MysqlService::Ubuntu

View File

@ -0,0 +1,41 @@
{
"name": "mysql",
"version": "5.5.3",
"description": "Provides mysql_service and mysql_client resources",
"long_description": "",
"maintainer": "Chef Software, Inc.",
"maintainer_email": "cookbooks@getchef.com",
"license": "Apache 2.0",
"platforms": {
"amazon": ">= 0.0.0",
"redhat": ">= 0.0.0",
"centos": ">= 0.0.0",
"scientific": ">= 0.0.0",
"fedora": ">= 0.0.0",
"debian": ">= 0.0.0",
"ubuntu": ">= 0.0.0",
"smartos": ">= 0.0.0",
"omnios": ">= 0.0.0",
"freebsd": ">= 0.0.0",
"suse": ">= 0.0.0"
},
"dependencies": {
"yum-mysql-community": ">= 0.0.0"
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"attributes": {
},
"groupings": {
},
"recipes": {
}
}

View File

@ -0,0 +1,21 @@
name 'mysql'
maintainer 'Chef Software, Inc.'
maintainer_email 'cookbooks@getchef.com'
license 'Apache 2.0'
description 'Provides mysql_service and mysql_client resources'
version '5.5.3'
supports 'amazon'
supports 'redhat'
supports 'centos'
supports 'scientific'
supports 'fedora'
supports 'debian'
supports 'ubuntu'
supports 'smartos'
supports 'omnios'
supports 'freebsd'
supports 'suse'
depends 'yum-mysql-community'

View File

@ -0,0 +1,22 @@
#
# Cookbook Name:: mysql
# Recipe:: client
#
# Copyright 2008-2013, Chef Software, 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.
#
mysql_client 'default' do
action :create
end

View File

@ -0,0 +1,34 @@
#
# Cookbook Name:: mysql
# Recipe:: server
#
# Copyright 2008-2013, Chef Software, 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.
#
mysql_service node['mysql']['service_name'] do
version node['mysql']['version']
port node['mysql']['port']
data_dir node['mysql']['data_dir']
server_root_password node['mysql']['server_root_password']
server_debian_password node['mysql']['server_debian_password']
server_repl_password node['mysql']['server_repl_password']
allow_remote_root node['mysql']['allow_remote_root']
remove_anonymous_users node['mysql']['remove_anonymous_users']
remove_test_database node['mysql']['remove_test_database']
root_network_acl node['mysql']['root_network_acl']
package_version node['mysql']['server_package_version']
package_action node['mysql']['server_package_action']
action :create
end

View File

@ -0,0 +1,23 @@
# Mysql Cookbook
# mysql::server_deprecated
#
# Copyright 2008-2013, Chef Software, 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.
#
mysql_service node['mysql']['service_name'] do
port node['mysql']['port']
data_dir node['mysql']['data_dir']
template_source 'deprecated/my.cnf.erb'
end

View File

@ -0,0 +1,38 @@
[client]
<% if @port %>
port = <%= @port %>
<% end %>
<% if @socket_file %>
socket = <%= @socket_file %>
<% end %>
[mysqld_safe]
socket = <%= @socket_file %>
<% if @nice %>
nice = 0
<% end %>
[mysqld]
user = mysql
pid-file = <%= @pid_file %>
socket = <%= @socket_file %>
<% if @port %>
port = <%= @port %>
<% end %>
<% if @basedir %>
basedir = <%= @base_dir %>
<% end %>
<% if @data_dir %>
datadir = <%= @data_dir %>
<% end %>
<% if @tmpdir %>
tmpdir = /tmp
<% end %>
<% if @lc_messages_dir %>
lc-messages-dir = <%= @lc_messages_dir %>
<% end %>
[mysql]
<% if @include_dir %>
!includedir <%= @include_dir %>
<% end %>

View File

@ -0,0 +1,38 @@
[client]
<% if @port %>
port = <%= @port %>
<% end %>
<% if @socket_file %>
socket = <%= @socket_file %>
<% end %>
[mysqld_safe]
socket = <%= @socket_file %>
<% if @nice %>
nice = 0
<% end %>
[mysqld]
user = mysql
pid-file = <%= @pid_file %>
socket = <%= @socket_file %>
<% if @port %>
port = <%= @port %>
<% end %>
<% if @basedir %>
basedir = <%= @base_dir %>
<% end %>
<% if @data_dir %>
datadir = <%= @data_dir %>
<% end %>
<% if @tmpdir %>
tmpdir = /tmp
<% end %>
<% if @lc_messages_dir %>
lc-messages-dir = <%= @lc_messages_dir %>
<% end %>
[mysql]
<% if @include_dir %>
!includedir <%= @include_dir %>
<% end %>

View File

@ -0,0 +1,38 @@
[client]
<% if @port %>
port = <%= @port %>
<% end %>
<% if @socket_file %>
socket = <%= @socket_file %>
<% end %>
[mysqld_safe]
socket = <%= @socket_file %>
<% if @nice %>
nice = 0
<% end %>
[mysqld]
user = mysql
pid-file = <%= @pid_file %>
socket = <%= @socket_file %>
<% if @port %>
port = <%= @port %>
<% end %>
<% if @basedir %>
basedir = <%= @base_dir %>
<% end %>
<% if @data_dir %>
datadir = <%= @data_dir %>
<% end %>
<% if @tmpdir %>
tmpdir = /tmp
<% end %>
<% if @lc_messages_dir %>
lc-messages-dir = <%= @lc_messages_dir %>
<% end %>
[mysql]
<% if @include_dir %>
!includedir <%= @include_dir %>
<% end %>

View File

@ -0,0 +1,39 @@
[client]
<% if @port %>
port = <%= @port %>
<% end %>
<% if @socket %>
socket = <%= @socket_file %>
<% end %>
[mysqld_safe]
socket = <%= @socket_file %>
<% if @nice %>
nice = 0
<% end %>
[mysqld]
user = mysql
pid-file = <%= @pid_file %>
socket = <%= @socket_file %>
<% if @port %>
port = <%= @port %>
<% end %>
<% if @basedir %>
basedir = <%= @base_dir %>
<% end %>
<% if @data_dir %>
datadir = <%= @data_dir %>
<% end %>
<% if @tmpdir %>
tmpdir = /tmp
<% end %>
<% if @lc_messages_dir %>
lc-messages-dir = <%= @lc_messages_dir %>
<% end %>
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysql]
<% if @include_dir %>
!includedir <%= @include_dir %>
<% end %>

View File

@ -0,0 +1,41 @@
# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>
/usr/sbin/mysqld flags=(complain) {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/user-tmp>
#include <abstractions/mysql>
#include <abstractions/winbind>
capability dac_override,
capability sys_resource,
capability setgid,
capability setuid,
network tcp,
/etc/hosts.allow r,
/etc/hosts.deny r,
/etc/mysql/*.pem r,
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
/etc/mysql/my.cnf r,
/usr/lib/mysql/plugin/ r,
/usr/lib/mysql/plugin/*.so* mr,
/usr/sbin/mysqld mr,
/usr/share/mysql/** r,
/var/log/mysql.log rw,
/var/log/mysql.err rw,
/var/lib/mysql/ r,
<%= node['mysql']['data_dir'] %>/ r,
<%= node['mysql']['data_dir'] %>/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
/var/run/mysqld/mysqld.pid w,
/var/run/mysqld/mysqld.sock w,
/sys/devices/system/cpu/ r,
}

View File

@ -0,0 +1,12 @@
[client]
host = localhost
user = debian-sys-maint
password = <%= @config.server_debian_password %>
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = <%= @config.server_debian_password %>
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

View File

@ -0,0 +1,10 @@
mysql-server-5.5 mysql-server/root_password_again select <%= @config.server_root_password %>
mysql-server-5.5 mysql-server/root_password select <%= @config.server_root_password %>
mysql-server-5.5 mysql-server-5.5/really_downgrade boolean false
mysql-server-5.5 mysql-server-5.5/need_sarge_compat boolean false
mysql-server-5.5 mysql-server-5.5/start_on_boot boolean false
mysql-server-5.5 mysql-server/error_setting_password boolean false
mysql-server-5.5 mysql-server-5.5/nis_warning note
mysql-server-5.5 mysql-server-5.5/postrm_remove_databases boolean false
mysql-server-5.5 mysql-server/password_mismatch boolean false
mysql-server-5.5 mysql-server-5.5/need_sarge_compat_done boolean true

View File

@ -0,0 +1,374 @@
#
# Generated by Chef for <%= node['hostname'] %>
#
# Local modifications will be overwritten.
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = <%= node['mysql']['port'] %>
socket = <%= node['mysql']['server']['socket'] %>
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = <%= node['mysql']['server']['socket'] %>
nice = <%= node['mysql']['nice'] %>
[mysqld]
#
# * Basic Settings
#
#
# * IMPORTANT
# If you make changes to these settings and your system uses apparmor, you may
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#
user = mysql
pid-file = <%= node['mysql']['server']['pid_file'] %>
socket = <%= node['mysql']['server']['socket'] %>
port = <%= node['mysql']['port'] %>
basedir = <%= node['mysql']['server']['basedir'] %>
datadir = <%= node['mysql']['data_dir'] %>
tmpdir = <%= node['mysql']['server']['tmpdir'].join(':') %>
skip-external-locking
<%- if node['mysql']['tunable']['skip-name-resolve'] %>
skip-name-resolve
<%- end %>
# Charset and Collation
character-set-server = <%= node['mysql']['tunable']['character-set-server'] %>
collation-server = <%= node['mysql']['tunable']['collation-server'] %>
<%- if node['mysql']['tunable']['lower_case_table_names'] %>
lower_case_table_names = <%= node['mysql']['tunable']['lower_case_table_names'] %>
<%- end %>
<%- if node['mysql']['tunable']['event_scheduler'] %>
event_scheduler = <%= node['mysql']['tunable']['event_scheduler'] %>
<%- end %>
<%- if node['mysql']['tunable']['skip-character-set-client-handshake'] %>
skip-character-set-client-handshake
<%- end %>
<%- if (node['mysql']['tunable']['lc_messages_dir'] && node['mysql']['tunable']['lc_messages']) %>
lc_messages_dir = <%= node['mysql']['lc_messages_dir'] %>
lc_messages = <%= node['mysql']['lc_messages'] %>
<%- elsif (node['mysql']['tunable']['languages']) %>
languages = <%= node['mysql']['tunable']['languages'] %>
<%- end %>
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = <%= node['mysql']['bind_address'] %>
#
# * Fine Tuning
#
key_buffer_size = <%= node['mysql']['tunable']['key_buffer_size'] %>
max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
thread_stack = <%= node['mysql']['tunable']['thread_stack'] %>
thread_cache_size = <%= node['mysql']['tunable']['thread_cache_size'] %>
sort_buffer_size = <%= node['mysql']['tunable']['sort_buffer_size'] %>
read_buffer_size = <%= node['mysql']['tunable']['read_buffer_size'] %>
read_rnd_buffer_size = <%= node['mysql']['tunable']['read_rnd_buffer_size'] %>
join_buffer_size = <%= node['mysql']['tunable']['join_buffer_size'] %>
auto-increment-increment = <%= node['mysql']['auto-increment-increment'] %>
auto-increment-offset = <%= node['mysql']['auto-increment-offset'] %>
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = <%= node['mysql']['tunable']['myisam-recover'] %>
max_connections = <%= node['mysql']['tunable']['max_connections'] %>
max_connect_errors = <%= node['mysql']['tunable']['max_connect_errors'] %>
concurrent_insert = <%= node['mysql']['tunable']['concurrent_insert'] %>
connect_timeout = <%= node['mysql']['tunable']['connect_timeout'] %>
wait_timeout = <%= node['mysql']['tunable']['wait_timeout'] %>
net_read_timeout = <%= node['mysql']['tunable']['net_read_timeout'] %>
net_write_timeout = <%= node['mysql']['tunable']['net_write_timeout'] %>
back_log = <%= node['mysql']['tunable']['back_log'] %>
<%- if node['mysql']['version'].to_f >= 5.6 %>
table_open_cache = <%= node['mysql']['tunable']['table_open_cache'] %>
<%- else %>
table_cache = <%= node['mysql']['tunable']['table_open_cache'] %>
<%- end %>
tmp_table_size = <%= node['mysql']['tunable']['tmp_table_size'] %>
max_heap_table_size = <%= node['mysql']['tunable']['max_heap_table_size'] %>
bulk_insert_buffer_size = <%= node['mysql']['tunable']['bulk_insert_buffer_size'] %>
open-files-limit = <%= node['mysql']['tunable']['open-files-limit'] %>
# Default Table Settings
<%- if node['mysql']['tunable']['sql_mode'] %>
sql_mode = "<%= node['mysql']['tunable']['sql_mode'] %>"
<%- end %>
#
# * Query Cache Configuration
#
query_cache_limit = <%= node['mysql']['tunable']['query_cache_limit'] %>
query_cache_size = <%= node['mysql']['tunable']['query_cache_size'] %>
#
# * Logging
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
#log = /var/log/mysql/mysql.log
#
# Error logging goes to syslog. This is a Debian improvement :)
<%- if node['mysql']['tunable']['log_error'] %>
log_error = <%= node['mysql']['tunable']['log_error'] %>
<%- end %>
<%- if node['mysql']['tunable']['log_warnings'] %>
log_warnings
<%- end %>
#
# * Replication
#
#
# Here you can see queries with especially long duration
<%- if node['mysql']['server']['slow_query_log'] %>
slow_query_log = 1
slow_query_log_file = <%= node['mysql']['server']['slow_query_log_file'] %>
<%- else %>
log_slow_queries = <%= node['mysql']['server']['log_slow_queries'] %>
<%- end %>
long_query_time = <%= node['mysql']['tunable']['long_query_time'] %>
<%- if node['mysql']['tunable']['log_queries_not_using_index'] and node['mysql']['tunable']['slow_query_log'] %>
log-queries-not-using-indexes
<%- end %>
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
<%- if node['mysql']['tunable']['server_id'] %>
server-id = <%= node['mysql']['tunable']['server_id'] %>
<% end %>
<%- if node['mysql']['tunable']['log_bin'] %>
log_bin = <%= node['mysql']['tunable']['log_bin'] %>
binlog_format = <%= node['mysql']['tunable']['binlog_format'] %>
log_slave_updates = <%= node['mysql']['tunable']['log_slave_updates'] %>
<%- end %>
<%- if node['mysql']['tunable']['log_bin_trust_function_creators'] %>
log_bin_trust_function_creators
<%- end %>
expire_logs_days = <%= node['mysql']['tunable']['expire_logs_days'] %>
max_binlog_size = <%= node['mysql']['tunable']['max_binlog_size'] %>
binlog_cache_size = <%= node['mysql']['tunable']['binlog_cache_size'] %>
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
<%- if node['mysql']['tunable']['relay_log'] %>
relay_log = <%= node['mysql']['tunable']['relay_log'] %>
<%- end %>
<%- if node['mysql']['tunable']['relay_log_index'] %>
relay_log_index = <%= node['mysql']['tunable']['relay_log_index'] %>
<%- end %>
<%- if node['mysql']['tunable']['replicate_do_db'] %>
replicate_do_db = <%= node['mysql']['tunable']['replicate_do_db'] %>
<%- end %>
<%- if node['mysql']['tunable']['replicate_do_table'] %>
replicate_do_table = <%= node['mysql']['tunable']['replicate_do_table'] %>
<%- end %>
<%- if node['mysql']['tunable']['replicate_ignore_db'] %>
replicate_ignore_db = <%= node['mysql']['tunable']['replicate_ignore_db'] %>
<%- end %>
<%- if node['mysql']['tunable']['replicate_ignore_table'] %>
replicate_ignore_table = <%= node['mysql']['tunable']['replicate_ignore_table'] %>
<%- end %>
<%- if node['mysql']['tunable']['replicate_wild_do_table'] %>
replicate_wild_do_table = <%= node['mysql']['tunable']['replicate_wild_do_table'] %>
<%- end %>
<%- if node['mysql']['tunable']['replicate_wild_ignore_table'] %>
replicate_wild_ignore_table = <%= node['mysql']['tunable']['replicate_wild_ignore_table'] %>
<%- end %>
sync_binlog = <%= node['mysql']['tunable']['sync_binlog'] %>
<%- if node['mysql']['tunable']['skip_slave_start'] %>
skip_slave_start
<%- end %>
<%- if node['mysql']['tunable']['read_only'] %>
read_only = 1
<%- end %>
<%- if node['mysql']['tunable']['transaction-isolation'] %>
transaction-isolation = <%= node['mysql']['tunable']['transaction-isolation'] %>
<%- end %>
<%- if node['mysql']['tunable']['slave_compressed_protocol'] %>
slave_compressed_protocol = <%= node['mysql']['tunable']['slave_compressed_protocol'] %>
<%- end %>
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
#skip-innodb
<%- if node["mysql"]["version"].to_f >= 5.5 %>
innodb_write_io_threads = <%= node['mysql']['tunable']['innodb_write_io_threads'] %>
innodb_io_capacity = <%= node['mysql']['tunable']['innodb_io_capacity'] %>
innodb_read_io_threads = <%= node['mysql']['tunable']['innodb_read_io_threads'] %>
innodb_buffer_pool_instances = <%= node['mysql']['tunable']['innodb_buffer_pool_instances'] %>
<%- end %>
## InnoDB Plugin Independent Settings
innodb_data_home_dir = <%= node['mysql']['data_dir'] %>
innodb_log_group_home_dir = <%= node['mysql']['server']['directories']['log_dir'] %>
<%- if node['mysql']['log_files_in_group'] %>
innodb_log_files_in_group = <%= node['mysql']['log_files_in_group'] %>
<%- end %>
<%- if node['mysql']['innodb_status_file'] %>
innodb_status_file
<%- end %>
<%- if node['mysql']['tunable']['innodb_file_per_table'] %>
innodb_file_per_table
<%- end %>
innodb_table_locks = <%= node['mysql']['tunable']['innodb_table_locks'] %>
innodb_lock_wait_timeout = <%= node['mysql']['tunable']['innodb_lock_wait_timeout'] %>
<%- if node['mysql']['tunable']['innodb_rollback_on_timeout'] %>
innodb_rollback_on_timeout
<%- end %>
innodb_thread_concurrency = <%= node['mysql']['tunable']['innodb_thread_concurrency'] %>
innodb_commit_concurrency = <%= node['mysql']['tunable']['innodb_commit_concurrency'] %>
innodb_support_xa = <%= node['mysql']['tunable']['innodb_support_xa'] %>
<%- if node['mysql']['tunable']['skip-innodb-doublewrite'] %>
skip-innodb-doublewrite
<%- end %>
innodb_buffer_pool_size = <%= node['mysql']['tunable']['innodb_buffer_pool_size'] %>
innodb_log_file_size = <%= node['mysql']['tunable']['innodb_log_file_size'] %>
innodb_additional_mem_pool_size = <%= node['mysql']['tunable']['innodb_additional_mem_pool_size'] %>
innodb_data_file_path = <%= node['mysql']['tunable']['innodb_data_file_path'] %>
innodb_flush_log_at_trx_commit = <%= node['mysql']['tunable']['innodb_flush_log_at_trx_commit'] %>
<%- if node['mysql']['tunable']['innodb_flush_method'] %>
innodb_flush_method = <%= node['mysql']['tunable']['innodb_flush_method'] %>
<%- end %>
innodb_log_buffer_size = <%= node['mysql']['tunable']['innodb_log_buffer_size'] %>
<%- if node['mysql']['tunable']['innodb_adaptive_flushing'] %>
innodb_adaptive_flushing = <%= node['mysql']['tunable']['innodb_adaptive_flushing'] %>
<%- end %>
<%- if node['mysql']['tunable']['innodb_adaptive_flushing_method'] %>
innodb_adaptive_flushing_method = <%= node['mysql']['tunable']['innodb_adaptive_flushing_method'] %>
<%- end %>
<%- if node['mysql']['tunable']['innodb_adaptive_checkpoint'] %>
innodb_adaptive_checkpoint = <%= node['mysql']['tunable']['innodb_adaptive_checkpoint'] %>
<%- end %>
<% if node['mysql']['server']['skip_federated'] %>
#
# * Federated
#
# The FEDERATED storage engine is disabled since 5.0.67 by default in the .cnf files
# shipped with MySQL distributions (my-huge.cnf, my-medium.cnf, and so forth).
#
skip-federated
<% end %>
#
# * Security Features
#
# Read the manual, too, if you want chroot!
<% if node['mysql']['security']['chroot'] -%>
chroot = <%= node['mysql']['security']['chroot'] %>
<% end %>
<% if node['mysql']['security']['safe_user_create'] -%>
safe-user-create = <%= node['mysql']['security']['safe_user_create'] %>
<% end %>
<% if node['mysql']['security']['secure_auth'] -%>
secure-auth = <%= node['mysql']['security']['secure_auth'] %>
<% end %>
<% if node['mysql']['security']['skip_symbolic_links'] -%>
skip-symbolic-links = <%= node['mysql']['security']['skip_symbolic_links'] %>
<% end %>
<% if node['mysql']['security']['secure_file_priv'] -%>
secure-file-priv = <%= node['mysql']['security']['secure_file_priv'] %>
<% end %>
<% if node['mysql']['security']['local_infile'] -%>
local-infile = <%= node['mysql']['security']['local_infile'] %>
<% end %>
<% if node['mysql']['security']['skip_show_database'] -%>
skip-show-database
<% end %>
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
quote-names
max_allowed_packet = <%= node['mysql']['tunable']['max_allowed_packet'] %>
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[myisamchk]
key_buffer = <%= node['mysql']['tunable']['max_allowed_packet'] %>
myisam_sort_buffer_size = <%= node['mysql']['tunable']['myisam_sort_buffer_size'] %>
myisam_max_sort_file_size = <%= node['mysql']['tunable']['myisam_max_sort_file_size'] %>
myisam_repair_threads = <%= node['mysql']['tunable']['myisam_repair_threads'] %>
myisam-recover = <%= node['mysql']['tunable']['myisam-recover'] %>
#
# * NDB Cluster
#
# See /usr/share/doc/mysql-server-*/README.Debian for more information.
#
# The following configuration is read by the NDB Data Nodes (ndbd processes)
# not from the NDB Management Nodes (ndb_mgmd processes).
#
# [MYSQL_CLUSTER]
# ndb-connectstring=127.0.0.1
<% case node['platform_family'] -%>
<% when "rhel", "fedora", "suse" -%>
#
# * BerkeleyDB
#
# Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
skip-bdb
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords = <%= node['mysql']['old_passwords'] %>
<% end -%>
<% if node['mysql']['server']['directories']['confd_dir'] -%>
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir <%= node['mysql']['server']['directories']['confd_dir'] %>/
<% end -%>

View File

@ -0,0 +1,27 @@
<% case node['platform_family'] -%>
<% when 'debian' -%>
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<%= @config.server_debian_password %>' WITH GRANT OPTION;
<% end %>
<% if @config.server_repl_password -%>
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' identified by '<%= @config.server_repl_password %>';
<% end %>
<% if @config.allow_remote_root -%>
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '<%= @config.server_root_password %>' WITH GRANT OPTION;
<% else %>
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
UPDATE mysql.user SET Password=PASSWORD('<%= @config.server_root_password %>') WHERE User='root';
<% end %>
<% if @config.remove_anonymous_users -%>
DELETE FROM mysql.user WHERE User='';
<% end %>
<% if @config.remove_test_database -%>
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';
<% end %>
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('<%= @config.server_root_password %>');
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('<%= @config.server_root_password %>');
<% if @config.root_network_acl.each -%>
<% @config.root_network_acl.each do |acl| -%>
GRANT ALL PRIVILEGES ON *.* TO 'root'@'<%= acl %>' IDENTIFIED BY '<%= @config.server_root_password %>' WITH GRANT OPTION;
<% end %>
<% end %>

View File

@ -0,0 +1,26 @@
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='database/mysql' type='service' version='0'>
<create_default_instance enabled='true'/>
<single_instance/>
<dependency name='fs' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<dependency name='net' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/network/loopback'/>
</dependency>
<exec_method name='start' type='method' exec='/lib/svc/method/mysqld start' timeout_seconds='18446744073709551615'/>
<exec_method name='stop' type='method' exec='/lib/svc/method/mysqld stop' timeout_seconds='18446744073709551615'/>
<stability value='Evolving'/>
<template>
<common_name>
<loctext xml:lang='C'>MySQL RDBMS</loctext>
</common_name>
<documentation>
<manpage title='MySQL <%= @version %>' section='1'/>
<doc_link name='mysql.com' uri='http://dev.mysql.com/docs'/>
</documentation>
</template>
</service>
</service_bundle>

View File

@ -0,0 +1,29 @@
#!/sbin/sh
#
# Generated by Chef
#
. /lib/svc/share/smf_include.sh
PIDFILE=<%= @pid_file %>
ulimit -n 10240
case "$1" in
start)
<%= @base_dir %>/bin/mysqld --user=mysql \
--basedir=<%= @base_dir %> \
--datadir=<%= @data_dir %> \
--pid-file=${PIDFILE} \
--log-error=/var/log/mysql/error.log &
;;
stop)
[ -f ${PIDFILE} ] && kill `/usr/bin/head -1 ${PIDFILE}`
;;
*)
echo "Usage: $0 {start|stop}" >&2
exit 1
;;
esac
exit $SMF_EXIT_OK

View File

@ -0,0 +1,32 @@
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='pkgsrc/mysql' type='service' version='0'>
<create_default_instance enabled='true'/>
<single_instance/>
<dependency name='fs' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<dependency name='net' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/network/loopback'/>
</dependency>
<method_context project='mysql' working_directory='/var/mysql'>
<method_credential group='mysql' user='mysql'/>
<method_environment>
<envvar name='LD_PRELOAD_32' value='/usr/lib/extendedFILE.so.1'/>
</method_environment>
</method_context>
<exec_method name='start' type='method' exec='/opt/local/lib/svc/method/mysqld start' timeout_seconds='18446744073709551615'/>
<exec_method name='stop' type='method' exec='/opt/local/lib/svc/method/mysqld stop' timeout_seconds='18446744073709551615'/>
<stability value='Evolving'/>
<template>
<common_name>
<loctext xml:lang='C'>MySQL RDBMS</loctext>
</common_name>
<documentation>
<manpage title='MySQL <%= @version %>' section='1'/>
<doc_link name='mysql.com' uri='http://dev.mysql.com/docs'/>
</documentation>
</template>
</service>
</service_bundle>

View File

@ -0,0 +1,29 @@
#!/sbin/sh
#
# Generated by Chef
#
. /lib/svc/share/smf_include.sh
PIDFILE="/var/mysql/mysql.pid"
ulimit -n 10240
case "$1" in
start)
/opt/local/sbin/mysqld --user=mysql \
--basedir=/opt/local \
--datadir=<%= @data_dir %> \
--pid-file=${PIDFILE} \
--log-error=/var/log/mysql/error.log &
;;
stop)
[ -f ${PIDFILE} ] && kill `/usr/bin/head -1 ${PIDFILE}`
;;
*)
echo "Usage: $0 {start|stop}" >&2
exit 1
;;
esac
exit $SMF_EXIT_OK

10
chef/cookbooks/nmap/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.vagrant
Berksfile.lock
Gemfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
/cookbooks

View File

@ -0,0 +1,3 @@
site :opscode
metadata

View File

@ -0,0 +1,4 @@
source :rubygems
gem 'berkshelf'
gem 'vagrant', '~> 1.0.5'

View File

@ -0,0 +1,3 @@
Copyright (C) 2012 YOUR_NAME
All rights reserved - Do Not Redistribute

View File

@ -0,0 +1,16 @@
# nmap cookbook
# Requirements
Chef 10.16.2 or above
# Usage
simply include 'recipe[nmap]' in a node's run_list
# Attributes
# Recipes
default.rb : installs the nmap package
# Author
Author:: Sean OMeara (<someara@opscode.com>)

64
chef/cookbooks/nmap/Vagrantfile vendored Normal file
View File

@ -0,0 +1,64 @@
require 'berkshelf/vagrant'
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# The path to the Berksfile to use with Vagrant Berkshelf
# config.berkshelf.berksfile_path = "./Berksfile"
# An array of symbols representing groups of cookbook described in the Vagrantfile
# to skip installing and copying to Vagrant's shelf.
# config.berkshelf.only = []
# An array of symbols representing groups of cookbook described in the Vagrantfile
# to skip installing and copying to Vagrant's shelf.
# config.berkshelf.except = []
config.vm.host_name = "nmap-berkshelf"
config.vm.box = "Berkshelf-CentOS-6.3-x86_64-minimal"
config.vm.box_url = "https://dl.dropbox.com/u/31081437/Berkshelf-CentOS-6.3-x86_64-minimal.box"
# Boot with a GUI so you can see the screen. (Default is headless)
# config.vm.boot_mode = :gui
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
config.vm.network :hostonly, "33.33.33.10"
# Assign this VM to a bridged network, allowing you to connect directly to a
# network using the host's network device. This makes the VM appear as another
# physical device on your network.
# config.vm.network :bridged
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
# config.vm.forward_port 80, 8080
# Share an additional folder to the guest VM. The first argument is
# an identifier, the second is the path on the guest to mount the
# folder, and the third is the path on the host to the actual folder.
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
config.ssh.max_tries = 40
config.ssh.timeout = 120
config.vm.provision :chef_solo do |chef|
chef.json = {
:mysql => {
:server_root_password => 'rootpass',
:server_debian_password => 'debpass',
:server_repl_password => 'replpass'
}
}
chef.run_list = [
"recipe[nmap::default]"
]
end
end

View File

@ -0,0 +1,52 @@
# Put files/directories that should be ignored in this file.
# Lines that start with '# ' are comments.
## OS
.DS_Store
Icon?
nohup.out
## EDITORS
\#*
.#*
*~
*.sw[a-z]
*.bak
REVISION
TAGS*
tmtags
*_flymake.*
*_flymake
*.tmproj
.project
.settings
mkmf.log
## COMPILED
a.out
*.o
*.pyc
*.so
## OTHER SCM
*/.bzr/*
*/.hg/*
*/.svn/*
## Don't send rspecs up in cookbook
.watchr
.rspec
spec/*
spec/fixtures/*
features/*
## SCM
.gitignore
# Berkshelf
Berksfile
Berksfile.lock
cookbooks/*
# Vagrant
.vagrant

Some files were not shown because too many files have changed in this diff Show More