Update cookbooks and add wordpress cookbook

This commit is contained in:
Greg Karékinian
2016-02-19 18:09:49 +01:00
parent 9ba973e3ac
commit 820b0ab3f8
606 changed files with 22421 additions and 14084 deletions

46
cookbooks/database/.gitignore vendored Normal file
View File

@@ -0,0 +1,46 @@
*.gem
.zero-knife.rb
*.rbc
.bundle
.config
coverage
InstalledFiles
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
Gemfile.lock
_Store
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
*.tmp
*.bk
*.bkup
.ruby-version
.ruby-gemset
.rvmrc
# YARD artifacts
.yardoc
_yardoc
doc/
.idea
.ruby-version
#chef stuff
Berksfile.lock
.kitchen
.kitchen.local.yml
vendor/
.coverage/
#vagrant stuff
.vagrant/
.vagrant.d/

View File

@@ -0,0 +1,182 @@
#<% require 'kitchen-sync' %>
---
driver_config:
digitalocean_client_id: <%= ENV['DIGITAL_OCEAN_CLIENT_ID'] %>
google_client_email: <%= ENV['GOOGLE_CLIENT_EMAIL'] %>
google_key_location: <%= ENV['GOOGLE_KEY_LOCATION'] %>
google_project: <%= ENV['GOOGLE_PROJECT'] %>
joyent_username: <%= ENV['SDC_CLI_ACCOUNT'] %>
joyent_keyfile: <%= ENV['SDC_CLI_IDENTITY'] %>
joyent_keyname: <%= ENV['SDC_CLI_KEY_ID'] %>
joyent_url: <%= ENV['SDC_CLI_URL'] %>
aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %>
flavor_id: <%= ENV['EC2_FLAVOR_ID'] %>
availability_zone: <%= ENV['AWS_AVAILABILITY_ZONE'] %>
provisioner:
name: chef_zero
# require_chef_omnibus: 11.16.8
# require_chef_omnibus: 12.0.3
require_chef_omnibus: latest
platforms:
- name: centos-5.8
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: centos-5-8-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
- name: centos-6.5
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: centos-6-5-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
- name: centos-7.0
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: centos-7-0-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
- name: amazon-2014.09
driver_plugin: ec2
driver_config:
image_id: ami-9a6ed3f2
username: ec2-user
ssh_key: <%= ENV['EC2_SSH_KEY_PATH'] %>
- name: fedora-20
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: fedora-20-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
- name: suse-11.3
driver_plugin: ec2
driver_config:
image_id: ami-e8084981
username: root
ssh_key: <%= ENV['EC2_SSH_KEY_PATH'] %>
- name: debian-7.0
driver_plugin: gce
driver_config:
image_name: debian-7-wheezy-v20131120
zone: <%= ENV['GCE_ZONE'] %>
area: <%= ENV['GCE_AREA'] %>
network: <%= ENV['GCE_NETWORK'] %>
username: <%= ENV['GCE_USERNAME'] %>
public_key_path: <%= ENV['GCE_PUBLIC_KEY_PATH'] %>
ssh_key: <%= ENV['GCE_SSH_KEY_PATH'] %>
run_list:
- recipe[apt]
- name: ubuntu-10.04
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: ubuntu-10-04-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
run_list:
- recipe[apt]
- name: ubuntu-12.04
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: ubuntu-12-04-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
run_list:
- recipe[apt]
- name: ubuntu-14.04
driver_plugin: digital_ocean
driver_config:
size: 2gb
image: ubuntu-14-04-x64
region: <%= ENV['DIGITAL_OCEAN_REGION'] %>
ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %>
ssh_key: <%= ENV['DIGITAL_OCEAN_SSH_KEY_PATH'] %>
run_list:
- recipe[apt]
suites:
#
# database-test
#
- name: myclient50
run_list:
- recipe[mysql_database_test]
attributes:
mysql:
version: '5.0'
includes: [
'centos-5.8'
]
- name: myclient51
run_list:
- recipe[mysql_database_test]
attributes:
mysql:
version: '5.1'
includes: [
'centos-6.5',
'ubuntu-10.04'
]
- name: myclient55
run_list:
- recipe[mysql_database_test]
attributes:
mysql:
version: '5.5'
includes: [
'centos-6.5',
'debian-7.0',
'ubuntu-12.04',
'ubuntu-14.04'
]
- name: myclient56
run_list:
- recipe[mysql_database_test]
attributes:
mysql:
version: '5.6'
includes: [
'centos-5.8',
'centos-6.5',
'centos-7.0',
'ubuntu-14.04'
]
- name: myclient57
run_list:
- recipe[mysql_database_test]
attributes:
mysql:
version: '5.7'
includes: [
'centos-5.8',
'centos-6.5',
'centos-7.0'
]

