Initial Chef repository
This commit is contained in:
26
cookbooks/mysql2_chef_gem/CHANGELOG.md
Normal file
26
cookbooks/mysql2_chef_gem/CHANGELOG.md
Normal file
@@ -0,0 +1,26 @@
|
||||
mysql2_chef_gem CHANGELOG
|
||||
========================
|
||||
|
||||
1.0.1 (2014-12-25)
|
||||
------------------
|
||||
- Moving from recipe_eval in to include_recipe LWRP
|
||||
|
||||
1.0.0 (2014-12-23)
|
||||
------------------
|
||||
- Replacing recipes with resources
|
||||
- Mysql and MariaDB providers for linking mysql2 gem
|
||||
- Expanded platform test coverage
|
||||
|
||||
0.1.1 (2014-09-15)
|
||||
------------------
|
||||
- Correct a typo in documentation
|
||||
- Correct a test failing with Travis CI
|
||||
|
||||
0.1.0 (2014-09-15)
|
||||
------------------
|
||||
- Correct documentation
|
||||
- Correct rubocop offenses
|
||||
|
||||
0.0.3 (2014-09-12)
|
||||
------------------
|
||||
- Initial release (copy of mysql-chef_gem, but for mysql2)
|
||||
108
cookbooks/mysql2_chef_gem/README.md
Normal file
108
cookbooks/mysql2_chef_gem/README.md
Normal file
@@ -0,0 +1,108 @@
|
||||
Mysql2 Chef Gem Installer Cookbook
|
||||
==================================
|
||||
|
||||
[](https://travis-ci.org/sinfomicien/mysql2_chef_gem)
|
||||
|
||||
mysql2_chef_gem is a library cookbook that provides an LWRP for use
|
||||
in recipes. It provides a wrapper around `chef_gem` called
|
||||
`mysql2_chef_gem` that eases the installation process, collecting the
|
||||
prerequisites and side-stepping the compilation phase arms race.
|
||||
|
||||
Scope
|
||||
-----
|
||||
This cookbook is concerned with the installation of the `mysql2`
|
||||
Rubygem into Chef's gem path. Installation into other Ruby
|
||||
environments, or installation of related gems such as `mysql` are
|
||||
outside the scope of this cookbook.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
* Chef 11 or higher
|
||||
* Ruby 1.9 (preferably from the Chef full-stack installer)
|
||||
|
||||
Platform Support
|
||||
----------------
|
||||
The following platforms have been tested with Test Kitchen and are
|
||||
known to work.
|
||||
|
||||
```
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| | 5.0 | 5.1 | 5.5 | 5.6 | 5.7 |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / centos-5 | X | | | X | X |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / centos-6 | | X | X | X | X |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / centos-7 | | | X | X | X |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / fedora-20 | | | X | X | X |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / debian-7 | | | X | | |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / ubuntu-10.04 | | X | | | |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / ubuntu-12.04 | | | X | | |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mysql / ubuntu-14.04 | | | X | X | |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mariadb / fedora-20 | | | X | | |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
| Mysql2ChefGem::Mariadb / ubuntu-14.04 | | | X | | |
|
||||
|---------------------------------------+-----+-----+-----+-----+-----|
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
Place a dependency on the mysql cookbook in your cookbook's metadata.rb
|
||||
```ruby
|
||||
depends 'mysql2_chef_gem', '~> 1.0'
|
||||
```
|
||||
|
||||
Then, in a recipe:
|
||||
|
||||
```ruby
|
||||
mysql2_chef_gem 'default' do
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
Resources Overview
|
||||
------------------
|
||||
### mysql2_chef_gem
|
||||
|
||||
The `mysql2_chef_gem` resource the build dependencies and installation
|
||||
of the `mysql2` rubygem into Chef's Ruby environment
|
||||
|
||||
#### Example
|
||||
```ruby
|
||||
mysql2_chef_gem 'default' do
|
||||
gem_version '0.3.17'
|
||||
action :install
|
||||
end
|
||||
```
|
||||
#### Parameters
|
||||
- `gem_version` - The version of the `mysql` Rubygem to install into
|
||||
the Chef environment. Defaults to '0.3.17'
|
||||
- `connectors_url` - URL of a tarball containing pre-compiled MySQL
|
||||
connector libraries
|
||||
- `connectors_checksum` - sha256sum of the `connectors_url` tarball
|
||||
|
||||
#### Actions
|
||||
- `:install` - Build and install the gem into the Chef environment
|
||||
- `:remove` - Delete the gem from the Chef environment
|
||||
|
||||
#### Providers
|
||||
Chef selects a default provider based on platform and version,
|
||||
but you can specify one if your platform support it.
|
||||
|
||||
```ruby
|
||||
mysql2_chef_gem 'default' do
|
||||
provider Chef::Provider::Mysql2ChefGem::Mariadb
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
Authors
|
||||
-------
|
||||
- Author:: Sean OMeara (<someara@opscode.com>)
|
||||
- Author:: Nicolas Blanc(<sinfomicien@gmail.com>)
|
||||
5
cookbooks/mysql2_chef_gem/libraries/matchers.rb
Normal file
5
cookbooks/mysql2_chef_gem/libraries/matchers.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
if defined?(ChefSpec)
|
||||
def install_mysql2_chef_gem(resource_name)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:mysql2_chef_gem, :install, resource_name)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
class Chef
|
||||
class Provider
|
||||
class Mysql2ChefGem
|
||||
class Mariadb < Chef::Provider::LWRPBase
|
||||
use_inline_resources if defined?(use_inline_resources)
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
action :install do
|
||||
recipe_eval do
|
||||
run_context.include_recipe 'build-essential::default'
|
||||
end
|
||||
|
||||
# As a recipe: must rely on global node attributes
|
||||
recipe_eval do
|
||||
run_context.include_recipe 'mariadb::client'
|
||||
end
|
||||
|
||||
gem_package 'mysql2' do
|
||||
gem_binary RbConfig::CONFIG['bindir'] + '/gem'
|
||||
version new_resource.gem_version
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
||||
action :remove do
|
||||
gem_package 'mysql2' do
|
||||
gem_binary RbConfig::CONFIG['bindir'] + '/gem'
|
||||
action :remove
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
class Chef
|
||||
class Provider
|
||||
class Mysql2ChefGem
|
||||
class Mysql < Chef::Provider::LWRPBase
|
||||
include Chef::DSL::IncludeRecipe
|
||||
use_inline_resources if defined?(use_inline_resources)
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
action :install do
|
||||
include_recipe 'build-essential::default'
|
||||
|
||||
# As a resource: can pass version from calling recipe
|
||||
mysql_client 'default' do
|
||||
version new_resource.client_version
|
||||
action :create
|
||||
end
|
||||
|
||||
gem_package 'mysql2' do
|
||||
gem_binary RbConfig::CONFIG['bindir'] + '/gem'
|
||||
version new_resource.gem_version
|
||||
action :install
|
||||
end
|
||||
end
|
||||
|
||||
action :remove do
|
||||
gem_package 'mysql2' do
|
||||
gem_binary RbConfig::CONFIG['bindir'] + '/gem'
|
||||
action :remove
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
require 'chef/resource/lwrp_base'
|
||||
|
||||
class Chef
|
||||
class Resource
|
||||
class Mysql2ChefGem < Chef::Resource::LWRPBase
|
||||
self.resource_name = :mysql2_chef_gem
|
||||
actions :install, :remove
|
||||
default_action :install
|
||||
|
||||
attribute :mysql2_chef_gem_name, kind_of: String, name_attribute: true, required: true
|
||||
attribute :gem_version, kind_of: String, default: '0.3.17'
|
||||
attribute :client_version, kind_of: String, default: nil
|
||||
end
|
||||
end
|
||||
end
|
||||
17
cookbooks/mysql2_chef_gem/libraries/z_provider_mapping.rb
Normal file
17
cookbooks/mysql2_chef_gem/libraries/z_provider_mapping.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
#########
|
||||
# mysql2_chef_gem
|
||||
#########
|
||||
Chef::Platform.set platform: :amazon, resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :centos, version: '< 7.0', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :centos, version: '>= 7.0', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :debian, resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :fedora, version: '< 19', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :fedora, version: '>= 19', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :omnios, resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :redhat, version: '< 7.0', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :redhat, version: '>= 7.0', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :scientific, version: '< 7.0', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :scientific, version: '>= 7.0', resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :smartos, resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :suse, resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
Chef::Platform.set platform: :ubuntu, resource: :mysql2_chef_gem, provider: Chef::Provider::Mysql2ChefGem::Mysql
|
||||
39
cookbooks/mysql2_chef_gem/metadata.json
Normal file
39
cookbooks/mysql2_chef_gem/metadata.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "mysql2_chef_gem",
|
||||
"version": "1.0.1",
|
||||
"description": "Provides the mysql2_chef_gem resource",
|
||||
"long_description": "",
|
||||
"maintainer": "Nicolas Blanc",
|
||||
"maintainer_email": "sinfomicien@gmail.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"
|
||||
},
|
||||
"dependencies": {
|
||||
"build-essential": ">= 0.0.0",
|
||||
"mysql": ">= 0.0.0",
|
||||
"mariadb": ">= 0.0.0"
|
||||
},
|
||||
"recommendations": {
|
||||
},
|
||||
"suggestions": {
|
||||
},
|
||||
"conflicting": {
|
||||
},
|
||||
"providing": {
|
||||
},
|
||||
"replacing": {
|
||||
},
|
||||
"attributes": {
|
||||
},
|
||||
"groupings": {
|
||||
},
|
||||
"recipes": {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user