View File

@@ -0,0 +1,33 @@
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: centos-5.11
- name: centos-6.7
- name: centos-7.1
- name: debian-7.8
run_list:
- recipe[apt]
- name: debian-8.1
run_list:
- recipe[apt]
- name: fedora-21
- name: ubuntu-12.04
run_list:
- recipe[apt]
- name: ubuntu-14.04
run_list:
- recipe[apt]
suites:
#
# database-test
#
- name: default
run_list:
- recipe[mysql_database_test]
- recipe[postgresql_database_test]

View File

@@ -0,0 +1,35 @@
AllCops:
Exclude:
- vendor/**/*
- 'Guardfile'
AlignParameters:
Enabled: false
Encoding:
Enabled: false
ClassLength:
Enabled: false
MethodLength:
Enabled: false
LineLength:
Enabled: false
Documentation:
Enabled: false
PerceivedComplexity:
Enabled: false
CyclomaticComplexity:
Enabled: false
Style/FileName:
Enabled: false
Metrics/AbcSize:
Enabled: false

View File

@@ -0,0 +1,12 @@
sudo: false
cache: bundler
language: ruby
bundler_args: --without kitchen_common kitchen_vagrant
rvm:
- 2.0
- 2.1
- 2.2
script:
- bundle exec foodcritic -f any .
- bundle exec rubocop
- bundle exec rspec --color --format progress

View File

@@ -0,0 +1,12 @@
source 'https://supermarket.chef.io'
metadata
group :integration do
cookbook 'apt'
cookbook 'selinux'
cookbook 'mysql2_chef_gem'
end
cookbook 'mysql_database_test', path: 'test/fixtures/cookbooks/mysql_database_test'
cookbook 'postgresql_database_test', path: 'test/fixtures/cookbooks/postgresql_database_test'

View File

@@ -1,6 +1,34 @@
Database cookbook README
========================
v4.0.9 (2015-09-07)
-------------------
- Fix bad attribute name with postgresql_database in the readme
- Add `flags` attribute to the mysql provider
- Add `database` attribute to the mysql provider
- Use the correct database with the mssql provider
- Updated testing.md and contributing.md to point to documentation in the new community_cookbook_documentation repo
- Add oracle as a supported platform in the metadata
- Add source_url and issues_url metadata
- Add cookbook version and travis badges to the readme
- Clarify the minimum required Chef version in the readme
- Add a Travis config
- Resolve several rubocop and foodcritic warnings
- Update all platforms in the Kitchen config
- Update development dependencies to the latest releases
- Add a maintainers.md and maintainers.toml file
- Add a chefignore file
- Update list of ignored files in the gitignore
v4.0.8 (2015-08-03)
-------------------
- #139 - Use a more reliable method of determining whether the
Postgres server accepts the REPLICATION attribute on user creation.
v4.0.7 (2015-07-27)
-------------------
- #161 - Fixes multiple issues causing the MySQL database user creation to not be idempotent
v4.0.6 (2015-04-29)
-------------------
- #126 - Use sql_query property instead of sql in the mysql provider for :query action

View File

@@ -0,0 +1,2 @@
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD

View File

@@ -0,0 +1,41 @@
source 'https://rubygems.org'
group :lint do
gem 'foodcritic', '~> 4.0'
gem 'rubocop', '~> 0.33'
gem 'rainbow', '< 2.0'
end
group :unit do
gem 'berkshelf', '~> 3.2'
gem 'chefspec', '~> 4.3'
end
group :kitchen_common do
gem 'test-kitchen', '~> 1.4'
end
group :kitchen_vagrant do
gem 'kitchen-vagrant', '~> 0.18'
end
group :kitchen_cloud do
gem 'kitchen-digitalocean'
gem 'kitchen-ec2'
gem 'kitchen-joyent'
gem 'kitchen-gce'
end
group :development do
gem 'ruby_gntp'
gem 'growl'
gem 'rb-fsevent'
gem 'guard', '~> 2.4'
gem 'guard-kitchen'
gem 'guard-foodcritic'
gem 'guard-rspec'
gem 'guard-rubocop'
gem 'rake'
gem 'fauxhai'
gem 'pry-nav'
end

View File

@@ -0,0 +1,24 @@
# More info at https://github.com/guard/guard#readme
guard 'foodcritic', :cookbook_paths => '.', :cli => '-t ~FC023 -t ~FC005', :all_on_start => false do
watch(/attributes\/.+\.rb$/)
watch(/providers\/.+\.rb$/)
watch(/recipes\/.+\.rb$/)
watch(/resources\/.+\.rb$/)
watch('metadata.rb')
end
guard 'rubocop' do
watch(/attributes\/.+\.rb$/)
watch(/providers\/.+\.rb$/)
watch(/recipes\/.+\.rb$/)
watch(/resources\/.+\.rb$/)
watch('metadata.rb')
end
guard :rspec, :cmd => 'chef exec /opt/chefdk/embedded/bin/rspec', :all_on_start => false, :notification => false do
watch(/^libraries\/(.+)\.rb$/)
watch(/^spec\/(.+)_spec\.rb$/)
watch(/^(recipes)\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' }
end

201
cookbooks/database/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 2008-2015 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,19 @@
<!-- This is a generated file. Please do not edit directly -->
# Maintainers
This file lists how this cookbook project is maintained. When making changes to the system, this
file tells you who needs to review your patch - you need a simple majority of maintainers
for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need
to not receive a veto from a Lieutenant or the Project Lead.
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD)
for details on the process and how to become a maintainer or the project lead.
# Project Maintainer
* [Tim Smith](https://github.com/tas50)
# Maintainers
* [Jennifer Davis](https://github.com/sigje)
* [Sean OMeara](https://github.com/someara)
* [Tim Smith](https://github.com/tas50)
* [Thom May](https://github.com/thommay)

View File

@@ -0,0 +1,46 @@
#
# This file is structured to be consumed by both humans and computers.
# It is a TOML document containing Markdown
#
[Preamble]
title = "Maintainers"
text = """
This file lists how this cookbook project is maintained. When making changes to the system, this
file tells you who needs to review your patch - you need a simple majority of maintainers
for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need
to not receive a veto from a Lieutenant or the Project Lead.
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD)
for details on the process and how to become a maintainer or the project lead.
"""
[Org]
[Org.Components]
[Org.Components.Core]
title = "Project Maintainer"
lieutenant = 'tas50'
maintainers = [
'sigje',
'someara',
'tas50',
'thommay'
]
[people]
[people.sigje]
name = "Jennifer Davis"
github = "sigje"
[people.someara]
name = "Sean OMeara"
github = "someara"
[people.tas50]
name = "Tim Smith"
github = "tas50"
[people.thommay]
name = "Thom May"
github = "thommay"

View File

@@ -1,5 +1,8 @@
Database Cookbook
=================
[![Build Status](https://travis-ci.org/opscode-cookbooks/database.svg?branch=master)](http://travis-ci.org/opscode-cookbooks/database)
[![Cookbook Version](https://img.shields.io/cookbook/v/database.svg)](https://supermarket.chef.io/cookbooks/database)
The main highlight of this cookbook is the `database` and
`database_user` resources for managing databases and database users in
a RDBMS. Providers for MySQL, PostgreSQL and SQL Server are also
@@ -7,11 +10,13 @@ provided, see usage documentation below.
Requirements
------------
Chef version 0.11+
### Platforms
- Debian, Ubuntu
- Red Hat, CentOS, Scientific, Fedora, Amazon
- Debian / Ubuntu derivatives
- RHEL derivatives
- Fedora
### Chef
- Chef 11+
### Cookbooks
The following Chef Software cookbooks are dependencies:

View File

@@ -0,0 +1,61 @@
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
require 'kitchen'
require_relative 'tasks/maintainers'
# Style tests. Rubocop and Foodcritic
namespace :style do
desc 'Run Ruby style checks'
RuboCop::RakeTask.new(:ruby)
desc 'Run Chef style checks'
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any'],
tags: ['~FC005']
}
end
end
desc 'Run all style checks'
task style: ['style:chef', 'style:ruby']
# Rspec and ChefSpec
desc 'Run ChefSpec examples'
RSpec::Core::RakeTask.new(:spec)
# Integration tests. Kitchen.ci
namespace :integration do
desc 'Run Test Kitchen with Vagrant'
task :vagrant do
Kitchen.logger = Kitchen.default_file_logger
Kitchen::Config.new.instances.each do |instance|
instance.test(:always)
end
end
desc 'Run Test Kitchen with cloud plugins'
task :cloud do
run_kitchen = true
if ENV['TRAVIS'] == 'true' && ENV['TRAVIS_PULL_REQUEST'] != 'false'
run_kitchen = false
end
if run_kitchen
Kitchen.logger = Kitchen.default_file_logger
@loader = Kitchen::Loader::YAML.new(project_config: './.kitchen.cloud.yml')
config = Kitchen::Config.new(loader: @loader)
config.instances.each do |instance|
instance.test(:always)
end
end
end
end
desc 'Run all tests on Travis'
task travis: ['style', 'spec', 'integration:cloud']
# Default
task default: ['style', 'spec', 'integration:vagrant']

View File

@@ -0,0 +1,2 @@
Please refer to
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/TESTING.MD

View File

@@ -0,0 +1,100 @@
# Put files/directories that should be ignored in this file when uploading
# or sharing to the community site.
# Lines that start with '# ' are comments.
# OS generated files #
######################
.DS_Store
Icon?
nohup.out
ehthumbs.db
Thumbs.db
# SASS #
########
.sass-cache
# EDITORS #
###########
\#*
.#*
*~
*.sw[a-z]
*.bak
REVISION
TAGS*
tmtags
*_flymake.*
*_flymake
*.tmproj
.project
.settings
mkmf.log
## COMPILED ##
##############
a.out
*.o
*.pyc
*.so
*.com
*.class
*.dll
*.exe
*/rdoc/
# Testing #
###########
.watchr
.rspec
spec/*
spec/fixtures/*
test/*
features/*
examples/*
Guardfile
Procfile
# SCM #
#######
.git
*/.git
.gitignore
.gitmodules
.gitconfig
.gitattributes
.svn
*/.bzr/*
*/.hg/*
*/.svn/*
# Berkshelf #
#############
Berksfile
Berksfile.lock
cookbooks/*
tmp
# Cookbooks #
#############
CONTRIBUTING
CHANGELOG*
# Strainer #
############
Colanderfile
Strainerfile
.colander
.strainer
# Vagrant #
###########
.vagrant
Vagrantfile
# Travis #
##########
.travis.yml
test/
spec/
examples/

View File

@@ -103,11 +103,11 @@ class Chef
require 'mysql2'
@test_client ||=
Mysql2::Client.new(
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
)
end
@@ -121,11 +121,11 @@ class Chef
require 'mysql2'
@repair_client ||=
Mysql2::Client.new(
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
)
end
@@ -139,11 +139,13 @@ class Chef
require 'mysql2'
@query_client ||=
Mysql2::Client.new(
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port],
flags: new_resource.connection[:flags],
database: new_resource.database_name
)
end

View File

@@ -94,21 +94,84 @@ class Chef
db_name = new_resource.database_name ? "`#{new_resource.database_name}`" : '*'
tbl_name = new_resource.table ? new_resource.table : '*'
test_table = new_resource.database_name ? 'mysql.db' : 'mysql.user'
possible_global_privs = [
:select,
:insert,
:update,
:delete,
:create,
:drop,
:references,
:index,
:alter,
:create_tmp_table,
:lock_tables,
:create_view,
:show_view,
:create_routine,
:alter_routine,
:execute,
:event,
:trigger,
:reload,
:shutdown,
:process,
:file,
:show_db,
:super,
:repl_slave,
:repl_client,
:create_user
]
possible_db_privs = [
:select,
:insert,
:update,
:delete,
:create,
:drop,
:references,
:index,
:alter,
:create_tmp_table,
:lock_tables,
:create_view,
:show_view,
:create_routine,
:alter_routine,
:execute,
:event,
:trigger
]
if new_resource.privileges == [:all] && new_resource.database_name
desired_privs = possible_db_privs
elsif new_resource.privileges == [:all]
desired_privs = possible_global_privs
else
desired_privs = new_resource.privileges
end
# Test
incorrect_privs = nil
begin
test_sql = 'SELECT * from mysql.db'
test_sql = "SELECT * from #{test_table}"
test_sql += " WHERE User='#{new_resource.username}'"
test_sql += " AND Host='#{new_resource.host}'"
test_sql += " AND Db='#{new_resource.database_name}'"
test_sql += " AND Db='#{new_resource.database_name}'" if new_resource.database_name
test_sql_results = test_client.query test_sql
incorrect_privs = true if test_sql_results.size == 0
# These should all by 'Y'
test_sql_results.each do |r|
new_resource.privileges.each do |p|
key = "#{p.capitalize}_priv"
desired_privs.each do |p|
key = "#{p.capitalize}"
.gsub(' ', '_')
.gsub('Replication_', 'Repl_')
key = "#{key}_priv"
incorrect_privs = true if r[key] != 'Y'
end
end
@@ -156,11 +219,11 @@ class Chef
require 'mysql2'
@test_client ||=
Mysql2::Client.new(
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
)
end
@@ -174,11 +237,11 @@ class Chef
require 'mysql2'
@repair_client ||=
Mysql2::Client.new(
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
host: new_resource.connection[:host],
socket: new_resource.connection[:socket],
username: new_resource.connection[:username],
password: new_resource.connection[:password],
port: new_resource.connection[:port]
)
end

View File

@@ -41,9 +41,7 @@ class Chef
unless exists?
begin
encoding = @new_resource.encoding
if encoding != 'DEFAULT'
encoding = "'#{@new_resource.encoding}'"
end
encoding = "'#{@new_resource.encoding}'" if encoding != 'DEFAULT'
Chef::Log.debug("#{@new_resource}: Creating database #{new_resource.database_name}")
create_sql = "CREATE DATABASE \"#{new_resource.database_name}\""
create_sql += " TEMPLATE = #{new_resource.template}" if new_resource.template
@@ -100,14 +98,15 @@ class Chef
ret
end
# Test if text is psql keyword
def keyword?(text)
# Verify the postgres server's version number is greater than the integer passed in
def version_greater_than?(desired_version_int)
begin
result = db('template1').exec_params('select * from pg_get_keywords() where word = $1', [text.downcase]).num_tuples != 0
ret = db('template1').exec('SHOW server_version_num;')
server_version_int = ret.getvalue(0, 0).to_i
ensure
close
end
result
server_version_int > desired_version_int
end
#
@@ -124,7 +123,7 @@ class Chef
port = @new_resource.connection[:port] || 5432
user = @new_resource.connection[:username] || 'postgres'
Chef::Log.debug("#{@new_resource}: connecting to database #{dbname} on #{host}:#{port} as #{user}")
password = @new_resource.connection[:password] || node[:postgresql][:password][:postgres]
password = @new_resource.connection[:password] || node['postgresql']['password']['postgres']
@db = ::PGconn.new(
host: host,
port: port,

View File

@@ -42,13 +42,11 @@ class Chef
options += " #{@new_resource.createdb ? 'CREATEDB' : 'NOCREATEDB'}"
options += " #{@new_resource.createrole ? 'CREATEROLE' : 'NOCREATEROLE'}"
options += " #{@new_resource.login ? 'LOGIN' : 'NOLOGIN'}"
options += " #{@new_resource.replication ? 'REPLICATION' : 'NOREPLICATION'}" if keyword?('REPLICATION')
options += " #{@new_resource.replication ? 'REPLICATION' : 'NOREPLICATION'}" if version_greater_than?(90_100)
options += " #{@new_resource.superuser ? 'SUPERUSER' : 'NOSUPERUSER'}"
statement = "CREATE USER \"#{@new_resource.username}\""
if options.length > 0
statement += " WITH #{options}"
end
statement += " WITH #{options}" if options.length > 0
db('template1').query(statement)
@new_resource.updated_by_last_action(true)

View File

@@ -61,8 +61,8 @@ class Chef
def action_query
if exists?
begin
# db.select_db(@new_resource.database_name) if @new_resource.database_name
Chef::Log.debug("#{@new_resource}: Performing query [#{new_resource.sql_query}]")
db.execute("USE [#{@new_resource.database_name}]").do if @new_resource.database_name
db.execute(@new_resource.sql_query).do
@new_resource.updated_by_last_action(true)
ensure

View File

@@ -88,7 +88,7 @@ class Chef
end
Chef::Application.fatal!('Please provide a database_name, SQL Server does not support global GRANT statements.') unless @new_resource.database_name
db.execute("USE [#{@new_resource.database_name}]").do
@new_resource.sql_roles.each do | sql_role, role_action |
@new_resource.sql_roles.each do |sql_role, role_action|
alter_statement = "ALTER ROLE [#{sql_role}] #{role_action} MEMBER [#{@new_resource.username}]"
Chef::Log.info("#{@new_resource} granting access with statement [#{alter_statement}]")
db.execute(alter_statement).do
@@ -105,7 +105,7 @@ class Chef
server_version = db.execute("SELECT SERVERPROPERTY('productversion')").each.first.values.first
Chef::Log.info("SQL Server Version: #{server_version.inspect}")
db.execute('USE [master]').do
@new_resource.sql_sys_roles.each do | sql_sys_role, role_action |
@new_resource.sql_sys_roles.each do |sql_sys_role, role_action|
case role_action
when 'ADD'
if server_version < '11.00.0000.00'

View File

@@ -35,7 +35,7 @@ class Chef
def windows_user(arg = nil)
set_or_return(
:windows_user,
:windows_user,
arg,
kind_of: [TrueClass, FalseClass],
default: false
@@ -45,7 +45,7 @@ class Chef
def sql_roles(arg = nil)
Chef::Log.debug("Received roles: #{arg.inspect}")
set_or_return(
:sql_roles,
:sql_roles,
arg,
kind_of: Hash
)
@@ -54,7 +54,7 @@ class Chef
def sql_sys_roles(arg = nil)
Chef::Log.debug("Received Server roles: #{arg.inspect}")
set_or_return(
:sql_sys_roles,
:sql_sys_roles,
arg,
kind_of: Hash
)

View File

@@ -1 +1,49 @@
{"name":"database","version":"4.0.6","description":"provides LWRPs for common database tasks","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"debian":">= 0.0.0","ubuntu":">= 0.0.0","centos":">= 0.0.0","suse":">= 0.0.0","fedora":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0","amazon":">= 0.0.0"},"dependencies":{"postgresql":">= 1.0.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}}
{
"name": "database",
"description": "provides LWRPs for common database tasks",
"long_description": "",
"maintainer": "Chef Software, Inc.",
"maintainer_email": "cookbooks@chef.io",
"license": "Apache 2.0",
"platforms": {
"debian": ">= 0.0.0",
"ubuntu": ">= 0.0.0",
"centos": ">= 0.0.0",
"suse": ">= 0.0.0",
"fedora": ">= 0.0.0",
"redhat": ">= 0.0.0",
"scientific": ">= 0.0.0",
"oracle": ">= 0.0.0",
"amazon": ">= 0.0.0"
},
"dependencies": {
"postgresql": ">= 1.0.0"
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"attributes": {
},
"groupings": {
},
"recipes": {
},
"version": "4.0.9",
"source_url": "https://github.com/opscode-cookbooks/database",
"issues_url": "https://github.com/opscode-cookbooks/database/issues"
}

View File

@@ -0,0 +1,21 @@
name 'database'
maintainer 'Chef Software, Inc.'
maintainer_email 'cookbooks@chef.io'
license 'Apache 2.0'
description 'provides LWRPs for common database tasks'
version '4.0.9'
supports 'debian'
supports 'ubuntu'
supports 'centos'
supports 'suse'
supports 'fedora'
supports 'redhat'
supports 'scientific'
supports 'oracle'
supports 'amazon'
depends 'postgresql', '>= 1.0.0'
source_url 'https://github.com/opscode-cookbooks/database' if respond_to?(:source_url)
issues_url 'https://github.com/opscode-cookbooks/database/issues' if respond_to?(:issues_url)