Merge branch 'feature/ubuntu-16.04' into 'master'

Support Ubuntu 16.04

See merge request !2
This commit is contained in:
Greg Karékinian 2017-06-16 09:34:50 +00:00
commit acd67151a0
289 changed files with 5337 additions and 106651 deletions

51
Batali
View File

@ -6,36 +6,37 @@ Batali.define do
cookbook 'mediawiki',
git: 'https://github.com/67P/mediawiki-cookbook.git',
ref: 'nginx'
cookbook 'php-fpm',
git: 'https://github.com/67P/cookbook-php-fpm.git',
ref: 'ubuntu_systemd'
cookbook 'wordpress',
git: 'https://github.com/67P/wordpress-cookbook.git',
ref: 'relax_dependencies'
cookbook 'postfix'
cookbook 'unattended-upgrades'
cookbook 'poise-ruby-build', '~> 1.1.0'
cookbook 'application', '~> 5.2.0'
cookbook 'application_javascript'
cookbook 'application_ruby', '~> 4.1.0'
cookbook 'application_git', '~> 1.1.0' # 1.2.0 doesn't work with knife-solo
cookbook 'users', '~> 5.0.0'
cookbook 'sudo', '~> 3.5.0'
cookbook 'hostname'
cookbook 'redis',
git: 'https://github.com/phlipper/chef-redis.git',
ref: 'v0.5.6'
cookbook 'firewall', '~> 2.6.1'
cookbook 'chef_nginx', '~> 6.0.2'
cookbook 'build-essential'
cookbook 'mysql'
cookbook 'postgresql', '~> 6.1'
cookbook 'postfix', '~> 5.0.2'
cookbook 'php-fpm', '~> 0.7.9'
cookbook 'php', '~> 4.2.0'
cookbook 'poise-ruby-build', '~> 1.1.0'
cookbook 'application', '~> 5.2.0'
cookbook 'application_javascript', '~> 1.0.0'
cookbook 'application_ruby', '~> 4.1.0'
cookbook 'application_git', '~> 1.1.0' # 1.2.0 doesn't work with knife-solo
cookbook 'users', '~> 5.0.0'
cookbook 'sudo', '~> 3.5.0'
cookbook 'hostname', '~> 0.4.2'
cookbook 'firewall', '~> 2.6.2'
cookbook 'chef_nginx', '~> 6.1.1'
cookbook 'build-essential', '~> 8.0.3'
cookbook 'mysql', '~> 8.4.0'
cookbook 'postgresql', '~> 6.1.1'
# Deprecated, but wordpress and mediawiki depend on it and it would painful
# to change it without moving the databases
cookbook 'database'
cookbook 'mysql2_chef_gem'
cookbook 'chef_client_updater', '~> 1.0.2'
cookbook 'timezone-ii'
cookbook 'nodejs', '~> 3.0.0'
cookbook 'ark', '~> 3.0.0'
cookbook 'logrotate', '~> 2.1.0'
cookbook 'openssl', '~> 7.0.1'
cookbook 'mysql2_chef_gem', '~> 2.0.1'
cookbook 'chef_client_updater', '~> 1.1.1'
cookbook 'timezone-ii', '~> 0.2.0'
cookbook 'nodejs', '~> 3.0.0'
cookbook 'ark', '~> 3.1.0'
cookbook 'logrotate', '~> 2.2.0'
cookbook 'openssl', '~> 7.1.0'
cookbook 'ntp', '~> 3.4.0'
end

11
Vagrantfile vendored
View File

@ -12,8 +12,7 @@ Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/ubuntu-15.04"
config.vm.box = "bento/ubuntu-16.04"
config.vm.provider :virtualbox do |vb|
# Customize the amount of memory on the VM:
@ -98,12 +97,12 @@ Vagrant.configure(2) do |config|
chef.environments_path = 'environments'
chef.encrypted_data_bag_secret_key_path = '.chef/encrypted_data_bag_secret'
chef.environment = 'development'
# chef.add_recipe 'kosmos-wordpress'
chef.add_recipe 'kosmos-base'
chef.add_recipe 'kosmos-wordpress'
# chef.add_recipe 'sockethub'
chef.add_recipe 'kosmos-mastodon'
chef.add_recipe 'kosmos-mastodon::nginx'
# chef.add_recipe 'kosmos-mastodon'
# chef.add_recipe 'kosmos-mastodon::nginx'
# chef.add_recipe '5apps-hubot::xmpp_botka'
# chef.add_recipe 'kosmos-hubot'
end
end

View File

@ -71,21 +71,13 @@
[
"yum-epel",
">= 0.0.0"
],
[
"windows",
">= 0.0.0"
],
[
"iis",
">= 0.0.0"
]
],
"version": "1.7.2",
"version": "4.2.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/php/versions/1.7.2/download",
"version": "1.7.2"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/php/versions/4.2.0/download",
"version": "4.2.0"
}
},
{
@ -100,11 +92,11 @@
">= 1.1"
]
],
"version": "8.0.1",
"version": "8.0.3",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/build-essential/versions/8.0.1/download",
"version": "8.0.1"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/build-essential/versions/8.0.3/download",
"version": "8.0.3"
}
},
{
@ -198,35 +190,28 @@
{
"name": "mysql",
"dependencies": [
[
"yum-mysql-community",
">= 0.0.0"
],
[
"smf",
">= 0.0.0"
]
],
"version": "6.1.3",
"version": "8.4.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/mysql/versions/6.1.3/download",
"version": "6.1.3"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/mysql/versions/8.4.0/download",
"version": "8.4.0"
}
},
{
"name": "yum-mysql-community",
"name": "yum-epel",
"dependencies": [
[
"yum",
">= 3.2"
"~> 3.0"
]
],
"version": "0.1.21",
"version": "0.3.6",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/yum-mysql-community/versions/0.1.21/download",
"version": "0.1.21"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/yum-epel/versions/0.3.6/download",
"version": "0.3.6"
}
},
{
@ -234,80 +219,11 @@
"dependencies": [
],
"version": "5.0.0",
"version": "3.13.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/yum/versions/5.0.0/download",
"version": "5.0.0"
}
},
{
"name": "smf",
"dependencies": [
[
"rbac",
">= 1.0.1"
]
],
"version": "2.2.8",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/smf/versions/2.2.8/download",
"version": "2.2.8"
}
},
{
"name": "rbac",
"dependencies": [
],
"version": "1.0.3",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/rbac/versions/1.0.3/download",
"version": "1.0.3"
}
},
{
"name": "yum-epel",
"dependencies": [
[
"compat_resource",
">= 12.16.3"
]
],
"version": "2.1.1",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/yum-epel/versions/2.1.1/download",
"version": "2.1.1"
}
},
{
"name": "compat_resource",
"dependencies": [
],
"version": "12.16.3",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/compat_resource/versions/12.16.3/download",
"version": "12.16.3"
}
},
{
"name": "iis",
"dependencies": [
[
"windows",
">= 1.34.6"
]
],
"version": "5.0.8",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/iis/versions/5.0.8/download",
"version": "5.0.8"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/yum/versions/3.13.0/download",
"version": "3.13.0"
}
},
{
@ -349,15 +265,15 @@
}
},
{
"name": "openssl",
"name": "compat_resource",
"dependencies": [
],
"version": "7.0.1",
"version": "12.19.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/openssl/versions/7.0.1/download",
"version": "7.0.1"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/compat_resource/versions/12.19.0/download",
"version": "12.19.0"
}
},
{
@ -384,11 +300,11 @@
">= 0.0.0"
]
],
"version": "6.0.2",
"version": "6.1.1",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/chef_nginx/versions/6.0.2/download",
"version": "6.0.2"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/chef_nginx/versions/6.1.1/download",
"version": "6.1.1"
}
},
{
@ -420,22 +336,22 @@
"dependencies": [
[
"build-essential",
">= 0.0.0"
">= 2.4.0"
],
[
"mysql",
"~> 6.0"
">= 8.2.0"
],
[
"mariadb",
">= 0.0.0"
]
],
"version": "1.0.2",
"version": "2.0.1",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/mysql2_chef_gem/versions/1.0.2/download",
"version": "1.0.2"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/mysql2_chef_gem/versions/2.0.1/download",
"version": "2.0.1"
}
},
{
@ -478,19 +394,18 @@
"dependencies": [
[
"apt",
"> 0"
">= 0.0.0"
],
[
"yum",
">= 3.0"
]
],
"version": "0.7.5",
"version": "0.7.9",
"source": {
"url": "https://github.com/67P/cookbook-php-fpm.git",
"ref": "00ae43a225cf23fd3ed937f27ab25aba8d812db9",
"type": "Batali::Source::Git",
"subdirectory": null
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/php-fpm/versions/0.7.9/download",
"version": "0.7.9"
}
},
{
@ -553,6 +468,21 @@
"subdirectory": null
}
},
{
"name": "iis",
"dependencies": [
[
"windows",
">= 1.34.6"
]
],
"version": "5.0.8",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/iis/versions/5.0.8/download",
"version": "5.0.8"
}
},
{
"name": "tar",
"dependencies": [
@ -577,31 +507,32 @@
"version": "0.9.0"
}
},
{
"name": "redis",
"dependencies": [
[
"apt",
"> 0"
]
],
"version": "0.5.6",
"source": {
"url": "https://github.com/phlipper/chef-redis.git",
"ref": "7476279fc9c8727f082b8d77b5e1922dc2ef437b",
"type": "Batali::Source::Git",
"subdirectory": null
}
},
{
"name": "postfix",
"dependencies": [
],
"version": "5.0.1",
"version": "5.0.2",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/postfix/versions/5.0.1/download",
"version": "5.0.1"
}
},
{
"name": "unattended-upgrades",
"dependencies": [
[
"apt",
">= 0.0.0"
]
],
"version": "0.1.2",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/unattended-upgrades/versions/0.1.2/download",
"version": "0.1.2"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/postfix/versions/5.0.2/download",
"version": "5.0.2"
}
},
{
@ -927,11 +858,11 @@
">= 0.0.0"
]
],
"version": "0.4.0",
"version": "0.4.2",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/hostname/versions/0.4.0/download",
"version": "0.4.0"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/hostname/versions/0.4.2/download",
"version": "0.4.2"
}
},
{
@ -946,22 +877,6 @@
"version": "2.4.5"
}
},
{
"name": "redis",
"dependencies": [
[
"apt",
"> 0"
]
],
"version": "0.5.6",
"source": {
"url": "https://github.com/phlipper/chef-redis.git",
"ref": "7476279fc9c8727f082b8d77b5e1922dc2ef437b",
"type": "Batali::Source::Git",
"subdirectory": null
}
},
{
"name": "firewall",
"dependencies": [
@ -970,11 +885,11 @@
">= 0.0.0"
]
],
"version": "2.6.1",
"version": "2.6.2",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/firewall/versions/2.6.1/download",
"version": "2.6.1"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/firewall/versions/2.6.2/download",
"version": "2.6.2"
}
},
{
@ -985,11 +900,11 @@
">= 12.16.3"
]
],
"version": "1.0.2",
"version": "1.1.1",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/chef_client_updater/versions/1.0.2/download",
"version": "1.0.2"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/chef_client_updater/versions/1.1.1/download",
"version": "1.1.1"
}
},
{
@ -1035,6 +950,18 @@
"version": "3.0.0"
}
},
{
"name": "homebrew",
"dependencies": [
],
"version": "3.0.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download",
"version": "3.0.0"
}
},
{
"name": "ark",
"dependencies": [
@ -1051,38 +978,47 @@
">= 0.0.0"
]
],
"version": "3.0.0",
"version": "3.1.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ark/versions/3.0.0/download",
"version": "3.0.0"
}
},
{
"name": "homebrew",
"dependencies": [
],
"version": "3.0.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download",
"version": "3.0.0"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ark/versions/3.1.0/download",
"version": "3.1.0"
}
},
{
"name": "logrotate",
"dependencies": [
[
"compat_resource",
">= 0.0.0"
]
],
"version": "2.1.0",
"version": "2.2.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/logrotate/versions/2.1.0/download",
"version": "2.1.0"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/logrotate/versions/2.2.0/download",
"version": "2.2.0"
}
},
{
"name": "openssl",
"dependencies": [
],
"version": "7.1.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/openssl/versions/7.1.0/download",
"version": "7.1.0"
}
},
{
"name": "ntp",
"dependencies": [
],
"version": "3.4.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/ntp/versions/3.4.0/download",
"version": "3.4.0"
}
}
]

View File

@ -2,7 +2,13 @@
This file is used to list changes made in each version of the ark cookbook.
## 3.1.0 (2017-05-06)
- Ensure the dependencies get installed on Chef 13 Amazon Linux systems
- Require Chef 12.7+ and remove action_class.class_eval usage
## 3.0.0 (2017-04-05)
- Rewrite of resource to custom resources.
- Remove EOL platforms from testing.
- Update zlib URL

View File

@ -44,7 +44,7 @@ Should work on common Unix/Linux systems with typical userland utilities like ta
### Chef
- Chef 12.5+
- Chef 12.7+
### Cookbooks

View File

@ -30,10 +30,10 @@ default['ark']['sevenzip_binary'] = nil
pkgs = %w(libtool autoconf) unless platform_family?('mac_os_x')
pkgs += %w(make) unless platform_family?('mac_os_x', 'freebsd')
pkgs += %w(unzip rsync gcc) unless platform_family?('mac_os_x')
pkgs += %w(autogen) unless platform_family?('rhel', 'fedora', 'mac_os_x', 'suse')
pkgs += %w(autogen) unless platform_family?('rhel', 'fedora', 'mac_os_x', 'suse', 'amazon')
pkgs += %w(gtar) if platform?('freebsd') || platform?('smartos')
pkgs += %w(gmake) if platform?('freebsd')
if platform_family?('rhel', 'suse')
if platform_family?('rhel', 'suse', 'amazon')
if node['platform_version'].to_i >= 7
pkgs += %w(xz bzip2 tar)
elsif node['platform_version'].to_i < 7

File diff suppressed because one or more lines are too long

View File

@ -523,6 +523,6 @@ action :configure do
end
end
action_class.class_eval do
action_class do
include ::Ark::ProviderHelpers
end

View File

@ -2,6 +2,15 @@
This file is used to list changes made in each version of the build-essential cookbook.
## 8.0.3 (2017-05-30)
- Fix solaris metadata in metadata.rb
- Remove mac_os_x_server from metata as it's not a platform
## 8.0.2 (2017-05-06)
- Remove buggy action_class.class_eval usage
## 8.0.1 (2017-04-14)
- Test with local delivery and not Rake

File diff suppressed because one or more lines are too long

View File

@ -44,7 +44,7 @@ action :install do
end
end
action_class.class_eval do
action_class do
#
# Determine if the XCode Command Line Tools are installed
#

View File

@ -2,6 +2,23 @@
This file is used to list changes made in each version of the chef_client_updater cookbook.
## 1.1.1 (2017-05-11)
- Fix the initial load of mixlib-install failing
## 1.1.0 (2017-05-10)
- Add support for download URL overrides via new properties on the resource and attributes for the default recipe. This requires mixlib-install 3.2.1, which we now ensure we install in the updater resource.
- Update the default post_install action in the recipe to match the resource (exec).
- Remove usage of class_eval in the resource since we use compat_resource and class_eval causes issues with some later Chef 12 releases.
- Fix the solaris platform name in the metadata.rb.
- Remove disabling FC016 and FC023 Foodcritic rules as these no longer alert.
- Avoid infinite loops if trying to install the latest chef-client version from any channel.
- Add a true test recipe and remove unused inspec tests
- Add debug logging of the current vs. desired versions to help troubleshooting
- Added a blurb in the readme outlining init system issues surrounding kill and the chef-client starting back up
## 1.0.2 (2017-04-07)
- Fix Chef 13 compatibility by using Kernel.exec not exec

View File

@ -18,10 +18,16 @@ This cookbook updates the chef-client
- compat_resource
### Usage
## Usage
This cookbook provides both a custom resource and a default recipe. The default recipe simply uses the custom resource with a set of attributes. You can add chef_client_updater::default to your run list or use the custom resource in a wrapper cookbook.
### Init System Caveats
When Chef runs as a service under a system init daemon such as Sys-V or systemd each chef run forks off from the main chef-client process being managed by the init system. For a chef-client upgrade to occur the running chef-client as well as the parent process must be killed, and a new chef-client must start using the updated binaries. This cookbook handles killing the chef-client, but your init system must properly handle starting the service back up. For systemd and upstart this can be handled via configuration, and chef-client cookbook 8.1.1 or later handles this by default. This functionality is not available in sys-v (RHEL 6, Debian 7, and others), so you will need to employ a secondary process such as a monitoring system to start the chef-client service.
## Resources
### chef_client_updater
Installs the mixlib-install/mixlib-install gems and upgrades the chef-client.
@ -34,6 +40,8 @@ Installs the mixlib-install/mixlib-install gems and upgrades the chef-client.
- `post_install_action` - After installing the chef-client what should we do. `exec` to exec the new client or `kill` to kill the client and rely on the init system to start up the new version. Default: `exec`
- `exec_command` - The chef-client command. default: $PROGRAM_NAME.split(' ').first
- `exec_args` - An array of arguments to exec the chef-client with. default: ARGV
- `download_url_override` - The direct URL for the chef-client package.
- `checksum` - The SHA-256 checksum of the chef-client package from the direct URL.
#### examples

View File

@ -26,4 +26,10 @@ default['chef_client_updater']['prevent_downgrade'] = true
default['chef_client_updater']['version'] = 'latest'
# kill the client post install or exec the client post install for non-service based installs
default['chef_client_updater']['post_install_action'] = 'kill'
default['chef_client_updater']['post_install_action'] = 'exec'
# the download URL (for use in an air-gapped environment)
default['chef_client_updater']['download_url_override'] = nil
# the checksum of the package from "download_url_override"
default['chef_client_updater']['checksum'] = nil

View File

@ -1 +1 @@
{"name":"chef_client_updater","version":"1.0.2","description":"Upgrades chef-client to specified releases","long_description":"Upgrades chef-client to specified releases","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","debian":">= 0.0.0","mac_os_x":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","oracle":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0","solaris":">= 0.0.0","suse":">= 0.0.0","ubuntu":">= 0.0.0","windows":">= 0.0.0","aix":">= 0.0.0"},"dependencies":{"compat_resource":">= 12.16.3"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/chef_client_updater","issues_url":"https://github.com/chef-cookbooks/chef_client_updater/issues","chef_version":[[">= 12.1"]],"ohai_version":[]}
{"name":"chef_client_updater","version":"1.1.1","description":"Upgrades chef-client to specified releases","long_description":"Upgrades chef-client to specified releases","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","debian":">= 0.0.0","mac_os_x":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","oracle":">= 0.0.0","redhat":">= 0.0.0","scientific":">= 0.0.0","solaris2":">= 0.0.0","suse":">= 0.0.0","ubuntu":">= 0.0.0","windows":">= 0.0.0","aix":">= 0.0.0"},"dependencies":{"compat_resource":">= 12.16.3"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/chef_client_updater","issues_url":"https://github.com/chef-cookbooks/chef_client_updater/issues","chef_version":[[">= 12.1"]],"ohai_version":[]}

View File

@ -22,4 +22,6 @@ chef_client_updater 'update chef-client' do
version node['chef_client_updater']['version']
prevent_downgrade node['chef_client_updater']['prevent_downgrade']
post_install_action node['chef_client_updater']['post_install_action']
download_url_override node['chef_client_updater']['download_url_override'] if node['chef_client_updater']['download_url_override']
checksum node['chef_client_updater']['checksum'] if node['chef_client_updater']['checksum']
end

View File

@ -26,9 +26,11 @@ property :version, [String, Symbol], default: :latest
property :post_install_action, String, default: 'exec'
property :exec_command, String, default: $PROGRAM_NAME.split(' ').first
property :exec_args, Array, default: ARGV
property :download_url_override, String
property :checksum, String
action :update do
if update_necessary? # ~FC023
if update_necessary?
converge_by "Upgraded chef-client #{current_version} to #{desired_version}" do
upgrade_command = Mixlib::ShellOut.new(mixlib_install.install_command)
upgrade_command.run_command
@ -37,12 +39,14 @@ action :update do
end
end
action_class.class_eval do
action_class do
def load_mixlib_install
gem 'mixlib-install', '~> 3.2', '>= 3.2.1'
require 'mixlib/install'
rescue LoadError
Chef::Log.info('mixlib-install gem not found. Installing now')
chef_gem 'mixlib-install' do
version '>= 3.2.1'
compile_time true if respond_to?(:compile_time)
end
@ -69,6 +73,9 @@ action_class.class_eval do
product_version: new_resource.version == 'latest' ? :latest : new_resource.version,
}
if new_resource.download_url_override && new_resource.checksum
options[:install_command_options] = { download_url_override: new_resource.download_url_override, checksum: new_resource.checksum }
end
Mixlib::Install.new(options)
end
@ -80,7 +87,7 @@ action_class.class_eval do
end
def desired_version
new_resource.version == 'latest' ? mixlib_install.available_versions.last : new_resource.version
new_resource.version.to_sym == :latest ? mixlib_install.available_versions.last : new_resource.version
end
# why wouldn't we use the built in update_available? method in mixlib-install?
@ -90,6 +97,7 @@ action_class.class_eval do
load_mixlib_versioning
cur_version = Mixlib::Versioning.parse(current_version)
des_version = Mixlib::Versioning.parse(desired_version)
Chef::Log.debug("The current chef-client version is #{cur_version} and the desired version is #{desired_version}")
new_resource.prevent_downgrade ? (des_version > cur_version) : (des_version != cur_version)
end

View File

@ -2,6 +2,21 @@
This file is used to list changes made in each version of the nginx cookbook.
## 6.1.1 (2017-06-08)
- Use multipackage installs in the pagespeed recipe to speed things up
- Several fixes for Amazon Linux on Chef 13+
## 6.1.0 (2017-06-07)
- Add attributes for setting the repository URLs
- Fix support for Amazon Linux repos on Chef 13+
## 6.0.3 (2017-06-05)
- Correctly compare nginx versions with multiple digits so 1.10 is properly recognized as coming after 1.2.
## 6.0.2 (2017-04-27)
- Resolve name conflicts in the resource

View File

@ -26,11 +26,11 @@ The following cookbooks are direct dependencies because they're used for common
The following platforms are supported and tested with Test Kitchen:
- Ubuntu 12.04+
- CentOS 5+
- Ubuntu 14.04+
- CentOS 6+
- Debian 7+
- openSUSE 13.2+
- FreeBSD 9+
- openSUSE
- FreeBSD
Other Debian and RHEL family distributions are assumed to work.
@ -119,14 +119,6 @@ Generally used attributes. Some have platform specific values. See `attributes/d
- `node['nginx']['extra_configs']` - a Hash of key/values to nginx configuration.
### chef_nginx::echo
These attributes are used in the `chef_nginx::http_echo_module` recipe.
- `node['nginx']['echo']['version']` - The version of `http_echo` you want (default: 0.59)
- `node['nginx']['echo']['url']` - URL for the tarball.
- `node['nginx']['echo']['checksum']` - Checksum of the tarball.
### chef_nginx::devel
These attributes are used in the `chef_nginx::ngx_devel_module` recipe.
@ -135,6 +127,14 @@ These attributes are used in the `chef_nginx::ngx_devel_module` recipe.
- `node['nginx']['devel']['url']` - The URL of the nginx devel module tar.gz file
- `node['nginx']['devel']['checksum']` - The checksum of the nginx devel module tar.gz file
### chef_nginx::echo
These attributes are used in the `chef_nginx::http_echo_module` recipe.
- `node['nginx']['echo']['version']` - The version of `http_echo` you want (default: 0.59)
- `node['nginx']['echo']['url']` - URL for the tarball.
- `node['nginx']['echo']['checksum']` - Checksum of the tarball.
### chef_nginx::geoip
These attributes are used in the `chef_nginx::http_geoip_module` recipe. Please note that the `country_dat_checksum` and `city_dat_checksum` are based on downloads from a datacenter in Fremont, CA, USA. You really should override these with checksums for the geo tarballs from your node location.
@ -159,6 +159,13 @@ From: <http://nginx.org/en/docs/http/ngx_http_realip_module.html>
- `node['nginx']['realip']['addresses']` - Addresses to use for the `http_realip` configuration.
- `node['nginx']['realip']['real_ip_recursive']` - If recursive search is enabled, the original client address that matches one of the trusted addresses is replaced by the last non-trusted address sent in the request header field. Can be on "on" or "off" (default).
### chef_nginx::openssl_source
These attributes are used in the `chef_nginx::openssl_source` recipe.
- `node['nginx']['openssl_source']['version']` - The version of OpenSSL you want to download and use (default: 1.0.1t)
- `node['nginx']['openssl_source']['url']` - The url for the OpenSSL source
### chef_nginx::passenger
These attributes are used in the `chef_nginx::passenger` recipe.
@ -184,13 +191,6 @@ Basic configuration to use the official Phusion Passenger repositories:
- `node['nginx']['package_name']` - 'nginx-extras'
- `node['nginx']['passenger']['install_method']` - 'package'
### chef_nginx::openssl_source
These attributes are used in the `chef_nginx::openssl_source` recipe.
- `node['nginx']['openssl_source']['version']` - The version of OpenSSL you want to download and use (default: 1.0.1t)
- `node['nginx']['openssl_source']['url']` - The url for the OpenSSL source
### chef_nginx::rate_limiting
- `node['nginx']['enable_rate_limiting']` - set to true to enable rate limiting (`limit_req_zone` in nginx.conf)
@ -198,6 +198,11 @@ These attributes are used in the `chef_nginx::openssl_source` recipe.
- `node['nginx']['rate_limiting_backoff']` - sets the backoff time for `limit_req_zone`.
- `node['nginx']['rate_limit']` - set the rate limit amount for `limit_req_zone`.
### chef_nginx::repo
- `node['nginx']['upstream_repository']` - the URL to use for the package repository resource; default is set based on platform type
- `node['nginx']['repo_signing_key']` - The URL from which package signing/gpg key is retrieved
### chef_nginx::socketproxy
These attributes are used in the `chef_nginx::socketproxy` recipe.

View File

@ -41,11 +41,7 @@ default['nginx']['repo_source'] = 'nginx'
default['nginx']['install_method'] = 'package'
case node['platform_family']
when 'debian'
default['nginx']['user'] = 'www-data'
when 'rhel'
default['nginx']['user'] = 'nginx'
when 'fedora'
when 'rhel', 'fedora', 'amazon'
default['nginx']['user'] = 'nginx'
when 'freebsd'
default['nginx']['package_name'] = 'www/nginx'
@ -57,7 +53,7 @@ when 'freebsd'
when 'suse'
default['nginx']['user'] = 'wwwrun'
default['nginx']['group'] = 'www'
else
else # debian probably
default['nginx']['user'] = 'www-data'
end

View File

@ -19,17 +19,24 @@
# limitations under the License.
#
case node['platform_family']
when 'rhel', 'fedora'
default['nginx']['upstream_repository'] = case node['platform']
when 'centos'
# See http://wiki.nginx.org/Install
"http://nginx.org/packages/centos/#{node['platform_version'].to_i}/$basearch/"
when 'amazon'
'http://nginx.org/packages/rhel/6/$basearch/'
else
"http://nginx.org/packages/rhel/#{node['platform_version'].to_i}/$basearch/"
end
when 'debian'
default['nginx']['upstream_repository'] = "http://nginx.org/packages/#{node['platform']}"
end
default['nginx']['upstream_repository'] =
case node['platform_family']
when 'amazon' # Chef 13+ on amazon linux
'http://nginx.org/packages/rhel/6/$basearch/'
when 'rhel', 'fedora'
case node['platform']
when 'centos'
# See http://wiki.nginx.org/Install
"http://nginx.org/packages/centos/#{node['platform_version'].to_i}/$basearch/"
when 'amazon' # Chef < 13 on Amazon
'http://nginx.org/packages/rhel/6/$basearch/'
else
"http://nginx.org/packages/rhel/#{node['platform_version'].to_i}/$basearch/"
end
when 'debian'
"http://nginx.org/packages/#{node['platform']}"
when 'suse'
'http://nginx.org/packages/sles/12'
end
default['nginx']['repo_signing_key'] = 'http://nginx.org/keys/nginx_signing.key'

View File

@ -0,0 +1,37 @@
class NginxVersion
include Comparable
attr_reader :version
def initialize(version)
@version = version
end
def <=>(other)
lhsegments = segments
rhsegments = other.segments
parts = [lhsegments.size, rhsegments.size].max
(0..(parts - 1)).each do |index|
lhs = lhsegments[index] || 0
rhs = rhsegments[index] || 0
next if lhs == rhs
return lhs <=> rhs
end
0
end
def to_s
version
end
protected
def segments
version.split('.').map { |part| Integer(part) }
end
end

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,7 @@ end
end
end
if !node['nginx']['default_site_enabled'] && platform_family?('rhel', 'fedora')
if !node['nginx']['default_site_enabled'] && platform_family?('rhel', 'fedora', 'amazon')
%w(default.conf example_ssl.conf).each do |config|
file "/etc/nginx/conf.d/#{config}" do
action :delete

View File

@ -22,7 +22,7 @@ remote_file psol_src_filepath do
end
package_array = value_for_platform_family(
%w(rhel) => node['nginx']['pagespeed']['packages']['rhel'],
%w(rhel amazon) => node['nginx']['pagespeed']['packages']['rhel'],
%w(debian) => node['nginx']['pagespeed']['packages']['debian']
)

View File

@ -18,16 +18,12 @@
#
packages = value_for_platform_family(
%w(rhel) => node['nginx']['passenger']['packages']['rhel'],
%w(rhel amazon) => node['nginx']['passenger']['packages']['rhel'],
%w(fedora) => node['nginx']['passenger']['packages']['fedora'],
%w(debian) => node['nginx']['passenger']['packages']['debian']
)
unless packages.empty?
packages.each do |name|
package name
end
end
package packages unless packages.empty?
gem_package 'rake' if node['nginx']['passenger']['install_rake']

View File

@ -19,12 +19,12 @@
#
case node['platform_family']
when 'rhel'
when 'rhel', 'amazon'
yum_repository 'nginx' do
description 'Nginx.org Repository'
baseurl node['nginx']['upstream_repository']
gpgkey 'http://nginx.org/keys/nginx_signing.key'
gpgkey node['nginx']['repo_signing_key']
action :create
end
@ -32,8 +32,8 @@ when 'suse'
zypper_repo 'nginx' do
repo_name 'Nginx.org Repository'
uri 'http://nginx.org/packages/sles/12'
key 'http://nginx.org/keys/nginx_signing.key'
uri node['nginx']['upstream_repository']
key node['nginx']['repo_signing_key']
end
when 'debian'
@ -43,7 +43,7 @@ when 'debian'
distribution node['lsb']['codename']
components %w(nginx)
deb_src true
key 'http://nginx.org/keys/nginx_signing.key'
key node['nginx']['repo_signing_key']
end
else

View File

@ -21,7 +21,7 @@
# limitations under the License.
#
raise "#{node['platform']} is not a supported platform in the nginx::source recipe" unless platform_family?('rhel', 'fedora', 'debian', 'suse')
raise "#{node['platform']} is not a supported platform in the nginx::source recipe" unless platform_family?('rhel', 'amazon', 'fedora', 'debian', 'suse')
node.normal['nginx']['binary'] = node['nginx']['source']['sbin_path']
node.normal['nginx']['daemon_disable'] = true
@ -42,7 +42,7 @@ src_filepath = "#{Chef::Config['file_cache_path']}/nginx-#{node['nginx']['source
# install prereqs
package value_for_platform_family(
%w(rhel fedora) => %w(pcre-devel openssl-devel tar),
%w(rhel fedora amazon) => %w(pcre-devel openssl-devel tar),
%w(suse) => %w(pcre-devel libopenssl-devel tar),
%w(debian) => %w(libpcre3 libpcre3-dev libssl-dev tar)
)

View File

@ -2,6 +2,6 @@
set_real_ip_from <%= address %>;
<% end -%>
real_ip_header <%= node['nginx']['realip']['header'] %>;
<% if node['nginx']['version'].to_f >= 1.2 -%>
<% if NginxVersion.new(node['nginx']['version']) >= NginxVersion.new('1.2') -%>
real_ip_recursive <%= node['nginx']['realip']['real_ip_recursive'] %>;
<% end -%>

View File

@ -2,6 +2,11 @@
This file is used to list changes made in each version of the compat_resource cookbook.
## 12.19.0 (2017-04-17)
- Suppress warning already initialized constant
- Backport yum/apt changes from 12.19
## 12.16.2 (2016-11-09)
- Sync chef-client changes from Chef 12.16.42

View File

@ -4,8 +4,13 @@
[<%= @config.repositoryid %>]
name=<%= @config.description %>
<% if @config.baseurl %>
baseurl=<%= @config.baseurl %>
<% end %>
baseurl=<%= case @config.baseurl
when Array
@config.baseurl.join("\n")
else
@config.baseurl
end %>
<% end -%>
<% if @config.cost %>
cost=<%= @config.cost %>
<% end %>
@ -24,7 +29,9 @@ exclude=<%= @config.exclude %>
failovermethod=<%= @config.failovermethod %>
<% end %>
<% if @config.fastestmirror_enabled %>
fastestmirror_enabled=<%= @config.fastestmirror_enabled %>
fastestmirror_enabled=1
<% else %>
fastestmirror_enabled=0
<% end %>
<% if @config.gpgcheck %>
gpgcheck=1

View File

@ -89,16 +89,15 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
end
action :delete do
declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
action :delete
notifies :run, "execute[yum clean all #{new_resource.repositoryid}]", :immediately
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
end
# clean the repo cache first
declare_resource(:execute, "yum clean all #{new_resource.repositoryid}") do
command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
only_if "yum repolist | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
action :nothing
only_if "yum repolist all | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
end
declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
action :delete
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
end
declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do

View File

@ -54,7 +54,6 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
property :cookbook, [String, nil, false], default: nil, desired_state: false, nillable: true, coerce: proc { |x| x ? x : nil }
property :cache_rebuild, [TrueClass, FalseClass], default: true, desired_state: false
property :sensitive, [TrueClass, FalseClass], default: false, desired_state: false
default_action :add
allowed_actions :add, :remove

View File

@ -38,7 +38,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object)
class AptUpdate < (defined?(::Chef::Resource::AptUpdate) ? ::Chef::Resource::AptUpdate : Chef::Resource)
resource_name :apt_update
provides :apt_update, os: "linux"
provides :apt_update
property :frequency, Integer, default: 86_400

View File

@ -41,7 +41,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
provides :yum_repository
# http://linux.die.net/man/5/yum.conf
property :baseurl, String, regex: /.*/
property :baseurl, [String, Array], regex: /.*/
property :cost, String, regex: /^\d+$/
property :clean_headers, [TrueClass, FalseClass], default: false # deprecated
property :clean_metadata, [TrueClass, FalseClass], default: true
@ -74,7 +74,6 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
property :repo_gpgcheck, [TrueClass, FalseClass]
property :report_instanceid, [TrueClass, FalseClass]
property :repositoryid, String, regex: /.*/, name_property: true
property :sensitive, [TrueClass, FalseClass], default: false
property :skip_if_unavailable, [TrueClass, FalseClass]
property :source, String, regex: /.*/
property :sslcacert, String, regex: /.*/

View File

@ -1,3 +1,3 @@
module ChefCompat
CHEF_UPSTREAM_VERSION="12.16.42"
CHEF_UPSTREAM_VERSION="12.16.42" unless defined? CHEF_UPSTREAM_VERSION
end

View File

@ -1 +1 @@
{"name":"compat_resource","version":"12.16.3","description":"Backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards","long_description":"# compat_resource cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/compat_resource.svg?branch=master)](https://travis-ci.org/chef-cookbooks/compat_resource) [![Cookbook Version](https://img.shields.io/cookbook/v/compat_resource.svg)](https://supermarket.chef.io/cookbooks/compat_resource)\n\nThis cookbook backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards. This includes [Custom Resource](https://docs.chef.io/custom_resources.html) functionality, notification improvements, as well as new resources added to core chef. It allows for the usage of these new resources in cookbooks without requiring the very latest Chef client release.\n\n## Backported functionality\n\n- [Custom Resources](https://docs.chef.io/custom_resources.html)\n- [apt_repository](https://docs.chef.io/resource_apt_repository.html)\n- [apt_update](https://docs.chef.io/resource_apt_update.html)\n- [systemd_unit](https://docs.chef.io/resource_systemd_unit.html)\n- [yum_repository](https://docs.chef.io/resource_yum_repository.html)\n- [:before notifications](https://docs.chef.io/resources.html#timers)\n\n## Requirements\n\n### Platforms\n\n- All platforms supported by Chef\n\n### Chef\n\n- Chef 12.1+\n\n### Cookbooks\n\n- none\n\n## Usage\n\nTo use this cookbook, put `depends 'compat_resource'` in the metadata.rb of your cookbook. Once this is done, you can use all the new custom resource features to define resources. It Just Works.\n\n## Custom Resources?\n\nCurious about how to use custom resources?\n\n- Docs: <https://docs.chef.io/custom_resources.html>\n- Slides: <https://docs.chef.io/decks/custom_resources.html>\n\n## License & Authors\n\n- Author:: Lamont Granquist ([lamont@chef.io](mailto:lamont@chef.io))\n- Author:: John Keiser ([jkeiser@chef.io](mailto:jkeiser@chef.io))\n\n```text\nCopyright:: 2015-2016 Chef Software, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Lamont Granquist","maintainer_email":"lamont@chef.io","license":"Apache 2.0","platforms":{},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/compat_resource","issues_url":"https://github.com/chef-cookbooks/compat_resource/issues","chef_version":">= 12.1","ohai_version":{}}
{"name":"compat_resource","version":"12.19.0","description":"Backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards","long_description":"# compat_resource cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/compat_resource.svg?branch=master)](https://travis-ci.org/chef-cookbooks/compat_resource) [![Cookbook Version](https://img.shields.io/cookbook/v/compat_resource.svg)](https://supermarket.chef.io/cookbooks/compat_resource)\n\nThis cookbook backports functionality introduced in the latest chef-client releases to any chef-client from 12.1 onwards. This includes [Custom Resource](https://docs.chef.io/custom_resources.html) functionality, notification improvements, as well as new resources added to core chef. It allows for the usage of these new resources in cookbooks without requiring the very latest Chef client release.\n\n## Backported functionality\n\n- [Custom Resources](https://docs.chef.io/custom_resources.html)\n- [apt_repository](https://docs.chef.io/resource_apt_repository.html)\n- [apt_update](https://docs.chef.io/resource_apt_update.html)\n- [systemd_unit](https://docs.chef.io/resource_systemd_unit.html)\n- [yum_repository](https://docs.chef.io/resource_yum_repository.html)\n- [:before notifications](https://docs.chef.io/resources.html#timers)\n\n## Requirements\n\n### Platforms\n\n- All platforms supported by Chef\n\n### Chef\n\n- Chef 12.1+\n\n### Cookbooks\n\n- none\n\n## Usage\n\nTo use this cookbook, put `depends 'compat_resource'` in the metadata.rb of your cookbook. Once this is done, you can use all the new custom resource features to define resources. It Just Works.\n\n## Custom Resources?\n\nCurious about how to use custom resources?\n\n- Docs: <https://docs.chef.io/custom_resources.html>\n- Slides: <https://docs.chef.io/decks/custom_resources.html>\n\n## License & Authors\n\n- Author:: Lamont Granquist ([lamont@chef.io](mailto:lamont@chef.io))\n- Author:: John Keiser ([jkeiser@chef.io](mailto:jkeiser@chef.io))\n\n```text\nCopyright:: 2015-2016 Chef Software, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Lamont Granquist","maintainer_email":"lamont@chef.io","license":"Apache 2.0","platforms":{},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/compat_resource","issues_url":"https://github.com/chef-cookbooks/compat_resource/issues","chef_version":[[">= 12.1"]],"ohai_version":[]}

View File

@ -2,6 +2,12 @@ firewall Cookbook CHANGELOG
=======================
This file is used to list changes made in each version of the firewall cookbook.
v2.6.2 (2017-06-01)
-------------------
* Incorrect file checking on Ubuntu, double file write (#173)
* Added testing on CentOS 6.9
* Clarify metadata that we're not working on Amazon Linux (#172)
v2.6.1 (2017-04-21)
-------------------
* Add recipe to disable firewall (#164)

View File

@ -43,7 +43,7 @@ class Chef
rule_files = %w(rules.v4)
rule_files << 'rules.v6' if ipv6_enabled?(new_resource)
rule_files.each do |svc|
next unless ::File.exist?("/etc/iptables/#{svc}")
next if ::File.exist?("/etc/iptables/#{svc}")
# must create empty file for service to start
f = lookup_or_create_rulesfile(svc)

View File

@ -43,7 +43,7 @@ class Chef
rule_files = %w(rules.v4)
rule_files << 'rules.v6' if ipv6_enabled?(new_resource)
rule_files.each do |svc|
next unless ::File.exist?("/etc/iptables/#{svc}")
next if ::File.exist?("/etc/iptables/#{svc}")
# must create empty file for service to start
f = lookup_or_create_rulesfile(svc)

File diff suppressed because one or more lines are too long

View File

@ -13,3 +13,4 @@ Gemfile.lock
\#*#
bin/*
metadata.json
Gemfile.lock

View File

@ -4,58 +4,31 @@ driver_config:
require_chef_omnibus: true
platforms:
- name: ubuntu-14.04
driver_config:
box: opscode_ubuntu-14.04_provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
- name: ubuntu-12.04
driver_config:
box: opscode_ubuntu-12.04_provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box
- name: ubuntu-10.04
driver_config:
box: opscode_ubuntu-10.04_provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-10.04_chef-provisionerless.box
- name: debian-6
driver_config:
box: opscode_debian-6.0.8_provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-6.0.8_chef-provisionerless.box
- name: debian-7
driver_config:
box: opscode_debian-7.2.0_provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.2.0_chef-provisionerless.box
- name: centos-6.4
driver_config:
box: opscode_centos-6.4_provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.4_chef-provisionerless.box
#- name: freebsd-9.2
# driver_config:
# box: opscode_freebsd-9.2_provisionerless
# box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_freebsd-9.2_chef-provisionerless.box
- name: freebsd-10
driver_config:
box: opscode_freebsd-10.0_provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_freebsd-10.0_chef-provisionerless.box
- name: fedora-19
driver_config:
box: opscode_fedora-19_chef-provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-19_chef-provisionerless.box
- name: fedora-20
driver_config:
box: opscode_fedora-20_chef-provisionerless
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_fedora-20_chef-provisionerless.box
- name: ubuntu-12.04
- name: ubuntu-14.04
- name: ubuntu-16.04
- name: debian-7.11
- name: debian-8.5
- name: centos-6.8
- name: centos-7.2
- name: freebsd-9.3
- name: freebsd-10.3
- name: fedora-21
- name: fedora-22
- name: fedora-23
- name: fedora-24
suites:
- name: default
run_list:
- recipe[hostname::default]
attributes:
set_fqdn: test.example.com
- name: wildcard
run_list:
- recipe[hostname::default]
provisioner:
solo_rb:
node_name: test
attributes:
set_fqdn: '*.example.com'
- name: default
run_list:
- recipe[hostname::default]
attributes:
set_fqdn: test.example.com
- name: wildcard
run_list:
- recipe[hostname::default]
provisioner:
solo_rb:
node_name: test
attributes:
set_fqdn: '*.example.com'

View File

@ -0,0 +1 @@
--color

View File

@ -1,12 +1,23 @@
AllCops:
DisplayCopNames: true
Exclude:
- tmp/**
Documentation:
Lint/AmbiguousBlockAssociation:
Enabled: false
LineLength:
Metrics/BlockLength:
Enabled: false
SingleSpaceBeforeFirstArg:
Metrics/LineLength:
Enabled: false
Style/Documentation:
Exclude:
- Thorfile
Style/PercentLiteralDelimiters:
Enabled: false
Style/SingleSpaceBeforeFirstArg:
Enabled: false

View File

@ -1,9 +1,10 @@
bundler_args: --without integration
before_script: bundle exec berks install
script: bundle exec strainer test
script: bundle exec rake
language: ruby
rvm:
- 1.9.3
- 2.3.1
sudo: false
notifications:
hipchat:
secure: ! 'mTePogP3SZVXbZ8l3o1yN+uszEEwQY3WgBXXXQc4hV1nLGhAXgjgj5ueCKAE

View File

@ -1,8 +1,8 @@
# -*- ruby -*-
source "https://supermarket.getchef.com"
source 'https://supermarket.getchef.com'
metadata
group :integration do
cookbook "minitest-handler"
cookbook 'minitest-handler'
end

View File

@ -1,5 +1,18 @@
# Change History
0.4.2 (2017-05-04)
==================
- #51: Make host file idempotent on RHEL
- #52: Add `append_hostsfile_ip` logic for improved idempotence
- #55: Ensure sysctl `kernel.hostname` set correctly on RHEL
0.4.1 (2017-04-24)
==================
- #43: Set unique hosts file entry for hostname
- #44: Make hostname mapping to `127.0.0.1` optional
- #59: Updates to resolve deprecations warnings
- #60, #61: various test fixes
0.4.0 (2015-03-16)
==================
- #40: Use file resources with lazy eval and notifies to prevent network restarts from occurring on every chef run (Matt Kasa)

View File

@ -1,14 +1,13 @@
source 'https://rubygems.org'
gem 'berkshelf'
gem 'chef', '~> 11.10'
gem 'chef', '~> 12.13'
gem 'chefspec'
gem 'foodcritic', '~> 3.0'
gem 'foodcritic'
gem 'rake'
gem 'strainer'
gem 'rubocop'
group :integration do
gem 'test-kitchen', '~> 1.0'
gem 'kitchen-vagrant'
gem 'test-kitchen'
end

View File

@ -0,0 +1,20 @@
Copyright (c) 2011-2017 Maciej Pasternacki
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,5 +1,7 @@
# hostname cookbook
[![Build Status](https://travis-ci.org/3ofcoins/chef-cookbook-hostname.svg?branch=master)](https://travis-ci.org/3ofcoins/chef-cookbook-hostname)
[![Chef cookbook](https://img.shields.io/cookbook/v/hostname.svg)](https://supermarket.chef.io/cookbooks/hostname)
## Description
Sets hostname and FQDN of the node. The latest code is hosted at
@ -30,7 +32,13 @@ and have node set its FQDN and hostname based on its chef node name
- `node['hostname_cookbook']['hostsfile_ip']` -- IP used in
`/etc/hosts` to correctly set FQDN (default: `127.0.1.1`)
- `node['hostname_cookbook']['hostsfile_aliases']` -- list of aliases used in
`/etc/hosts` for the ip set above (default: [`hostname`])
- `node['hostname_cookbook']['hostsfile_include_hostname_in_aliases']` -- whether to include the hostname
at the end of the aliases list above (default: true)
- `node['hostname_cookbook']['append_hostsfile_ip']` -- Set to `false` to
prevent an entry for the node's hostname from being appended in `/etc/hosts` (default: `true`)
## Recipes

View File

@ -0,0 +1,15 @@
require 'foodcritic'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)
FoodCritic::Rake::LintTask.new do |t|
t.options = {
fail_tags: ['any']
}
end
RSpec::Core::RakeTask.new(:spec)
task default: %w[foodcritic rubocop spec]

View File

@ -1,4 +0,0 @@
rubocop: rubocop $COOKBOOK
knife test: knife cookbook test $COOKBOOK
foodcritic: foodcritic -c 11.6.0 --tags ~FC015 --epic-fail any $SANDBOX/$COOKBOOK
chefspec: rspec $SANDBOX/$COOKBOOK

View File

@ -13,13 +13,12 @@ And then, to install all cookbooks:
Local
-----
$ bundle exec strainer test
$ bundle exec rake
The above runs:
- rubocop
- `knife cookbook test` tests
- Food Critic lint
- rubocop lint
- Foodcritic lint
- Chefspec tests
Chefspec tests (the interesting part) are in `spec/`.

View File

@ -6,12 +6,12 @@ require 'bundler/setup'
require 'shellwords'
class Cookbook < Thor
COOKBOOK_NAME = 'hostname'
COOKBOOK_CATEGORY = 'utilities'
COOKBOOK_NAME = 'hostname'.freeze
COOKBOOK_CATEGORY = 'utilities'.freeze
include Thor::Actions
desc :edit, "Edit cookbook in browser"
desc :edit, 'Edit cookbook in browser'
def edit
open "http://community.opscode.com/cookbooks/#{COOKBOOK_NAME}/edit"
end
@ -35,7 +35,7 @@ class Cookbook < Thor
def open_cmd
@open_cmd ||= %w[open xdg-open].find do |command|
system "which #{command} >/dev/null 2>&1"
$?.success?
$CHILD_STATUS.success?
end
end
end

View File

@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
default['hostname_cookbook']['hostsfile_ip'] = '127.0.1.1'
default['hostname_cookbook']['hostsfile_ip_interface'] = 'lo0' if platform == 'freebsd'
default['hostname_cookbook']['hostsfile_ip_interface'] = 'lo0' if node['platform'] == 'freebsd'
default['hostname_cookbook']['hostsfile_aliases'] = []
default['hostname_cookbook']['hostsfile_include_hostname_in_aliases'] = true
default['hostname_cookbook']['append_hostsfile_ip'] = true

View File

@ -6,10 +6,15 @@ maintainer_email 'maciej@3ofcoins.net'
license 'MIT'
description 'Configures hostname and FQDN'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.4.0'
version '0.4.2'
supports 'debian'
supports 'ubuntu'
supports 'freebsd'
depends 'hostsfile'
source_url 'https://github.com/3ofcoins/chef-cookbook-hostname' if respond_to?(:source_url)
issues_url 'https://github.com/3ofcoins/chef-cookbook-hostname/issues' if respond_to?(:issues_url)
chef_version '>= 12.1' if respond_to?(:chef_version)

View File

@ -31,7 +31,10 @@ if fqdn
fqdn =~ /^([^.]+)/
hostname = Regexp.last_match[1]
case node['platform']
aliases = node['hostname_cookbook']['hostsfile_aliases']
aliases += [hostname] if node['hostname_cookbook']['hostsfile_include_hostname_in_aliases']
case node['platform_family']
when 'freebsd'
directory '/etc/rc.conf.d' do
mode '0755'
@ -56,7 +59,7 @@ if fqdn
notifies :reload, 'ohai[reload_hostname]', :immediately
end
when 'centos', 'redhat', 'amazon', 'scientific'
when 'rhel'
service 'network' do
action :nothing
end
@ -66,6 +69,7 @@ if fqdn
content lazy {
::IO.read(hostfile).gsub(/^HOSTNAME=.*$/, "HOSTNAME=#{fqdn}")
}
not_if { ::IO.read(hostfile) =~ /^HOSTNAME=#{fqdn}$/ }
notifies :reload, 'ohai[reload_hostname]', :immediately
notifies :restart, 'service[network]', :delayed
end
@ -73,10 +77,13 @@ if fqdn
sysctl = '/etc/sysctl.conf'
file sysctl do
action :create
regex = /^kernel\.hostname=.*/
newline = "kernel.hostname=#{hostname}"
content lazy {
::IO.read(sysctl) + "kernel.hostname=#{hostname}\n"
original = ::IO.read(sysctl)
original.match(regex) ? original.gsub(regex, newline) : original + newline
}
not_if { ::IO.read(sysctl) =~ /^kernel\.hostname=#{hostname}$/ }
not_if { ::IO.read(sysctl).scan(regex).last == newline }
notifies :reload, 'ohai[reload_hostname]', :immediately
notifies :restart, 'service[network]', :delayed
end
@ -84,6 +91,14 @@ if fqdn
only_if { node['hostname'] != hostname }
notifies :reload, 'ohai[reload_hostname]', :immediately
end
# update /etc/hostname in RHEL7+
file '/etc/hostname' do
content "#{hostname}\n"
mode '0644'
only_if { ::File.exist?('/etc/hostname') }
notifies :reload, 'ohai[reload_hostname]', :immediately
end
else
file '/etc/hostname' do
content "#{hostname}\n"
@ -106,9 +121,11 @@ if fqdn
hostsfile_entry 'set hostname' do
ip_address node['hostname_cookbook']['hostsfile_ip']
hostname fqdn
aliases [hostname]
aliases aliases
unique true
action :create
notifies :reload, 'ohai[reload_hostname]', :immediately
only_if { node['hostname_cookbook']['append_hostsfile_ip'] }
end
ohai 'reload_hostname' do

View File

@ -1,3 +1,15 @@
*.rbc
.config
coverage
InstalledFiles
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
_Store
*~
*#
.#*
@ -7,19 +19,33 @@
*.tmp
*.bk
*.bkup
.kitchen.local.yml
Berksfile.lock
.bundle/
.cache/
.kitchen/
.vagrant/
.vagrant.d/
bin/
tmp/
vendor/
# RVM
# ruby/bundler files
.ruby-version
.ruby-gemset
.rvmrc
.rvmrc
Gemfile.lock
.bundle
*.gem
# YARD artifacts
.yardoc
_yardoc
doc/
.idea
# chef stuff
Berksfile.lock
.kitchen
.kitchen.local.yml
vendor/
.coverage/
.zero-knife.rb
Policyfile.lock.json
Cheffile.lock
.librarian/
# vagrant stuff
.vagrant/
.vagrant.d/
.kitchen/

View File

@ -1,12 +1,21 @@
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true
driver:
name: vagrant
provisioner:
name: chef_zero
# We have tests that ensure our deprecated features still
# work so we can't turn this on globally.
# deprecations_as_errors: true
platforms:
- name: ubuntu-12.04
run_list:
- recipe[fake::prep]
- name: centos-6.7
- name: centos-6.8
- name: centos-7.3
# - name: debian-7.11
- name: debian-8.6
- name: fedora-25
- name: opensuse-leap-42.1
- name: ubuntu-14.04
- name: ubuntu-16.04
suites:
- name: default

View File

@ -1,4 +0,0 @@
AllCops:
Exclude:
- vendor/**
- .kitchen/**

View File

@ -1,10 +1,20 @@
# Use Travis's cointainer based infrastructure
sudo: false
addons:
apt:
sources:
- chef-stable-precise
packages:
- chefdk
branches:
only:
- master
language: ruby
cache: bundler
rvm:
- 2.2
# Ensure we make ChefDK's Ruby the default
install: echo "Using ChefDK for all dependencies"
before_script:
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
script:
- make travis

View File

@ -1,7 +1,7 @@
source "https://supermarket.getchef.com"
source 'https://supermarket.chef.io'
metadata
group :development do
cookbook "fake", path: "test/fixtures/cookbooks/fake"
cookbook 'fake', path: 'test/fixtures/cookbooks/fake'
end

View File

@ -3,6 +3,34 @@ logrotate Cookbook CHANGELOG
This file is used to list changes made in each version of the
logrotate cookbook.
v2.2.0
------
# Compatibility Notes
The `compat_resource` dependency was removed. This means we now
require Chef 12.5 or higher. It also means we now better support Chef
13.
# Enhancements
- The global configuration now supports scripts.
- The package install action (upgrade by default) is now configurable
via an attribute.
- The development environment now more closely follows modern cookbook
practices.
# Bug Fixes
- ChefSpec matcher now correctly calls ChefSpec.define_matcher.
-
# Contributors
- Austin Heiman
- Baptiste Courtois
- Bogdan Katynski
- Thomas Dziedzic
- Tim Smith
v2.1.0
------

View File

@ -16,7 +16,7 @@
### Requirements
- Ruby 2.0+
- Bundler (`gem install bundler`)
- Latest ChefDK
- [Vagrant](https://vagrantup.com)
- [VirtualBox](https://virtualbox.org)
@ -24,15 +24,15 @@
1. Clone the git repository from GitHub:
$ git clone git@github.com:stevendanna/logrotate.git
git clone git@github.com:stevendanna/logrotate.git
2. Install the dependencies using bundler:
2. Ensure you have ChefDK installed:
$ bundle install
chef --version
3. Create a branch for your changes:
$ git checkout -b my_bug_fix
git checkout -b my_bug_fix
4. Make any changes

View File

@ -1,11 +0,0 @@
source "https://rubygems.org"
gem "berkshelf", "~> 4.0"
gem "chefspec", "~> 4.0"
gem "foodcritic", "~> 6.0"
gem "chefstyle", github: "chef/chefstyle"
group :integration do
gem "test-kitchen", "~> 1.0"
gem "kitchen-vagrant", "~> 0.11"
end

View File

@ -1,275 +0,0 @@
GIT
remote: git://github.com/chef/chefstyle.git
revision: cc37808b7849fdcf49f04011626143940f83fe92
specs:
chefstyle (0.3.1)
rubocop (= 0.39.0)
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
artifactory (2.3.2)
ast (2.2.0)
berkshelf (4.3.2)
addressable (~> 2.3, >= 2.3.4)
berkshelf-api-client (~> 2.0, >= 2.0.2)
buff-config (~> 1.0)
buff-extensions (~> 1.0)
buff-shell_out (~> 0.1)
celluloid (= 0.16.0)
celluloid-io (~> 0.16.1)
cleanroom (~> 1.0)
faraday (~> 0.9)
httpclient (~> 2.7)
minitar (~> 0.5, >= 0.5.4)
octokit (~> 4.0)
retryable (~> 2.0)
ridley (~> 4.5)
solve (~> 2.0)
thor (~> 0.19)
berkshelf-api-client (2.0.2)
faraday (~> 0.9.1)
httpclient (~> 2.7.0)
ridley (~> 4.5)
buff-config (1.0.1)
buff-extensions (~> 1.0)
varia_model (~> 0.4)
buff-extensions (1.0.0)
buff-ignore (1.1.1)
buff-ruby_engine (0.1.0)
buff-shell_out (0.2.0)
buff-ruby_engine (~> 0.1.0)
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
celluloid-io (0.16.2)
celluloid (>= 0.16.0)
nio4r (>= 1.1.0)
chef (12.9.38)
bundler (>= 1.10)
chef-config (= 12.9.38)
chef-zero (~> 4.5)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
ffi-yajl (~> 2.2)
highline (~> 1.6, >= 1.6.9)
mixlib-authentication (~> 1.4)
mixlib-cli (~> 1.4)
mixlib-log (~> 1.3)
mixlib-shellout (~> 2.0)
net-sftp (~> 2.1, >= 2.1.2)
net-ssh (>= 2.9, < 4.0)
net-ssh-multi (~> 1.1)
ohai (>= 8.6.0.alpha.1, < 9)
plist (~> 3.2)
proxifier (~> 1.0)
rspec-core (~> 3.4)
rspec-expectations (~> 3.4)
rspec-mocks (~> 3.4)
rspec_junit_formatter (~> 0.2.0)
serverspec (~> 2.7)
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
chef-config (12.9.38)
fuzzyurl (~> 0.8.0)
mixlib-config (~> 2.0)
mixlib-shellout (~> 2.0)
chef-zero (4.6.1)
ffi-yajl (~> 2.2)
hashie (>= 2.0, < 4.0)
mixlib-log (~> 1.3)
rack
uuidtools (~> 2.1)
chefspec (4.6.1)
chef (>= 11.14)
fauxhai (~> 3.2)
rspec (~> 3.0)
cleanroom (1.0.0)
cucumber-core (1.4.0)
gherkin (~> 3.2.0)
diff-lcs (1.2.5)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
fauxhai (3.3.0)
net-ssh
ffi (1.9.10)
ffi-yajl (2.2.3)
libyajl2 (~> 1.2)
foodcritic (6.1.1)
cucumber-core (>= 1.3)
erubis
nokogiri (>= 1.5, < 2.0)
rake
rufus-lru (~> 1.0)
treetop (~> 1.4)
yajl-ruby (~> 1.1)
fuzzyurl (0.8.0)
gherkin (3.2.0)
hashie (3.4.3)
highline (1.7.8)
hitimes (1.2.3)
httpclient (2.7.1)
ipaddress (0.8.3)
json (1.8.3)
kitchen-vagrant (0.20.0)
test-kitchen (~> 1.4)
libyajl2 (1.2.0)
mini_portile2 (2.0.0)
minitar (0.5.4)
mixlib-authentication (1.4.0)
mixlib-log
rspec-core (~> 3.2)
rspec-expectations (~> 3.2)
rspec-mocks (~> 3.2)
mixlib-cli (1.5.0)
mixlib-config (2.2.1)
mixlib-install (1.0.7)
artifactory
mixlib-shellout
mixlib-versioning
mixlib-log (1.6.0)
mixlib-shellout (2.2.6)
mixlib-versioning (1.1.0)
molinillo (0.4.4)
multi_json (1.11.2)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (3.1.1)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.2.1)
net-ssh (>= 2.6.5)
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
nio4r (1.2.1)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
octokit (4.3.0)
sawyer (~> 0.7.0, >= 0.5.3)
ohai (8.14.0)
chef-config (>= 12.5.0.alpha.1, < 13)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
ipaddress
mixlib-cli
mixlib-config (~> 2.0)
mixlib-log
mixlib-shellout (~> 2.0)
plist (~> 3.1)
systemu (~> 2.6.4)
wmi-lite (~> 1.0)
parser (2.3.0.7)
ast (~> 2.2)
plist (3.2.0)
polyglot (0.3.5)
powerpack (0.1.1)
proxifier (1.0.3)
rack (1.6.4)
rainbow (2.1.0)
rake (11.1.2)
retryable (2.0.3)
ridley (4.5.0)
addressable
buff-config (~> 1.0)
buff-extensions (~> 1.0)
buff-ignore (~> 1.1)
buff-shell_out (~> 0.1)
celluloid (~> 0.16.0)
celluloid-io (~> 0.16.1)
chef-config (>= 12.5.0)
erubis
faraday (~> 0.9.0)
hashie (>= 2.0.2, < 4.0.0)
httpclient (~> 2.7)
json (>= 1.7.7)
mixlib-authentication (>= 1.3.0)
retryable (~> 2.0)
semverse (~> 1.1)
varia_model (~> 0.4.0)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.39.0)
parser (>= 2.3.0.7, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.7.5)
rufus-lru (1.0.5)
safe_yaml (1.0.4)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
semverse (1.2.1)
serverspec (2.31.1)
multi_json
rspec (~> 3.0)
rspec-its
specinfra (~> 2.53)
sfl (2.2)
solve (2.0.3)
molinillo (~> 0.4.2)
semverse (~> 1.1)
specinfra (2.56.1)
net-scp
net-ssh (>= 2.7, < 4.0)
net-telnet
sfl
syslog-logger (1.6.8)
systemu (2.6.5)
test-kitchen (1.7.3)
mixlib-install (~> 1.0, >= 1.0.4)
mixlib-shellout (>= 1.2, < 3.0)
net-scp (~> 1.1)
net-ssh (>= 2.9, < 4.0)
safe_yaml (~> 1.0)
thor (~> 0.18)
thor (0.19.1)
timers (4.0.4)
hitimes
treetop (1.6.5)
polyglot (~> 0.3)
unicode-display_width (1.0.3)
uuidtools (2.1.5)
varia_model (0.4.1)
buff-extensions (~> 1.0)
hashie (>= 2.0.2, < 4.0.0)
wmi-lite (1.0.0)
yajl-ruby (1.2.1)
PLATFORMS
ruby
DEPENDENCIES
berkshelf (~> 4.0)
chefspec (~> 4.0)
chefstyle!
foodcritic (~> 6.0)
kitchen-vagrant (~> 0.11)
test-kitchen (~> 1.0)
BUNDLED WITH
1.11.2

View File

@ -1,13 +1,11 @@
travis: bundle berks
bundle exec chefstyle -D
bundle exec foodcritic .
bundle exec rspec --color --format doc
all: delivery
integration: bundle berks
bundle exec kitchen test
travis: debug_version_info all
bundle:
bundle install
debug_version_info:
/opt/chefdk/embedded/bin/chef --version
/opt/chefdk/embedded/bin/cookstyle --version
/opt/chefdk/embedded/bin/foodcritic --version
berks:
bundle exec berks install
delivery:
/opt/chefdk/bin/chef exec delivery local all

View File

@ -6,11 +6,22 @@ application specific logrotate configuration.
## Requirements
### Platforms
Should work on any platform that includes a 'logrotate' package and
writes logrotate configuration to /etc/logrotate.d. Tested on Ubuntu
and Centos.
### Chef
- Chef 12.5+
### Cookbooks
- none
## Recipes
### global
@ -118,7 +129,7 @@ The resource takes the following properties:
"logrotate.erb".
- `template_mode`: the mode to create the logrotate template with
(default: "0440")
(default: "0644")
- `template_owner`: the owner of the logrotate template (default:
"root")

View File

@ -1,10 +1,10 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Attribute:: default
#
# Copyright 2013, Chef Software, Inc
# Copyright 2015-2016, Steven Danna
# Copyright 2016, Bloomberg Finance L.P.
# Copyright:: 2013-2017, Chef Software, Inc
# Copyright:: 2015-2017, Steven Danna
# Copyright:: 2016-2017, Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -19,36 +19,37 @@
# limitations under the License.
#
default["logrotate"]["package"] = {
"name" => "logrotate",
"source" => nil,
"version" => nil,
"provider" => nil,
default['logrotate']['package'] = {
'name' => 'logrotate',
'source' => nil,
'version' => nil,
'provider' => nil,
'action' => :upgrade,
}
default["logrotate"]["directory"] = "/etc/logrotate.d"
default["logrotate"]["cron"]["install"] = platform?("solaris2") || platform?("aix")
default["logrotate"]["cron"]["name"] = "logrotate"
default["logrotate"]["cron"]["command"] = "/usr/sbin/logrotate /etc/logrotate.conf"
default["logrotate"]["cron"]["minute"] = 35
default["logrotate"]["cron"]["hour"] = 2
default['logrotate']['directory'] = '/etc/logrotate.d'
default['logrotate']['cron']['install'] = platform?('solaris2') || platform?('aix')
default['logrotate']['cron']['name'] = 'logrotate'
default['logrotate']['cron']['command'] = '/usr/sbin/logrotate /etc/logrotate.conf'
default['logrotate']['cron']['minute'] = 35
default['logrotate']['cron']['hour'] = 2
default["logrotate"]["global"] = {
"weekly" => true,
"rotate" => 4,
"create" => "",
default['logrotate']['global'] = {
'weekly' => true,
'rotate' => 4,
'create' => '',
"/var/log/wtmp" => {
"missingok" => true,
"monthly" => true,
"create" => "0664 root utmp",
"rotate" => 1,
'/var/log/wtmp' => {
'missingok' => true,
'monthly' => true,
'create' => '0664 root utmp',
'rotate' => 1,
},
"/var/log/btmp" => {
"missingok" => true,
"monthly" => true,
"create" => "0660 root utmp",
"rotate" => 1,
'/var/log/btmp' => {
'missingok' => true,
'monthly' => true,
'create' => '0660 root utmp',
'rotate' => 1,
},
}

View File

@ -1,5 +1,5 @@
# Put files/directories that should be ignored in this file when uploading
# or sharing to the community site.
# to a chef-server or supermarket.
# Lines that start with '# ' are comments.
# OS generated files #
@ -51,8 +51,16 @@ spec/*
spec/fixtures/*
test/*
features/*
examples/*
Guardfile
Procfile
.kitchen*
.rubocop.yml
spec/*
Rakefile
.travis.yml
.foodcritic
.codeclimate.yml
# SCM #
#######
@ -76,8 +84,10 @@ tmp
# Cookbooks #
#############
CONTRIBUTING
CONTRIBUTING*
CHANGELOG*
TESTING*
MAINTAINERS.toml
# Strainer #
############
@ -90,12 +100,3 @@ Strainerfile
###########
.vagrant
Vagrantfile
# Travis #
##########
.travis.yml
# Other #
##########
.sandbox
.bundle

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Library:: CookbookLogrotate
#
# Copyright 2013, Chef
# Copyright:: 2013-2017, Chef
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -19,24 +19,24 @@
# Helper module for Logrotate configuration module CookbookLogrotate
module CookbookLogrotate
DIRECTIVES = %w{compress copy copytruncate daily dateext
dateyesterday delaycompress hourly ifempty mailfirst maillast
missingok monthly nocompress nocopy nocopytruncate nocreate nocreateolddir
nodelaycompress nodateext nomail nomissingok noolddir
nosharedscripts noshred notifempty renamecopy sharedscripts shred weekly
yearly} unless const_defined?(:DIRECTIVES)
DIRECTIVES = %w(compress copy copytruncate daily dateext
dateyesterday delaycompress hourly ifempty mailfirst maillast
missingok monthly nocompress nocopy nocopytruncate nocreate nocreateolddir
nodelaycompress nodateext nomail nomissingok noolddir
nosharedscripts noshred notifempty renamecopy sharedscripts shred weekly
yearly).freeze unless const_defined?(:DIRECTIVES)
VALUES = %w{compresscmd uncompresscmd compressext compressoptions
create createolddir dateformat include mail extension maxage minsize maxsize
rotate size shredcycles start tabooext su olddir} unless const_defined?(:VALUES)
VALUES = %w(compresscmd uncompresscmd compressext compressoptions
create createolddir dateformat include mail extension maxage minsize maxsize
rotate size shredcycles start tabooext su olddir).freeze unless const_defined?(:VALUES)
SCRIPTS = %w{firstaction prerotate postrotate lastaction preremove} unless const_defined?(:SCRIPTS)
SCRIPTS = %w(firstaction prerotate postrotate lastaction preremove).freeze unless const_defined?(:SCRIPTS)
DIRECTIVES_AND_VALUES = DIRECTIVES + VALUES unless const_defined?(:DIRECTIVES_AND_VALUES)
DIRECTIVES_AND_VALUES_AND_SCRIPTS = DIRECTIVES + VALUES + SCRIPTS unless const_defined?(:DIRECTIVES_AND_VALUES_AND_SCRIPTS)
# Helper class for creating configurations
class LogrotateConfiguration
attr_reader :directives, :values, :paths
attr_reader :directives, :values, :scripts, :paths
class << self
def from_hash(hash)
@ -52,27 +52,23 @@ module CookbookLogrotate
end
def paths_from(hash)
hash.select { |k| !(DIRECTIVES_AND_VALUES.include?(k)) }.reduce({}) do |accum_paths, (path, config)|
hash.select { |k| !DIRECTIVES_AND_VALUES_AND_SCRIPTS.include?(k) }.each_with_object({}) do |(path, config), accum_paths|
accum_paths[path] = {
"directives" => directives_from(config),
"values" => values_from(config),
"scripts" => scripts_from(config),
'directives' => directives_from(config),
'values' => values_from(config),
'scripts' => scripts_from(config),
}
accum_paths
end
end
def scripts_from(hash)
defined_scripts = hash.select { |k| SCRIPTS.include?(k) }
defined_scripts.reduce({}) do |accum_scripts, (script, lines)|
if lines.respond_to?(:join)
accum_scripts[script] = lines.join("\n")
else
accum_scripts[script] = lines
end
accum_scripts
defined_scripts.each_with_object({}) do |(script, lines), accum_scripts|
accum_scripts[script] = if lines.respond_to?(:join)
lines.join("\n")
else
lines
end
end
end
end
@ -82,6 +78,7 @@ module CookbookLogrotate
def initialize(hash)
@directives = LogrotateConfiguration.directives_from(hash)
@values = LogrotateConfiguration.values_from(hash)
@scripts = LogrotateConfiguration.scripts_from(hash)
@paths = LogrotateConfiguration.paths_from(hash)
end
end

View File

@ -1,4 +1,6 @@
if defined?(ChefSpec)
ChefSpec.define_matcher :logrotate_app
def enable_logrotate_app(resource)
ChefSpec::Matchers::ResourceMatcher.new(:logrotate_app, :enable, resource)
end

View File

@ -16,7 +16,7 @@
"ubuntu": ">= 0.0.0"
},
"dependencies": {
"compat_resource": ">= 0.0.0"
},
"recommendations": {
@ -42,12 +42,14 @@
"recipes": {
"logrotate": "Installs logrotate package"
},
"version": "2.1.0",
"version": "2.2.0",
"source_url": "https://github.com/stevendanna/logrotate",
"issues_url": "https://github.com/stevendanna/logrotate/issues",
"privacy": false,
"chef_versions": [
[
">= 12.5"
]
],
"ohai_versions": [

View File

@ -1,19 +1,18 @@
name "logrotate"
maintainer "Steven Danna"
maintainer_email "steve@chef.io"
license "Apache 2.0"
description "Installs logrotate package and provides a definition for logrotate configs"
long_description "Installs the logrotate package, manages /etc/logrotate.conf, and provides a logrotate_app definition."
version "2.1.0"
name 'logrotate'
maintainer 'Steven Danna'
maintainer_email 'steve@chef.io'
license 'Apache 2.0'
description 'Installs logrotate package and provides a definition for logrotate configs'
long_description 'Installs the logrotate package, manages /etc/logrotate.conf, and provides a logrotate_app definition.'
version '2.2.0'
source_url "https://github.com/stevendanna/logrotate" if respond_to?(:source_url)
issues_url "https://github.com/stevendanna/logrotate/issues" if respond_to?(:issues_url)
recipe 'logrotate', 'Installs logrotate package'
provides 'logrotate_app'
recipe "logrotate", "Installs logrotate package"
provides "logrotate_app"
depends "compat_resource"
%w{amazon centos debian fedora redhat scientific solaris2 ubuntu}.each do |platform|
%w(amazon centos debian fedora redhat scientific solaris2 ubuntu).each do |platform|
supports platform
end
source_url 'https://github.com/stevendanna/logrotate'
issues_url 'https://github.com/stevendanna/logrotate/issues'
chef_version '>= 12.5' if respond_to?(:chef_version)

View File

@ -1,10 +1,10 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Recipe:: default
#
# Copyright 2009-2013, Chef Software, Inc.
# Copyright 2015-2016, Steven Danna
# Copyright 2016, Bloomberg Finance L.P.
# Copyright:: 2009-2017, Chef Software, Inc.
# Copyright:: 2015-2017, Steven Danna
# Copyright:: 2016-2017, Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -18,25 +18,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
return if platform?("windows")
return if platform?('windows')
package node["logrotate"]["package"]["name"] do
provider node["logrotate"]["package"]["provider"] if node["logrotate"]["package"]["provider"]
source node["logrotate"]["package"]["source"] if node["logrotate"]["package"]["source"]
version node["logrotate"]["package"]["version"] if node["logrotate"]["package"]["version"]
action :upgrade
package node['logrotate']['package']['name'] do
provider node['logrotate']['package']['provider'] if node['logrotate']['package']['provider']
source node['logrotate']['package']['source'] if node['logrotate']['package']['source']
version node['logrotate']['package']['version'] if node['logrotate']['package']['version']
action node['logrotate']['package']['action']
end
directory node["logrotate"]["directory"] do
owner "root"
group node["root_group"]
mode "0755"
directory node['logrotate']['directory'] do
owner 'root'
group node['root_group']
mode '0755'
end
if node["logrotate"]["cron"]["install"] # ~FC023
cron node["logrotate"]["cron"]["name"] do
minute node["logrotate"]["cron"]["minute"]
hour node["logrotate"]["cron"]["hour"]
command node["logrotate"]["cron"]["command"]
if node['logrotate']['cron']['install'] # ~FC023
cron node['logrotate']['cron']['name'] do
minute node['logrotate']['cron']['minute']
hour node['logrotate']['cron']['hour']
command node['logrotate']['cron']['command']
end
end

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: logrotate
# Cookbook:: logrotate
# Recipe:: default
#
# Copyright 2009-2013, Chef Software, Inc.
# Copyright:: 2009-2017, 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.
@ -17,14 +17,14 @@
# limitations under the License.
#
include_recipe "logrotate::default"
include_recipe 'logrotate::default'
parsed_configuration = CookbookLogrotate::LogrotateConfiguration.from_hash(node["logrotate"]["global"].to_hash)
parsed_configuration = CookbookLogrotate::LogrotateConfiguration.from_hash(node['logrotate']['global'].to_hash)
template "/etc/logrotate.conf" do
source "logrotate-global.erb"
mode "0644"
template '/etc/logrotate.conf' do
source 'logrotate-global.erb'
mode '0644'
variables(
:configuration => parsed_configuration
configuration: parsed_configuration
)
end

View File

@ -1,5 +1,5 @@
#
# Copyright 2016, Steven Danna
# Copyright:: 2016-2017, Steven Danna
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,20 +17,20 @@
resource_name :logrotate_app
property :path, [String, Array], required: true
property :frequency, String, default: "weekly"
property :cookbook, default: "logrotate"
property :template_name, default: "logrotate.erb"
property :template_mode, default: "0644"
property :template_owner, default: "root"
property :template_group, default: "root"
property :base_dir, String, default: "/etc/logrotate.d"
property :frequency, String, default: 'weekly'
property :cookbook, default: 'logrotate'
property :template_name, default: 'logrotate.erb'
property :template_mode, default: '0644'
property :template_owner, default: 'root'
property :template_group, default: 'root'
property :base_dir, String, default: '/etc/logrotate.d'
property :options, [Array, String], default: %w{missingok compress delaycompress copytruncate notifempty}
property :options, [Array, String], default: %w(missingok compress delaycompress copytruncate notifempty)
default_action :enable
CookbookLogrotate::SCRIPTS.each do |script_name|
property script_name.to_sym, coerce: Proc.new { |val| Array(val).join("\n") }
property script_name.to_sym, coerce: proc { |val| Array(val).join("\n") }
end
CookbookLogrotate::VALUES.each do |configurable_name|
@ -42,15 +42,15 @@ property :sharedscripts, [TrueClass, FalseClass], default: false
property :enable, [TrueClass, FalseClass], default: true
action :enable do
if !new_resource.enable
Chef::Log.deprecation "Use `action :disable` rather than `enable false` in the logrotate_app resource"
unless new_resource.enable
Chef::Log.deprecation 'Use `action :disable` rather than `enable false` in the logrotate_app resource'
action_disable
return true
end
logrotate_config = {
# The path should be a space separated list of quoted filesystem paths
path: Array(new_resource.path).map { |path| path.to_s.inspect }.join(" "),
path: Array(new_resource.path).map { |path| path.to_s.inspect }.join(' '),
frequency: new_resource.frequency,
directives: handle_options(new_resource),
scripts: handle_scripts(new_resource),
@ -58,9 +58,9 @@ action :enable do
}
directory new_resource.base_dir do
owner "root"
group node["root_group"]
mode "0755"
owner 'root'
group node['root_group']
mode '0755'
action :create
end
@ -84,7 +84,7 @@ end
def handle_configurables(new_resource)
configurables = {}
CookbookLogrotate::VALUES.each do |opt_name|
if value = new_resource.send(opt_name.to_sym)
if value = new_resource.send(opt_name.to_sym) # rubocop: disable Lint/AssignmentInCondition
configurables[opt_name] = value
end
end
@ -94,7 +94,7 @@ end
def handle_scripts(new_resource)
scripts = {}
CookbookLogrotate::SCRIPTS.each do |script_name|
if script_body = new_resource.send(script_name.to_sym)
if script_body = new_resource.send(script_name.to_sym) # rubocop: disable Lint/AssignmentInCondition
scripts[script_name] = script_body
end
end
@ -109,8 +109,8 @@ def handle_options(new_resource)
end
if new_resource.sharedscripts
Chef::Log.deprecation("The sharedscripts resource property is deprecated. Use the options property instead to set this value")
opts << "sharedscripts"
Chef::Log.deprecation('The sharedscripts resource property is deprecated. Use the options property instead to set this value')
opts << 'sharedscripts'
end
opts
end

View File

@ -9,6 +9,12 @@
<%= k %> <%= v %>
<% end -%>
<% @configuration.scripts.each do | scripttype, body | -%>
<%= scripttype %>
<%= body %>
endscript
<% end -%>
include /etc/logrotate.d
<% @configuration.paths.each do |path, path_config| -%>

View File

@ -2,6 +2,94 @@
This file is used to list changes made in each version of the mysql cookbook.
## 8.4.0 (2017-05-30)
- Fix client/server install on Amazon Linux and add testing
- Remove support for Ubuntu Precise since it's EOL
- Add Amazon Linux testing
## 8.3.1 (2017-04-04)
- Fix an ignoring of 'cookbook' attribute by 'mysql_config' resource
- Remove unused helper method
- Call out the supported platform versions in the metadata
- Switch to Delivery Local and rename the docked config
- Remove mention of the EOL opensuse 13.x in the readme
## 8.3.0 (2017-03-20)
- Refactor mysql_service_manager_upstart.rb to eliminate use of cloned resource
## 8.2.0 (2016-12-03)
- Include client development packages on RHEL/SUSE platforms
## 8.1.1 (2016-10-31)
- Fixing CVE-2016-6662 - Reverting execure bit on mysql config
## 8.1.0 (2016-10-29)
- Drop hardcoded, specific package version logic that broke many users
## 8.0.4 (2016-09-26)
- Bump debian version
- Updated packages for 12.04 and 14.04 too
- Add chef_version metadata
- Update platforms in the kitchen file
- Add selinux to the Berksfile for testing
- Make sure yum repos are setup in local Test Kitchen
## 8.0.3 (2016-09-14)
- [GH-390] Fix #390 incorrect escaping of initial_root_password
- Updated package versions for Ubuntu 16.04
- Testing updates
# v8.0.2 (2016-08-25)
- Various bug fixed and updates to package version strings
# v8.0.1 (2016-07-20)
- Fixed a regression in the mysql_client resource where the action was changed from create to install in the 8.0 release
- Added oracle, opensuse, and opensuseleap as supported platforms in the metadata
# v8.0.0 (2016-07-11)
- Converting from LWRP to custom resources
- Removing yum-mysql and other dependencies.
- ^ BREAKING CHANGE: RHELish users are now responsible
for including a recipe from the "yum-mysql" or equivalent
cookbook before utilizing the mysql_* resources.
- More thoughtful ChefSpec
- Renaming "replication" test suite to "smoke"
- Moving to Inspec
## v7.2.0 (2016-06-30)
- Support openeSUSE leap
- Support Fedora 24
## v7.1.2 (2016-06-30)
- Avoid deprecation warnings on the upcoming Chef 12.12 release
## v7.1.1 (2016-06-03)
- Fix apparmor blocking writes to non-default tmp_dirs
- Updated apparmor config to allow read & write to sock.lock file
- Use cookstyle instead of Rubocop directly
## v7.1.0 (2016-05-11)
- Added support for Ubuntu 16.04
## v7.0.0 (2016-04-19)
- Removed support for legacy distros: Ubuntu 10.04/13.04/14.10/15.04, Fedora 20/21, OmniOS r151006, opensuse 11.3/12.0
- Added support for Fedora 23, suse 13.X, and Ubuntu 16.04
- Updated the systemd support to create unit files in /etc/systemd and not /usr/lib/systemd
- Adding umask to bash resource that sets root password PR #386 @gziskind
- Cleaned up the Test Kitchen config to test the right platform version + mysql pairings
- Added Travis CI Test Kitchen testing on Fedora 22/23 and removed Fedora 21
- Updated the platforms used in the specs
## v6.1.3 (2016-03-14)
- Added support for Ubuntu 15.10
@ -65,7 +153,7 @@ This file is used to list changes made in each version of the mysql cookbook.
## v6.0.21 (2015-04-08)
- Fix to Upstart prestart script when using custom socket
- Fix to Upstart prestart script when using custom socket
- Adding --explicit_defaults_for_timestamp mysql_install_db_cmd for
- 5.6 and above
@ -186,7 +274,7 @@ This file is used to list changes made in each version of the mysql cookbook.
## v5.5.4 (2014-10-07)
- Adding sensitive flag to execute resources to protect passwords from logs
- Adding sensitive flag to execute resources to protect passwords from logs
## v5.5.3 (2014-09-24)

View File

@ -1,13 +1,10 @@
<!-- 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.
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 review from an existing maintainer for the cookbook 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)

View File

@ -2,16 +2,15 @@
[![Build Status](https://travis-ci.org/chef-cookbooks/mysql.svg?branch=master)](https://travis-ci.org/chef-cookbooks/mysql) [![Cookbook Version](https://img.shields.io/cookbook/v/mysql.svg)](https://supermarket.chef.io/cookbooks/mysql)
The Mysql Cookbook is a library cookbook that provides resource primitives (LWRPs) for use in recipes. It is designed to be a reference example for creating highly reusable cross-platform cookbooks.
The MySQL Cookbook is a library cookbook that provides resource primitives (LWRPs) for use in recipes. It is designed to be a reference example for creating highly reusable cross-platform cookbooks.
## 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 or value-added repackaged MySQL distributions like Drizzle, MariaDB, or Percona.
This cookbook is concerned with the "MySQL Community Server", particularly those shipped with F/OSS Unix and Linux distributions. It does not address forks or value-added repackaged MySQL distributions like MariaDB or Percona.
## Requirements
- Chef 11 or higher
- Ruby 1.9 or higher (preferably from the Chef full-stack installer)
- Chef 12.5 or higher
- Network accessible package repositories
- 'recipe[selinux::disabled]' on RHEL platforms
@ -20,42 +19,37 @@ This cookbook is concerned with the "MySQL Community Server", particularly those
The following platforms have been tested with Test Kitchen:
```
|----------------+-----+-----+-----+-----+-----|
| | 5.0 | 5.1 | 5.5 | 5.6 | 5.7 |
|----------------+-----+-----+-----+-----+-----|
| debian-7 | | | X | | |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-12.04 | | | X | | |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-14.04 | | | X | X | |
|----------------+-----+-----+-----+-----+-----|
| ubuntu-15.04 | | | | X | |
|----------------+-----+-----+-----+-----+-----|
| centos-5 | X | X | X | X | X |
|----------------+-----+-----+-----+-----+-----|
| centos-6 | | X | X | X | X |
|----------------+-----+-----+-----+-----+-----|
| centos-7 | | | X | X | X |
|----------------+-----+-----+-----+-----+-----|
| amazon | | | X | X | X |
|----------------+-----+-----+-----+-----+-----|
| fedora-22 | | | X | X | X |
|----------------+-----+-----+-----+-----+-----|
| fedora-23 | | | X | X | X |
|----------------+-----+-----+-----+-----+-----|
|----------------+-----+-----+-----+-----|
| | 5.1 | 5.5 | 5.6 | 5.7 |
|----------------+-----+-----+-----+-----|
| debian-7 | | X | | |
|----------------+-----+-----+-----+-----|
| debian-8 | | X | | |
|----------------+-----+-----+-----+-----|
| ubuntu-14.04 | | X | X | |
|----------------+-----+-----+-----+-----|
| ubuntu-16.04 | | | | X |
|----------------+-----+-----+-----+-----|
| centos-6 | X | X | X | X |
|----------------+-----+-----+-----+-----|
| centos-7 | | X | X | X |
|----------------+-----+-----+-----+-----|
| fedora | | | X | X |
|----------------+-----+-----+-----+-----|
| openSUSE Leap | | | X | |
|----------------+-----+-----+-----+-----|
```
## Cookbook Dependencies
- yum-mysql-community
- smf
There are no hard coupled dependencies. However, there is a loose dependency on `yum-mysql-community` for RHEL/CentOS platforms. As of the 8.0 version of this cookbook, configuration of the package repos is now the responsibility of the user.
## Usage
Place a dependency on the mysql cookbook in your cookbook's metadata.rb
```ruby
depends 'mysql', '~> 6.0'
depends 'mysql', '~> 8.0'
```
Then, in a recipe:
@ -180,7 +174,7 @@ Please note that when using `notifies` or `subscribes`, the resource to referenc
- `:create` - Configures everything but the underlying operating system service.
- `:delete` - Removes everything but the package and data_dir.
- `:start` - Starts the underlying operating system service
- `:stop`- Stops the underlying operating system service
- `:stop`- Stops the underlying operating system service
- `:restart` - Restarts the underlying operating system service
- `:reload` - Reloads the underlying operating system service
@ -274,7 +268,7 @@ mysql_client 'default' do
end
```
#### Parameters
#### Properties
- `package_name` - An array of packages to be installed. Defaults to a value looked up in an internal map.
- `package_version` - Specific versions of the package to install, passed onto the underlying package manager. Defaults to `nil`.
@ -401,31 +395,16 @@ Or to connect over the network, use something like this: connect over the networ
These network or socket ssettings can also be put in you $HOME/.my.cnf, if preferred.
### What about MariaDB, Percona, Drizzle, WebScaleSQL, etc.
### What about MariaDB, Percona, etc.
MySQL forks are purposefully out of scope for this cookbook. This is mostly to reduce the testing matrix to a manageable size. Cookbooks for these technologies can easily be created by copying and adapting this cookbook. However, there will be differences.
Package repository locations, package version names, software major version numbers, supported platform matrices, and the availability of software such as XtraDB and Galera are the main reasons that creating multiple cookbooks to make sense.
## Warnings
## Hacking / Testing / TODO
Please refer to the HACKING.md
## License & Authors
- Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io))
- Author:: AJ Christensen ([aj@chef.io](mailto:aj@chef.io))
- Author:: Seth Chisamore ([schisamo@chef.io](mailto:schisamo@chef.io))
- Author:: Brian Bianco ([brian.bianco@gmail.com](mailto:brian.bianco@gmail.com))
- Author:: Jesse Howarth ([him@jessehowarth.com](mailto:him@jessehowarth.com))
- Author:: Andrew Crump ([andrew@kotirisoftware.com](mailto:andrew@kotirisoftware.com))
- Author:: Christoph Hartmann ([chris@lollyrock.com](mailto:chris@lollyrock.com))
- Author:: Sean OMeara ([sean@chef.io](mailto:sean@chef.io))
## License
```text
Copyright:: 2009-2014 Chef Software, Inc
Copyright:: 2009-2017 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.

View File

@ -1,67 +1,118 @@
require 'shellwords'
module MysqlCookbook
module Helpers
include Chef::DSL::IncludeRecipe
module HelpersBase
require 'shellwords'
def base_dir
prefix_dir || '/usr'
def el6?
return true if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 6
false
end
def configure_package_repositories
# we need to enable the yum-mysql-community repository to get packages
return unless %w(rhel fedora).include? node['platform_family']
case parsed_version
when '5.5'
# Prefer packages from native repos
return if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5
return if node['platform_family'] == 'fedora'
include_recipe('yum-mysql-community::mysql55')
when '5.6'
include_recipe('yum-mysql-community::mysql56')
when '5.7'
include_recipe('yum-mysql-community::mysql57')
end
def el7?
return true if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7
false
end
def client_package_name
return new_resource.package_name if new_resource.package_name
client_package
def wheezy?
return true if node['platform'] == 'debian' && node['platform_version'].to_i == 7
false
end
def jessie?
return true if node['platform'] == 'debian' && node['platform_version'].to_i == 8
false
end
def trusty?
return true if node['platform'] == 'ubuntu' && node['platform_version'] == '14.04'
return true if node['platform'] == 'linuxmint' && node['platform_version'] =~ /^17\.[0-9]$/
false
end
def xenial?
return true if node['platform'] == 'ubuntu' && node['platform_version'] == '16.04'
false
end
def defaults_file
"#{etc_dir}/my.cnf"
end
def error_log
return new_resource.error_log if new_resource.error_log
def default_data_dir
return "/var/lib/#{mysql_name}" if node['os'] == 'linux'
return "/opt/local/lib/#{mysql_name}" if node['os'] == 'solaris2'
return "/var/db/#{mysql_name}" if node['os'] == 'freebsd'
end
def default_error_log
"#{log_dir}/error.log"
end
def etc_dir
return "/opt/mysql#{pkg_ver_string}/etc/#{mysql_name}" if node['platform_family'] == 'omnios'
return "#{prefix_dir}/etc/#{mysql_name}" if node['platform_family'] == 'smartos'
"#{prefix_dir}/etc/#{mysql_name}"
def default_pid_file
"#{run_dir}/mysqld.pid"
end
def include_dir
"#{etc_dir}/conf.d"
def default_major_version
# rhelish
return '5.1' if el6?
return '5.6' if el7?
return '5.6' if node['platform'] == 'amazon'
# debian
return '5.5' if wheezy?
return '5.5' if jessie?
# ubuntu
return '5.5' if trusty?
return '5.7' if xenial?
# misc
return '5.6' if node['platform'] == 'freebsd'
return '5.6' if node['platform'] == 'fedora'
return '5.6' if node['platform_family'] == 'suse'
end
def lc_messages_dir
end
def log_dir
return "/var/adm/log/#{mysql_name}" if node['platform_family'] == 'omnios'
"#{prefix_dir}/var/log/#{mysql_name}"
def major_from_full(v)
v.split('.').shift(2).join('.')
end
def mysql_name
"mysql-#{new_resource.instance}"
"mysql-#{instance}"
end
def pkg_ver_string
parsed_version.delete('.') if node['platform_family'] == 'omnios'
def default_socket_file
"#{run_dir}/mysqld.sock"
end
def default_client_package_name
return ['mysql', 'mysql-devel'] if major_version == '5.1' && el6?
return ['mysql55', 'mysql55-devel.x86_64'] if major_version == '5.5' && node['platform'] == 'amazon'
return ['mysql56', 'mysql56-devel.x86_64'] if major_version == '5.6' && node['platform'] == 'amazon'
return ['mysql-client-5.5', 'libmysqlclient-dev'] if major_version == '5.5' && node['platform_family'] == 'debian'
return ['mysql-client-5.6', 'libmysqlclient-dev'] if major_version == '5.6' && node['platform_family'] == 'debian'
return ['mysql-client-5.7', 'libmysqlclient-dev'] if major_version == '5.7' && node['platform_family'] == 'debian'
return 'mysql-community-server-client' if major_version == '5.6' && node['platform_family'] == 'suse'
['mysql-community-client', 'mysql-community-devel']
end
def default_server_package_name
return 'mysql-server' if major_version == '5.1' && el6?
return 'mysql55-server' if major_version == '5.5' && node['platform'] == 'amazon'
return 'mysql56-server' if major_version == '5.6' && node['platform'] == 'amazon'
return 'mysql-server-5.5' if major_version == '5.5' && node['platform_family'] == 'debian'
return 'mysql-server-5.6' if major_version == '5.6' && node['platform_family'] == 'debian'
return 'mysql-server-5.7' if major_version == '5.7' && node['platform_family'] == 'debian'
return 'mysql-community-server' if major_version == '5.6' && node['platform_family'] == 'suse'
'mysql-community-server'
end
def socket_dir
File.dirname(socket)
end
def run_dir
return "#{prefix_dir}/var/run/#{mysql_name}" if node['platform_family'] == 'rhel'
return "/run/#{mysql_name}" if node['platform_family'] == 'debian'
"/var/run/#{mysql_name}"
end
def prefix_dir
@ -72,102 +123,70 @@ module MysqlCookbook
def scl_name
return unless node['platform_family'] == 'rhel'
return 'mysql51' if parsed_version == '5.1' && node['platform_version'].to_i == 5
return 'mysql55' if parsed_version == '5.5' && node['platform_version'].to_i == 5
return 'mysql51' if version == '5.1' && node['platform_version'].to_i == 5
return 'mysql55' if version == '5.5' && node['platform_version'].to_i == 5
end
def scl_package?
return unless node['platform_family'] == 'rhel'
return true if parsed_version == '5.1' && node['platform_version'].to_i == 5
return true if parsed_version == '5.5' && node['platform_version'].to_i == 5
return true if version == '5.1' && node['platform_version'].to_i == 5
return true if version == '5.5' && node['platform_version'].to_i == 5
false
end
def etc_dir
return "/opt/mysql#{pkg_ver_string}/etc/#{mysql_name}" if node['platform_family'] == 'omnios'
return "#{prefix_dir}/etc/#{mysql_name}" if node['platform_family'] == 'smartos'
"#{prefix_dir}/etc/#{mysql_name}"
end
def base_dir
prefix_dir || '/usr'
end
def system_service_name
return 'mysql51-mysqld' if node['platform_family'] == 'rhel' && scl_name == 'mysql51'
return 'mysql55-mysqld' if node['platform_family'] == 'rhel' && scl_name == 'mysql55'
return 'mysqld' if node['platform_family'] == 'rhel'
return 'mysqld' if node['platform_family'] == 'fedora'
return 'mysql' if node['platform_family'] == 'debian'
return 'mysql' if node['platform_family'] == 'suse'
return 'mysql' if node['platform_family'] == 'omnios'
return 'mysql' if node['platform_family'] == 'smartos'
'mysql' # not one of the above
end
def v56plus
return false if parsed_version.split('.')[0].to_i < 5
return false if parsed_version.split('.')[1].to_i < 6
return false if version.split('.')[0].to_i < 5
return false if version.split('.')[1].to_i < 6
true
end
def v57plus
return false if parsed_version.split('.')[0].to_i < 5
return false if parsed_version.split('.')[1].to_i < 7
return false if version.split('.')[0].to_i < 5
return false if version.split('.')[1].to_i < 7
true
end
def password_column_name
return 'authentication_string' if v57plus
'password'
def default_include_dir
"#{etc_dir}/conf.d"
end
def password_expired
return ", password_expired='N'" if v57plus
''
def log_dir
return "/var/adm/log/#{mysql_name}" if node['platform_family'] == 'omnios'
"#{prefix_dir}/var/log/#{mysql_name}"
end
def root_password
if new_resource.initial_root_password == ''
Chef::Log.info('Root password is empty')
return ''
end
Shellwords.escape(new_resource.initial_root_password)
end
# database and initial records
# initialization commands
def mysqld_initialize_cmd
cmd = mysqld_bin
cmd << " --defaults-file=#{etc_dir}/my.cnf"
cmd << ' --initialize'
cmd << ' --explicit_defaults_for_timestamp' if v56plus
return "scl enable #{scl_name} \"#{cmd}\"" if scl_package?
cmd
end
def mysql_install_db_cmd
cmd = mysql_install_db_bin
cmd << " --defaults-file=#{etc_dir}/my.cnf"
cmd << " --datadir=#{parsed_data_dir}"
cmd << ' --explicit_defaults_for_timestamp' if v56plus
return "scl enable #{scl_name} \"#{cmd}\"" if scl_package?
cmd
end
def record_init
cmd = v56plus ? mysqld_bin : mysqld_safe_bin
cmd << " --defaults-file=#{etc_dir}/my.cnf"
cmd << " --init-file=/tmp/#{mysql_name}/my.sql"
cmd << ' --explicit_defaults_for_timestamp' if v56plus
cmd << ' &'
return "scl enable #{scl_name} \"#{cmd}\"" if scl_package?
cmd
end
def db_init
return mysqld_initialize_cmd if v57plus
mysql_install_db_cmd
end
def lc_messages_dir; end
def init_records_script
# Note: shell-escaping passwords in a SQL file may cause corruption - eg
# mysql will read \& as &, but \% as \%. Just escape bare-minimum \ and '
sql_escaped_password = root_password.gsub('\\') { '\\\\' }.gsub("'") { '\\\'' }
<<-EOS
set -e
rm -rf /tmp/#{mysql_name}
mkdir /tmp/#{mysql_name}
cat > /tmp/#{mysql_name}/my.sql <<-EOSQL
UPDATE mysql.user SET #{password_column_name}=PASSWORD('#{root_password}')#{password_expired} WHERE user = 'root';
cat > /tmp/#{mysql_name}/my.sql <<-'EOSQL'
UPDATE mysql.user SET #{password_column_name}=PASSWORD('#{sql_escaped_password}')#{password_expired} WHERE user = 'root';
DELETE FROM mysql.user WHERE USER LIKE '';
DELETE FROM mysql.user WHERE user = 'root' and host NOT IN ('127.0.0.1', 'localhost');
FLUSH PRIVILEGES;
@ -185,10 +204,27 @@ EOSQL
EOS
end
def mysql_bin
return "#{prefix_dir}/bin/mysql" if node['platform_family'] == 'smartos'
return "#{base_dir}/bin/mysql" if node['platform_family'] == 'omnios'
"#{prefix_dir}/usr/bin/mysql"
def password_column_name
return 'authentication_string' if v57plus
'password'
end
def root_password
if initial_root_password == ''
Chef::Log.info('Root password is empty')
return ''
end
initial_root_password
end
def password_expired
return ", password_expired='N'" if v57plus
''
end
def db_init
return mysqld_initialize_cmd if v57plus
mysql_install_db_cmd
end
def mysql_install_db_bin
@ -197,8 +233,13 @@ EOSQL
'mysql_install_db'
end
def mysql_version
new_resource.version
def mysql_install_db_cmd
cmd = mysql_install_db_bin
cmd << " --defaults-file=#{etc_dir}/my.cnf"
cmd << " --datadir=#{data_dir}"
cmd << ' --explicit_defaults_for_timestamp' if v56plus && !v57plus
return "scl enable #{scl_name} \"#{cmd}\"" if scl_package?
cmd
end
def mysqladmin_bin
@ -216,6 +257,15 @@ EOSQL
"#{prefix_dir}/usr/sbin/mysqld"
end
def mysqld_initialize_cmd
cmd = mysqld_bin
cmd << " --defaults-file=#{etc_dir}/my.cnf"
cmd << ' --initialize'
cmd << ' --explicit_defaults_for_timestamp' if v56plus
return "scl enable #{scl_name} \"#{cmd}\"" if scl_package?
cmd
end
def mysqld_safe_bin
return "#{prefix_dir}/bin/mysqld_safe" if node['platform_family'] == 'smartos'
return "#{base_dir}/bin/mysqld_safe" if node['platform_family'] == 'omnios'
@ -223,248 +273,14 @@ EOSQL
"#{prefix_dir}/usr/bin/mysqld_safe"
end
def pid_file
return new_resource.pid_file if new_resource.pid_file
"#{run_dir}/mysqld.pid"
end
def run_dir
return "#{prefix_dir}/var/run/#{mysql_name}" if node['platform_family'] == 'rhel'
return "/run/#{mysql_name}" if node['platform_family'] == 'debian'
"/var/run/#{mysql_name}"
end
def sensitive_supported?
Gem::Version.new(Chef::VERSION) >= Gem::Version.new('11.14.0')
end
def socket_file
return new_resource.socket if new_resource.socket
"#{run_dir}/mysqld.sock"
end
def socket_dir
return File.dirname(new_resource.socket) if new_resource.socket
run_dir
end
def tmp_dir
return new_resource.tmp_dir if new_resource.tmp_dir
'/tmp'
end
#######
# FIXME: There is a LOT of duplication here..
# There has to be a less gnarly way to look up this information. Refactor for great good!
#######
class Pkginfo
def self.pkginfo
# Autovivification is Perl.
@pkginfo = Chef::Node.new
@pkginfo.set['debian']['10.04']['5.1']['client_package'] = %w(mysql-client-5.1 libmysqlclient-dev)
@pkginfo.set['debian']['10.04']['5.1']['server_package'] = 'mysql-server-5.1'
@pkginfo.set['debian']['12.04']['5.5']['client_package'] = %w(mysql-client-5.5 libmysqlclient-dev)
@pkginfo.set['debian']['12.04']['5.5']['server_package'] = 'mysql-server-5.5'
@pkginfo.set['debian']['13.04']['5.5']['client_package'] = %w(mysql-client-5.5 libmysqlclient-dev)
@pkginfo.set['debian']['13.04']['5.5']['server_package'] = 'mysql-server-5.5'
@pkginfo.set['debian']['13.10']['5.5']['client_package'] = %w(mysql-client-5.5 libmysqlclient-dev)
@pkginfo.set['debian']['13.10']['5.5']['server_package'] = 'mysql-server-5.5'
@pkginfo.set['debian']['14.04']['5.5']['client_package'] = %w(mysql-client-5.5 libmysqlclient-dev)
@pkginfo.set['debian']['14.04']['5.5']['server_package'] = 'mysql-server-5.5'
@pkginfo.set['debian']['14.04']['5.6']['client_package'] = %w(mysql-client-5.6 libmysqlclient-dev)
@pkginfo.set['debian']['14.04']['5.6']['server_package'] = 'mysql-server-5.6'
@pkginfo.set['debian']['14.10']['5.5']['client_package'] = %w(mysql-client-5.5 libmysqlclient-dev)
@pkginfo.set['debian']['14.10']['5.5']['server_package'] = 'mysql-server-5.5'
@pkginfo.set['debian']['14.10']['5.6']['client_package'] = %w(mysql-client-5.6 libmysqlclient-dev)
@pkginfo.set['debian']['14.10']['5.6']['server_package'] = 'mysql-server-5.6'
@pkginfo.set['debian']['15.04']['5.6']['client_package'] = %w(mysql-client-5.6 libmysqlclient-dev)
@pkginfo.set['debian']['15.04']['5.6']['server_package'] = 'mysql-server-5.6'
@pkginfo.set['debian']['15.10']['5.6']['client_package'] = %w(mysql-client-5.6 libmysqlclient-dev)
@pkginfo.set['debian']['15.10']['5.6']['server_package'] = 'mysql-server-5.6'
@pkginfo.set['debian']['6']['5.1']['client_package'] = %w(mysql-client libmysqlclient-dev)
@pkginfo.set['debian']['6']['5.1']['server_package'] = 'mysql-server-5.1'
@pkginfo.set['debian']['7']['5.5']['client_package'] = %w(mysql-client libmysqlclient-dev)
@pkginfo.set['debian']['7']['5.5']['server_package'] = 'mysql-server-5.5'
@pkginfo.set['debian']['7']['5.6']['client_package'] = %w(mysql-client libmysqlclient-dev) # apt-repo from dotdeb
@pkginfo.set['debian']['7']['5.6']['server_package'] = 'mysql-server-5.6'
@pkginfo.set['debian']['7']['5.7']['client_package'] = %w(mysql-client libmysqlclient-dev) # apt-repo from dotdeb
@pkginfo.set['debian']['7']['5.7']['server_package'] = 'mysql-server-5.7'
@pkginfo.set['debian']['8']['5.5']['client_package'] = %w(mysql-client libmysqlclient-dev)
@pkginfo.set['debian']['8']['5.5']['server_package'] = 'mysql-server-5.5'
@pkginfo.set['fedora']['20']['5.5']['client_package'] = %w(community-mysql community-mysql-devel)
@pkginfo.set['fedora']['20']['5.5']['server_package'] = 'community-mysql-server'
@pkginfo.set['fedora']['20']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['fedora']['20']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['fedora']['20']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['fedora']['20']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['fedora']['21']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['fedora']['21']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['fedora']['21']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['fedora']['21']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['fedora']['22']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['fedora']['22']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['fedora']['22']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['fedora']['22']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['freebsd']['10']['5.5']['client_package'] = %w(mysql55-client)
@pkginfo.set['freebsd']['10']['5.5']['server_package'] = 'mysql55-server'
@pkginfo.set['freebsd']['9']['5.5']['client_package'] = %w(mysql55-client)
@pkginfo.set['freebsd']['9']['5.5']['server_package'] = 'mysql55-server'
@pkginfo.set['omnios']['151006']['5.5']['client_package'] = %w(database/mysql-55/library)
@pkginfo.set['omnios']['151006']['5.5']['server_package'] = 'database/mysql-55'
@pkginfo.set['omnios']['151006']['5.6']['client_package'] = %w(database/mysql-56)
@pkginfo.set['omnios']['151006']['5.6']['server_package'] = 'database/mysql-56'
@pkginfo.set['rhel']['2014.09']['5.1']['server_package'] = %w(mysql51 mysql51-devel)
@pkginfo.set['rhel']['2014.09']['5.1']['server_package'] = 'mysql51-server'
@pkginfo.set['rhel']['2014.09']['5.5']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2014.09']['5.5']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2014.09']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2014.09']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2014.09']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2014.09']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2015.03']['5.1']['server_package'] = %w(mysql51 mysql51-devel)
@pkginfo.set['rhel']['2015.03']['5.1']['server_package'] = 'mysql51-server'
@pkginfo.set['rhel']['2015.03']['5.5']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2015.03']['5.5']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2015.03']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2015.03']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2015.03']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2015.03']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2015.09']['5.1']['server_package'] = %w(mysql51 mysql51-devel)
@pkginfo.set['rhel']['2015.09']['5.1']['server_package'] = 'mysql51-server'
@pkginfo.set['rhel']['2015.09']['5.5']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2015.09']['5.5']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2015.09']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2015.09']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2015.09']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2015.09']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2016.03']['5.1']['server_package'] = %w(mysql51 mysql51-devel)
@pkginfo.set['rhel']['2016.03']['5.1']['server_package'] = 'mysql51-server'
@pkginfo.set['rhel']['2016.03']['5.5']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2016.03']['5.5']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2016.03']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2016.03']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['2016.03']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['2016.03']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['5']['5.0']['client_package'] = %w(mysql mysql-devel)
@pkginfo.set['rhel']['5']['5.0']['server_package'] = 'mysql-server'
@pkginfo.set['rhel']['5']['5.1']['client_package'] = %w(mysql51-mysql)
@pkginfo.set['rhel']['5']['5.1']['server_package'] = 'mysql51-mysql-server'
@pkginfo.set['rhel']['5']['5.5']['client_package'] = %w(mysql55-mysql mysql55-mysql-devel)
@pkginfo.set['rhel']['5']['5.5']['server_package'] = 'mysql55-mysql-server'
@pkginfo.set['rhel']['5']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['5']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['5']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['5']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['6']['5.1']['client_package'] = %w(mysql mysql-devel)
@pkginfo.set['rhel']['6']['5.1']['server_package'] = 'mysql-server'
@pkginfo.set['rhel']['6']['5.5']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['6']['5.5']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['6']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['6']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['6']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['6']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['7']['5.5']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['7']['5.5']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['7']['5.6']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['7']['5.6']['server_package'] = 'mysql-community-server'
@pkginfo.set['rhel']['7']['5.7']['client_package'] = %w(mysql-community-client mysql-community-devel)
@pkginfo.set['rhel']['7']['5.7']['server_package'] = 'mysql-community-server'
@pkginfo.set['smartos']['5.11']['5.5']['client_package'] = %w(mysql-client)
@pkginfo.set['smartos']['5.11']['5.5']['server_package'] = 'mysql-server'
@pkginfo.set['smartos']['5.11']['5.6']['client_package'] = %w(mysql-client)
@pkginfo.set['smartos']['5.11']['5.6']['server_package'] = 'mysql-server'
@pkginfo.set['suse']['11.3']['5.5']['client_package'] = %w(mysql-client)
@pkginfo.set['suse']['11.3']['5.5']['server_package'] = 'mysql'
@pkginfo.set['suse']['12.0']['5.5']['client_package'] = %w(mysql-client)
@pkginfo.set['suse']['12.0']['5.5']['server_package'] = 'mysql'
@pkginfo
end
end
def package_name_for(platform, platform_family, platform_version, version, type)
keyname = keyname_for(platform, platform_family, platform_version)
info = Pkginfo.pkginfo[platform_family.to_sym][keyname]
type_label = type.to_s.gsub('_package', '').capitalize
unless info[version]
# Show availabe versions if the requested is not available on the current platform
Chef::Log.error("Unsupported Version: You requested to install a Mysql #{type_label} version that is not supported by your platform")
Chef::Log.error("Platform: #{platform_family} #{platform_version} - Request Mysql #{type_label} version: #{version}")
Chef::Log.error("Availabe versions for your platform are: #{info.map { |k, _v| k }.join(' - ')}")
raise "Unsupported Mysql #{type_label} Version"
end
info[version][type]
end
def keyname_for(platform, platform_family, platform_version)
return platform_version if platform_family == 'debian' && platform == 'ubuntu'
return platform_version if platform_family == 'fedora'
return platform_version if platform_family == 'omnios'
return platform_version if platform_family == 'rhel' && platform == 'amazon'
return platform_version if platform_family == 'smartos'
return platform_version if platform_family == 'suse'
return platform_version.to_i.to_s if platform_family == 'debian'
return platform_version.to_i.to_s if platform_family == 'rhel'
return platform_version.to_s if platform_family == 'debian' && platform_version =~ /sid$/
return platform_version.to_s if platform_family == 'freebsd'
end
def parsed_data_dir
return new_resource.data_dir if new_resource.data_dir
return "/opt/local/lib/#{mysql_name}" if node['os'] == 'solaris2'
return "/var/lib/#{mysql_name}" if node['os'] == 'linux'
return "/var/db/#{mysql_name}" if node['os'] == 'freebsd'
end
def client_package
package_name_for(
node['platform'],
node['platform_family'],
node['platform_version'],
parsed_version,
:client_package
)
end
def server_package
package_name_for(
node['platform'],
node['platform_family'],
node['platform_version'],
parsed_version,
:server_package
)
end
def server_package_name
return new_resource.package_name if new_resource.package_name
server_package
end
def parsed_version
return new_resource.version if new_resource.version
return '5.0' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5
return '5.1' if node['platform_family'] == 'debian' && node['platform_version'] == '10.04'
return '5.1' if node['platform_family'] == 'debian' && node['platform_version'].to_i == 6
return '5.1' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 6
return '5.5' if node['platform_family'] == 'debian' && node['platform_version'] == '12.04'
return '5.5' if node['platform_family'] == 'debian' && node['platform_version'] == '13.04'
return '5.5' if node['platform_family'] == 'debian' && node['platform_version'] == '13.10'
return '5.5' if node['platform_family'] == 'debian' && node['platform_version'] == '14.04'
return '5.5' if node['platform_family'] == 'debian' && node['platform_version'] == '14.10'
return '5.5' if node['platform_family'] == 'debian' && node['platform_version'].to_i == 7
return '5.5' if node['platform_family'] == 'debian' && node['platform_version'].to_i == 8
return '5.5' if node['platform_family'] == 'freebsd'
return '5.5' if node['platform_family'] == 'omnios'
return '5.5' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 2014
return '5.5' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 2015
return '5.5' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7
return '5.5' if node['platform_family'] == 'smartos'
return '5.5' if node['platform_family'] == 'suse'
return '5.6' if node['platform_family'] == 'fedora'
return '5.6' if node['platform_family'] == 'debian' && node['platform_version'] == '15.04'
return '5.6' if node['platform_family'] == 'debian' && node['platform_version'] == '15.10'
def record_init
cmd = v56plus ? mysqld_bin : mysqld_safe_bin
cmd << " --defaults-file=#{etc_dir}/my.cnf"
cmd << " --init-file=/tmp/#{mysql_name}/my.sql"
cmd << ' --explicit_defaults_for_timestamp' if v56plus
cmd << ' &'
return "scl enable #{scl_name} \"#{cmd}\"" if scl_package?
cmd
end
end
end

View File

@ -1,18 +1,40 @@
if defined?(ChefSpec)
if ChefSpec.respond_to?(:define_matcher)
# ChefSpec >= 4.1
ChefSpec.define_matcher :mysql_config
ChefSpec.define_matcher :mysql_service
ChefSpec.define_matcher :mysql_client
elsif defined?(ChefSpec::Runner) &&
ChefSpec::Runner.respond_to?(:define_runner_method)
# ChefSpec < 4.1
ChefSpec::Runner.define_runner_method :mysql_config
ChefSpec::Runner.define_runner_method :mysql_service
ChefSpec::Runner.define_runner_method :mysql_client
ChefSpec.define_matcher :mysql_config
ChefSpec.define_matcher :mysql_service
ChefSpec.define_matcher :mysql_client
# mysql_client_client_installation_package
def install_mysql_client_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client_installation_package, :create, resource_name)
end
# config
def remove_mysql_client_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_client_installation_package, :remove, resource_name)
end
# mysql_server_server_installation_package
def install_mysql_server_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_server_installation_package, :install, resource_name)
end
def remove_mysql_server_installation_package(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_server_installation_package, :remove, resource_name)
end
#####
# old
#####
# client
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
# mysql_config
def create_mysql_config(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_config, :create, resource_name)
end
@ -46,12 +68,4 @@ if defined?(ChefSpec)
ChefSpec::Matchers::ResourceMatcher.new(:mysql_service, :reload, resource_name)
end
# client
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
end

View File

@ -0,0 +1,30 @@
module MysqlCookbook
class MysqlBase < Chef::Resource
require_relative 'helpers'
# All resources are composites
def whyrun_supported?
true
end
################
# Type Constants
################
Boolean = property_type(
is: [true, false],
default: false
) unless defined?(Boolean)
###################
# Common Properties
###################
property :run_group, String, default: 'mysql', desired_state: false
property :run_user, String, default: 'mysql', desired_state: false
property :version, String, default: lazy { default_major_version }, desired_state: false
property :include_dir, String, default: lazy { default_include_dir }, desired_state: false
property :major_version, String, default: lazy { major_from_full(version) }, desired_state: false
declare_action_class
end
end

View File

@ -0,0 +1,31 @@
module MysqlCookbook
class MysqlClientInstallationPackage < MysqlBase
# helper methods
require_relative 'helpers'
include MysqlCookbook::HelpersBase
# Resource properties
resource_name :mysql_client_installation_package
provides :mysql_client_installation, os: 'linux'
provides :mysql_client, os: 'linux'
property :package_name, [String, Array], default: lazy { default_client_package_name }, desired_state: false
property :package_options, [String, nil], desired_state: false
property :package_version, [String, nil], default: nil, desired_state: false
# Actions
action :create do
package package_name do
version package_version if package_version
options package_options if package_options
action :install
end
end
action :delete do
package package_name do
action :remove
end
end
end
end

View File

@ -0,0 +1,56 @@
module MysqlCookbook
class MysqlConfig < MysqlBase
resource_name :mysql_config
property :config_name, String, name_property: true, desired_state: false
property :cookbook, String, desired_state: false
property :group, String, default: 'mysql', desired_state: false
property :instance, String, default: 'default', desired_state: false
property :owner, String, default: 'mysql', desired_state: false
property :source, String, desired_state: false
property :variables, [Hash], desired_state: false
property :version, String, default: lazy { default_major_version }, desired_state: false
require_relative 'helpers'
include MysqlCookbook::HelpersBase
provides :mysql_config
action :create do
# hax because group property
g = Chef::Resource::Group.new(new_resource.group, run_context)
g.system true if name == 'mysql'
resource_collection.insert g
user owner do
gid owner
system true if name == 'mysql'
action :create
end
directory include_dir do
owner new_resource.owner
group new_resource.group
mode '0750'
recursive true
action :create
end
template "#{include_dir}/#{config_name}.cnf" do
owner new_resource.owner
group new_resource.group
mode '0640'
variables(new_resource.variables)
source new_resource.source
cookbook new_resource.cookbook
action :create
end
end
action :delete do
file "#{include_dir}/#{config_name}.cnf" do
action :delete
end
end
end
end

View File

@ -0,0 +1,42 @@
module MysqlCookbook
class MysqlServerInstallationPackage < MysqlBase
# Resource properties
resource_name :mysql_server_installation_package
provides :mysql_server_installation, os: 'linux'
property :package_name, String, default: lazy { default_server_package_name }, desired_state: false
property :package_options, [String, nil], desired_state: false
property :package_version, [String, nil], default: nil, desired_state: false
# helper methods
require_relative 'helpers'
include MysqlCookbook::HelpersBase
# Actions
action :install do
package package_name do
version package_version if package_version
options package_options if package_options
notifies :install, 'package[perl-Sys-Hostname-Long]', :immediately if platform_family?('suse')
notifies :run, 'execute[Initial DB setup script]', :immediately if platform_family?('suse')
action :install
end
package 'perl-Sys-Hostname-Long' do
action :nothing
end
execute 'Initial DB setup script' do
environment 'INSTANCE' => new_resource.name
command '/usr/lib/mysql/mysql-systemd-helper install'
action :nothing
end
end
action :delete do
package package_name do
action :remove
end
end
end
end

View File

@ -0,0 +1,105 @@
module MysqlCookbook
require_relative 'mysql_service_base'
class MysqlService < MysqlServiceBase
resource_name :mysql_service
# installation type and service_manager
property :install_method, %w(package auto), default: 'auto', desired_state: false
property :service_manager, %w(sysvinit upstart systemd auto), default: 'auto', desired_state: false
# mysql_server_installation
property :version, String, default: lazy { default_major_version }, desired_state: false
property :major_version, String, default: lazy { major_from_full(version) }, desired_state: false
property :package_name, String, default: lazy { default_package_name }, desired_state: false
property :package_options, [String, nil], desired_state: false
property :package_version, [String, nil], default: nil, desired_state: false
################
# Helper Methods
################
def copy_properties_to(to, *properties)
properties = self.class.properties.keys if properties.empty?
properties.each do |p|
# If the property is set on from, and exists on to, set the
# property on to
if to.class.properties.include?(p) && property_is_set?(p)
to.send(p, send(p))
end
end
end
action_class.class_eval do
def installation(&block)
case install_method
when 'auto'
install = mysql_server_installation(name, &block)
when 'package'
install = mysql_server_installation_package(name, &block)
when 'none'
Chef::Log.info('Skipping MySQL installation. Assuming it was handled previously.')
return
end
copy_properties_to(install)
install
end
def svc_manager(&block)
case service_manager
when 'auto'
svc = mysql_service_manager(name, &block)
when 'sysvinit'
svc = mysql_service_manager_sysvinit(name, &block)
when 'upstart'
svc = mysql_service_manager_upstart(name, &block)
when 'systemd'
svc = mysql_service_manager_systemd(name, &block)
end
copy_properties_to(svc)
svc
end
end
#########
# Actions
#########
action :create do
installation do
action :install
end
svc_manager do
action :create
end
end
action :start do
svc_manager do
action :start
end
end
action :delete do
svc_manager do
action :delete
end
installation do
action :delete
end
end
action :restart do
svc_manager do
action :restart
end
end
action :stop do
svc_manager do
action :stop
end
end
end
end

View File

@ -0,0 +1,203 @@
module MysqlCookbook
class MysqlServiceBase < MysqlBase
property :bind_address, String, desired_state: false
property :charset, String, default: 'utf8', desired_state: false
property :data_dir, String, default: lazy { default_data_dir }, desired_state: false
property :error_log, String, default: lazy { default_error_log }, desired_state: false
property :initial_root_password, String, default: 'ilikerandompasswords', desired_state: false
property :instance, String, name_property: true, desired_state: false
property :mysqld_options, Hash, default: {}, desired_state: false
property :pid_file, String, default: lazy { default_pid_file }, desired_state: false
property :port, [String, Integer], default: '3306', desired_state: false
property :socket, String, default: lazy { default_socket_file }, desired_state: false
property :tmp_dir, String, desired_state: false
alias socket_file socket
require_relative 'helpers'
include MysqlCookbook::HelpersBase
# action class methods are available within the actions and work as if the coded
# was inline the action. No messing with classes or passing in the new_resource
declare_action_class.class_eval do
def create_system_user
group 'mysql' do
action :create
end
user 'mysql' do
gid 'mysql'
action :create
end
end
def create_config
# require 'pry' ; binding.pry
# Yak shaving secion. Account for random errata.
#
# Turns out that mysqld is hard coded to try and read
# /etc/mysql/my.cnf, and its presence causes problems when
# setting up multiple services.
file "#{prefix_dir}/etc/mysql/my.cnf" do
action :delete
end
file "#{prefix_dir}/etc/my.cnf" do
action :delete
end
# mysql_install_db is broken on 5.6.13
link "#{prefix_dir}/usr/share/my-default.cnf" do
to "#{etc_dir}/my.cnf"
not_if { ::File.exist? "#{prefix_dir}/usr/share/my-default.cnf" } # FIXME: Chef bug?
action :create
end
# Support directories
directory etc_dir do
owner run_user
group run_group
mode '0750'
recursive true
action :create
end
directory include_dir do
owner run_user
group run_group
mode '0750'
recursive true
action :create
end
directory run_dir do
owner run_user
group run_group
mode '0755'
recursive true
action :create
end
directory log_dir do
owner run_user
group run_group
mode '0750'
recursive true
action :create
end
directory data_dir do
owner run_user
group run_group
mode '0750'
recursive true
action :create
end
# Main configuration file
template "#{etc_dir}/my.cnf" do
source 'my.cnf.erb'
cookbook 'mysql'
owner run_user
group run_group
mode '0600'
variables(config: new_resource)
action :create
end
end
def initialize_database
# initialize database and create initial records
bash "#{name} initial records" do
code init_records_script
umask '022'
returns [0, 1, 2] # facepalm
not_if "/usr/bin/test -f #{data_dir}/mysql/user.frm"
action :run
end
end
def delete_support_directories
# Stop the service before removing support directories
delete_stop_service
directory etc_dir do
recursive true
action :delete
end
directory run_dir do
recursive true
action :delete
end
directory log_dir do
recursive true
action :delete
end
end
#
# Platform specific bits
#
def configure_apparmor
# Do not add these resource if inside a container
# Only valid on Ubuntu
return if ::File.exist?('/.dockerenv') || ::File.exist?('/.dockerinit') || node['platform'] != 'ubuntu'
# Apparmor
package 'apparmor' do
action :install
end
directory '/etc/apparmor.d/local/mysql' do
owner 'root'
group 'root'
mode '0755'
recursive true
action :create
end
template '/etc/apparmor.d/local/usr.sbin.mysqld' do
cookbook 'mysql'
source 'apparmor/usr.sbin.mysqld-local.erb'
owner 'root'
group 'root'
mode '0644'
action :create
notifies :restart, "service[#{instance} apparmor]", :immediately
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 :restart, "service[#{instance} apparmor]", :immediately
end
template "/etc/apparmor.d/local/mysql/#{instance}" do
cookbook 'mysql'
source 'apparmor/usr.sbin.mysqld-instance.erb'
owner 'root'
group 'root'
mode '0644'
variables(
config: new_resource,
mysql_name: mysql_name
)
action :create
notifies :restart, "service[#{instance} apparmor]", :immediately
end
service "#{instance} apparmor" do
service_name 'apparmor'
action :nothing
end
end
end
end
end

View File

@ -0,0 +1,142 @@
module MysqlCookbook
class MysqlServiceManagerSystemd < MysqlServiceBase
resource_name :mysql_service_manager_systemd
provides :mysql_service_manager, os: 'linux' do |_node|
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:systemd)
end
action :create do
# from base
create_system_user
stop_system_service
create_config
configure_apparmor
initialize_database
end
action :start do
# Needed for Debian / Ubuntu
directory '/usr/libexec' do
owner 'root'
group 'root'
mode '0755'
action :create
end
# this script is called by the main systemd unit file, and
# spins around until the service is actually up and running.
template "/usr/libexec/#{mysql_name}-wait-ready" do
path "/usr/libexec/#{mysql_name}-wait-ready"
source 'systemd/mysqld-wait-ready.erb'
owner 'root'
group 'root'
mode '0755'
variables(socket_file: socket_file)
cookbook 'mysql'
action :create
end
# this is the main systemd unit file
template "/etc/systemd/system/#{mysql_name}.service" do
path "/etc/systemd/system/#{mysql_name}.service"
source 'systemd/mysqld.service.erb'
owner 'root'
group 'root'
mode '0644'
variables(
config: new_resource,
etc_dir: etc_dir,
base_dir: base_dir,
mysqld_bin: mysqld_bin
)
cookbook 'mysql'
notifies :run, "execute[#{instance} systemctl daemon-reload]", :immediately
action :create
end
# avoid 'Unit file changed on disk' warning
execute "#{instance} systemctl daemon-reload" do
command '/bin/systemctl daemon-reload'
action :nothing
end
# tmpfiles.d config so the service survives reboot
template "/usr/lib/tmpfiles.d/#{mysql_name}.conf" do
path "/usr/lib/tmpfiles.d/#{mysql_name}.conf"
source 'tmpfiles.d.conf.erb'
owner 'root'
group 'root'
mode '0644'
variables(
run_dir: run_dir,
run_user: run_user,
run_group: run_group
)
cookbook 'mysql'
action :create
end
# service management resource
service mysql_name.to_s do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports restart: true, status: true
action [:enable, :start]
end
end
action :stop do
# service management resource
service mysql_name.to_s do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports status: true
action [:disable, :stop]
only_if { ::File.exist?("/usr/lib/systemd/system/#{mysql_name}.service") }
end
end
action :restart do
# service management resource
service mysql_name.to_s do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports restart: true
action :restart
end
end
action :reload do
# service management resource
service mysql_name.to_s do
service_name mysql_name
provider Chef::Provider::Service::Systemd
action :reload
end
end
declare_action_class.class_eval do
def stop_system_service
# service management resource
service 'mysql' do
service_name system_service_name
provider Chef::Provider::Service::Systemd
supports status: true
action [:stop, :disable]
end
end
def delete_stop_service
# service management resource
service mysql_name.to_s do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports status: true
action [:disable, :stop]
only_if { ::File.exist?("/usr/lib/systemd/system/#{mysql_name}.service") }
end
end
end
end
end

View File

@ -0,0 +1,79 @@
module MysqlCookbook
class MysqlServiceManagerSysvinit < MysqlServiceBase
resource_name :mysql_service_manager_sysvinit
provides :mysql_service_manager, os: 'linux'
action :create do
# from base
create_system_user
stop_system_service
create_config
initialize_database
configure_apparmor
end
action :start do
template "/etc/init.d/#{mysql_name}" do
source 'sysvinit/mysqld.erb'
owner 'root'
group 'root'
mode '0755'
variables(
config: new_resource,
defaults_file: defaults_file,
error_log: error_log,
mysql_name: mysql_name,
mysqladmin_bin: mysqladmin_bin,
mysqld_safe_bin: mysqld_safe_bin,
pid_file: pid_file,
scl_name: scl_name
)
cookbook 'mysql'
action :create
end
service mysql_name do
supports restart: true, status: true
action [:enable, :start]
end
end
action :stop do
service mysql_name do
supports restart: true, status: true
action [:stop]
end
end
action :restart do
service mysql_name do
supports restart: true
action :restart
end
end
action :reload do
service mysql_name do
action :reload
end
end
declare_action_class.class_eval do
def stop_system_service
service system_service_name do
supports status: true
action [:stop, :disable]
end
end
def delete_stop_service
service mysql_name do
supports status: true
action [:disable, :stop]
only_if { ::File.exist?("#{etc_dir}/init.d/#{mysql_name}") }
end
end
end
end
end

View File

@ -0,0 +1,103 @@
module MysqlCookbook
class MysqlServiceManagerUpstart < MysqlServiceBase
resource_name :mysql_service_manager_upstart
provides :mysql_service_manager, platform_family: 'debian' do |_node|
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart) &&
!Chef::Platform::ServiceHelpers.service_resource_providers.include?(:systemd) &&
!Chef::Platform::ServiceHelpers.service_resource_providers.include?(:redhat) &&
::File.exist?('/sbin/status') # Fix for Docker, in 7 and 8 images /sbin/status doesn't exists and Upstart provider doesn't work
end
action :create do
# from base
create_system_user
stop_system_service
create_config
configure_apparmor
initialize_database
end
action :start do
template "/usr/sbin/#{mysql_name}-wait-ready" do
source 'upstart/mysqld-wait-ready.erb'
owner 'root'
group 'root'
mode '0755'
variables(socket_file: socket_file)
cookbook 'mysql'
action :create
end
template "/etc/init/#{mysql_name}.conf" do
source 'upstart/mysqld.erb'
owner 'root'
group 'root'
mode '0644'
variables(
defaults_file: defaults_file,
mysql_name: mysql_name,
run_group: run_group,
run_user: run_user,
socket_dir: socket_dir
)
cookbook 'mysql'
action :create
end
service mysql_name do
provider Chef::Provider::Service::Upstart
supports status: true
action [:start]
end
end
action :stop do
service mysql_name do
provider Chef::Provider::Service::Upstart
supports restart: true, status: true
action [:stop]
end
end
action :restart do
# With Upstart, restarting the service doesn't behave "as expected".
# We want the post-start stanzas, which wait until the
# service is available before returning
#
# http://upstart.ubuntu.com/cookbook/#restart
service mysql_name do
provider Chef::Provider::Service::Upstart
action [:stop, :start]
end
end
action :reload do
# With Upstart, reload just sends a HUP signal to the process.
# As far as I can tell, this doesn't work the way it's
# supposed to, so we need to actually restart the service.
service mysql_name do
provider Chef::Provider::Service::Upstart
action [:stop, :start]
end
end
declare_action_class.class_eval do
def stop_system_service
service system_service_name do
provider Chef::Provider::Service::Upstart
supports status: true
action [:stop, :disable]
end
end
def delete_stop_service
service mysql_name do
provider Chef::Provider::Service::Upstart
action [:disable, :stop]
only_if { ::File.exist?("#{etc_dir}/init/#{mysql_name}") }
end
end
end
end
end

View File

@ -1,39 +0,0 @@
require 'chef/provider/lwrp_base'
require_relative 'helpers'
class Chef
class Provider
class MysqlClient < Chef::Provider::LWRPBase
include MysqlCookbook::Helpers
provides :mysql_client if defined?(provides)
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :create do
# From helpers.rb
configure_package_repositories
client_package_name.each do |p|
package "#{new_resource.name} :create #{p}" do
package_name p
version new_resource.version if node['platform'] == 'smartos'
version new_resource.package_version
action :install
end
end
end
action :delete do
parsed_package_name.each do |p|
package "#{new_resource.name} :delete #{p}" do
action :remove
end
end
end
end
end
end

View File

@ -1,59 +0,0 @@
require 'chef/provider/lwrp_base'
require_relative 'helpers'
class Chef
class Provider
class MysqlConfig < Chef::Provider::LWRPBase
include MysqlCookbook::Helpers
provides :mysql_config if defined?(provides)
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
action :create do
group "#{new_resource.name} :create #{new_resource.group}" do
group_name new_resource.group
system true if new_resource.name == 'mysql'
action :create
end
user "#{new_resource.name} :create #{new_resource.owner}" do
username new_resource.owner
gid new_resource.owner
system true if new_resource.name == 'mysql'
action :create
end
directory "#{new_resource.name} :create #{include_dir}" do
path include_dir
owner new_resource.owner
group new_resource.group
mode '0750'
recursive true
action :create
end
template "#{new_resource.name} :create #{include_dir}/#{new_resource.config_name}.cnf" do
path "#{include_dir}/#{new_resource.config_name}.cnf"
owner new_resource.owner
group new_resource.group
mode '0640'
variables(new_resource.variables)
source new_resource.source
cookbook new_resource.cookbook
action :create
end
end
action :delete do
file "#{new_resource.name} :delete #{include_dir}/#{new_resource.config_name}.conf" do
path "#{include_dir}/#{new_resource.config_name}.conf"
action :delete
end
end
end
end
end

View File

@ -1,250 +0,0 @@
require 'chef/provider/lwrp_base'
require_relative 'helpers'
class Chef
class Provider
class MysqlServiceBase < Chef::Provider::LWRPBase
use_inline_resources if defined?(use_inline_resources)
def whyrun_supported?
true
end
# Mix in helpers from libraries/helpers.rb
include MysqlCookbook::Helpers
# Service related methods referred to in the :create and :delete
# actions need to be implemented in the init system subclasses.
#
# create_stop_system_service
# delete_stop_service
# All other methods are found in libraries/helpers.rb
#
# etc_dir, run_dir, log_dir, etc
action :create do
# Yum, Apt, etc. From helpers.rb
configure_package_repositories
# Software installation
package "#{new_resource.name} :create #{server_package_name}" do
package_name server_package_name
version parsed_version if node['platform'] == 'smartos'
version new_resource.package_version
action new_resource.package_action
end
create_stop_system_service
# Apparmor
configure_apparmor
# System users
group "#{new_resource.name} :create mysql" do
group_name 'mysql'
action :create
end
user "#{new_resource.name} :create mysql" do
username 'mysql'
gid 'mysql'
action :create
end
# Yak shaving secion. Account for random errata.
#
# Turns out that mysqld is hard coded to try and read
# /etc/mysql/my.cnf, and its presence causes problems when
# setting up multiple services.
file "#{new_resource.name} :create #{prefix_dir}/etc/mysql/my.cnf" do
path "#{prefix_dir}/etc/mysql/my.cnf"
action :delete
end
file "#{new_resource.name} :create #{prefix_dir}/etc/my.cnf" do
path "#{prefix_dir}/etc/my.cnf"
action :delete
end
# mysql_install_db is broken on 5.6.13
link "#{new_resource.name} :create #{prefix_dir}/usr/share/my-default.cnf" do
target_file "#{prefix_dir}/usr/share/my-default.cnf"
to "#{etc_dir}/my.cnf"
action :create
end
# Support directories
directory "#{new_resource.name} :create #{etc_dir}" do
path etc_dir
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
directory "#{new_resource.name} :create #{include_dir}" do
path include_dir
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
directory "#{new_resource.name} :create #{run_dir}" do
path run_dir
owner new_resource.run_user
group new_resource.run_group
mode '0755'
recursive true
action :create
end
directory "#{new_resource.name} :create #{log_dir}" do
path log_dir
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
directory "#{new_resource.name} :create #{parsed_data_dir}" do
path parsed_data_dir
owner new_resource.run_user
group new_resource.run_group
mode '0750'
recursive true
action :create
end
# Main configuration file
template "#{new_resource.name} :create #{etc_dir}/my.cnf" do
path "#{etc_dir}/my.cnf"
source 'my.cnf.erb'
cookbook 'mysql'
owner new_resource.run_user
group new_resource.run_group
mode '0600'
variables(
config: new_resource,
error_log: error_log,
include_dir: include_dir,
lc_messages_dir: lc_messages_dir,
pid_file: pid_file,
socket_file: socket_file,
tmp_dir: tmp_dir,
data_dir: parsed_data_dir
)
action :create
end
# initialize database and create initial records
bash "#{new_resource.name} :create initial records" do
code init_records_script
returns [0, 1, 2] # facepalm
not_if "/usr/bin/test -f #{parsed_data_dir}/mysql/user.frm"
action :run
end
end
action :delete do
# Stop the service before removing support directories
delete_stop_service
directory "#{new_resource.name} :delete #{etc_dir}" do
path etc_dir
recursive true
action :delete
end
directory "#{new_resource.name} :delete #{run_dir}" do
path run_dir
recursive true
action :delete
end
directory "#{new_resource.name} :delete #{log_dir}" do
path log_dir
recursive true
action :delete
end
end
#
# Platform specific bits
#
def configure_apparmor
# Do not add these resource if inside a container
# Only valid on Ubuntu
unless ::File.exist?('/.dockerenv') || ::File.exist?('/.dockerinit')
if node['platform'] == 'ubuntu'
# Apparmor
package "#{new_resource.name} :create apparmor" do
package_name 'apparmor'
action :install
end
directory "#{new_resource.name} :create /etc/apparmor.d/local/mysql" do
path '/etc/apparmor.d/local/mysql'
owner 'root'
group 'root'
mode '0755'
recursive true
action :create
end
template "#{new_resource.name} :create /etc/apparmor.d/local/usr.sbin.mysqld" do
path '/etc/apparmor.d/local/usr.sbin.mysqld'
cookbook 'mysql'
source 'apparmor/usr.sbin.mysqld-local.erb'
owner 'root'
group 'root'
mode '0644'
action :create
notifies :restart, "service[#{new_resource.name} :create apparmor]", :immediately
end
template "#{new_resource.name} :create /etc/apparmor.d/usr.sbin.mysqld" do
path '/etc/apparmor.d/usr.sbin.mysqld'
cookbook 'mysql'
source 'apparmor/usr.sbin.mysqld.erb'
owner 'root'
group 'root'
mode '0644'
action :create
notifies :restart, "service[#{new_resource.name} :create apparmor]", :immediately
end
template "#{new_resource.name} :create /etc/apparmor.d/local/mysql/#{new_resource.instance}" do
path "/etc/apparmor.d/local/mysql/#{new_resource.instance}"
cookbook 'mysql'
source 'apparmor/usr.sbin.mysqld-instance.erb'
owner 'root'
group 'root'
mode '0644'
variables(
data_dir: parsed_data_dir,
mysql_name: mysql_name,
log_dir: log_dir,
run_dir: run_dir,
pid_file: pid_file,
socket_file: socket_file
)
action :create
notifies :restart, "service[#{new_resource.name} :create apparmor]", :immediately
end
service "#{new_resource.name} :create apparmor" do
service_name 'apparmor'
action :nothing
end
end
end
end
end
end
end

View File

@ -1,91 +0,0 @@
class Chef
class Provider
class MysqlServiceSmf < Chef::Provider::MysqlServiceBase
# FIXME: we should have a service_helper to determine if the platform supports SMF similarly
# to how we handle systemd on linux
if defined?(provides) # foodcritic ~FC023
provides :mysql_service, os: %w(solaris2 omnios smartos openindiana opensolaris nexentacore) do
File.exist?('/usr/sbin/svccfg')
end
end
action :start do
method_script_path = "/lib/svc/method/#{mysql_name}" if node['platform'] == 'omnios'
method_script_path = "/opt/local/lib/svc/method/#{mysql_name}" if node['platform'] == 'smartos'
template "#{new_resource.name} :start #{method_script_path}" do
path method_script_path
cookbook 'mysql'
source 'smf/svc.method.mysqld.erb'
owner 'root'
group 'root'
mode '0555'
variables(
base_dir: base_dir,
data_dir: parsed_data_dir,
defaults_file: defaults_file,
error_log: error_log,
mysql_name: mysql_name,
mysqld_bin: mysqld_bin,
pid_file: pid_file
)
action :create
end
smf "#{new_resource.name} :start #{mysql_name}" do
name mysql_name
user new_resource.run_user
group new_resource.run_group
start_command "#{method_script_path} start"
end
service "#{new_resource.name} :start #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Solaris
supports restart: true
action [:enable]
end
end
action :stop do
service "#{new_resource.name} :stop #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Solaris
supports restart: true
action :stop
end
end
action :restart do
service "#{new_resource.name} :restart #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Solaris
supports restart: true
action :restart
end
end
action :reload do
service "#{new_resource.name} :reload #{mysql_name}" do
provider Chef::Provider::Service::Solaris
service_name mysql_name
supports reload: true
action :reload
end
end
def create_stop_system_service
# nothing to do here
end
def delete_stop_service
service "#{new_resource.name} :delete #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Solaris
supports restart: true
action :stop
end
end
end
end
end

View File

@ -1,135 +0,0 @@
require_relative 'provider_mysql_service_base'
class Chef
class Provider
class MysqlServiceSystemd < Chef::Provider::MysqlServiceBase
if defined?(provides) # foodcritic ~FC023
provides :mysql_service, os: 'linux' do
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:systemd)
end
end
action :start do
# Needed for Debian / Ubuntu
directory '/usr/libexec' do
owner 'root'
group 'root'
mode '0755'
action :create
end
# this script is called by the main systemd unit file, and
# spins around until the service is actually up and running.
template "#{new_resource.name} :start /usr/libexec/#{mysql_name}-wait-ready" do
path "/usr/libexec/#{mysql_name}-wait-ready"
source 'systemd/mysqld-wait-ready.erb'
owner 'root'
group 'root'
mode '0755'
variables(socket_file: socket_file)
cookbook 'mysql'
action :create
end
# this is the main systemd unit file
template "#{new_resource.name} :start /lib/systemd/system/#{mysql_name}.service" do
path "/lib/systemd/system/#{mysql_name}.service"
source 'systemd/mysqld.service.erb'
owner 'root'
group 'root'
mode '0644'
variables(
config: new_resource,
etc_dir: etc_dir,
base_dir: base_dir,
mysqld_bin: mysqld_bin
)
cookbook 'mysql'
notifies :run, "execute[#{new_resource.name} :start systemctl daemon-reload]", :immediately
action :create
end
# avoid 'Unit file changed on disk' warning
execute "#{new_resource.name} :start systemctl daemon-reload" do
command '/bin/systemctl daemon-reload'
action :nothing
end
# tmpfiles.d config so the service survives reboot
template "#{new_resource.name} :start /usr/lib/tmpfiles.d/#{mysql_name}.conf" do
path "/usr/lib/tmpfiles.d/#{mysql_name}.conf"
source 'tmpfiles.d.conf.erb'
owner 'root'
group 'root'
mode '0644'
variables(
run_dir: run_dir,
run_user: new_resource.run_user,
run_group: new_resource.run_group
)
cookbook 'mysql'
action :create
end
# service management resource
service "#{new_resource.name} :start #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports restart: true, status: true
action [:enable, :start]
end
end
action :stop do
# service management resource
service "#{new_resource.name} :stop #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports status: true
action [:disable, :stop]
only_if { ::File.exist?("/usr/lib/systemd/system/#{mysql_name}.service") }
end
end
action :restart do
# service management resource
service "#{new_resource.name} :restart #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports restart: true
action :restart
end
end
action :reload do
# service management resource
service "#{new_resource.name} :reload #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Systemd
action :reload
end
end
def create_stop_system_service
# service management resource
service "#{new_resource.name} :create mysql" do
service_name system_service_name
provider Chef::Provider::Service::Systemd
supports status: true
action [:stop, :disable]
end
end
def delete_stop_service
# service management resource
service "#{new_resource.name} :delete #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Systemd
supports status: true
action [:disable, :stop]
only_if { ::File.exist?("/usr/lib/systemd/system/#{mysql_name}.service") }
end
end
end
end
end

View File

@ -1,89 +0,0 @@
require_relative 'provider_mysql_service_base'
class Chef
class Provider
class MysqlServiceSysvinit < Chef::Provider::MysqlServiceBase
provides :mysql_service, os: '!windows' if defined?(provides)
action :start do
template "#{new_resource.name} :start /etc/init.d/#{mysql_name}" do
path "/etc/init.d/#{mysql_name}"
source 'sysvinit/mysqld.erb'
owner 'root'
group 'root'
mode '0755'
variables(
config: new_resource,
defaults_file: defaults_file,
error_log: error_log,
mysql_name: mysql_name,
mysqladmin_bin: mysqladmin_bin,
mysqld_safe_bin: mysqld_safe_bin,
pid_file: pid_file,
scl_name: scl_name
)
cookbook 'mysql'
action :create
end
service "#{new_resource.name} :start #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Init::Redhat if node['platform_family'] == 'redhat'
provider Chef::Provider::Service::Init::Insserv if node['platform_family'] == 'debian'
supports restart: true, status: true
action [:enable, :start]
end
end
action :stop do
service "#{new_resource.name} :stop #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Init::Redhat if node['platform_family'] == 'redhat'
provider Chef::Provider::Service::Init::Insserv if node['platform_family'] == 'debian'
supports restart: true, status: true
action [:stop]
end
end
action :restart do
service "#{new_resource.name} :restart #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Init::Redhat if node['platform_family'] == 'redhat'
provider Chef::Provider::Service::Init::Insserv if node['platform_family'] == 'debian'
supports restart: true
action :restart
end
end
action :reload do
service "#{new_resource.name} :reload #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Init::Redhat if node['platform_family'] == 'redhat'
provider Chef::Provider::Service::Init::Insserv if node['platform_family'] == 'debian'
action :reload
end
end
def create_stop_system_service
service "#{new_resource.name} :create #{system_service_name}" do
service_name system_service_name
provider Chef::Provider::Service::Init::Redhat if node['platform_family'] == 'redhat'
provider Chef::Provider::Service::Init::Insserv if node['platform_family'] == 'debian'
supports status: true
action [:stop, :disable]
end
end
def delete_stop_service
service "#{new_resource.name} :delete #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Init::Redhat if node['platform_family'] == 'redhat'
provider Chef::Provider::Service::Init::Insserv if node['platform_family'] == 'debian'
supports status: true
action [:disable, :stop]
only_if { ::File.exist?("#{etc_dir}/init.d/#{mysql_name}") }
end
end
end
end
end

View File

@ -1,114 +0,0 @@
require_relative 'provider_mysql_service_base'
class Chef
class Provider
class MysqlServiceUpstart < Chef::Provider::MysqlServiceBase
if defined?(provides) # foodcritic ~FC023
provides :mysql_service, os: 'linux' do
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart) &&
!Chef::Platform::ServiceHelpers.service_resource_providers.include?(:redhat)
end
end
action :start do
template "#{new_resource.name} :start /usr/sbin/#{mysql_name}-wait-ready" do
path "/usr/sbin/#{mysql_name}-wait-ready"
source 'upstart/mysqld-wait-ready.erb'
owner 'root'
group 'root'
mode '0755'
variables(socket_file: socket_file)
cookbook 'mysql'
action :create
end
template "#{new_resource.name} :start /etc/init/#{mysql_name}.conf" do
path "/etc/init/#{mysql_name}.conf"
source 'upstart/mysqld.erb'
owner 'root'
group 'root'
mode '0644'
variables(
defaults_file: defaults_file,
mysql_name: mysql_name,
run_group: new_resource.run_group,
run_user: new_resource.run_user,
socket_dir: socket_dir
)
cookbook 'mysql'
action :create
end
service "#{new_resource.name} :start #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Upstart
supports status: true
action [:start]
end
end
action :stop do
service "#{new_resource.name} :stop #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Upstart
supports restart: true, status: true
action [:stop]
end
end
action :restart do
# With Upstart, restarting the service doesn't behave "as expected".
# We want the post-start stanzas, which wait until the
# service is available before returning
#
# http://upstart.ubuntu.com/cookbook/#restart
service "#{new_resource.name} :restart stop #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Upstart
action :stop
end
service "#{new_resource.name} :restart start #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Upstart
action :start
end
end
action :reload do
# With Upstart, reload just sends a HUP signal to the process.
# As far as I can tell, this doesn't work the way it's
# supposed to, so we need to actually restart the service.
service "#{new_resource.name} :reload stop #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Upstart
action :stop
end
service "#{new_resource.name} :reload start #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Upstart
action :start
end
end
def create_stop_system_service
service "#{new_resource.name} :create #{system_service_name}" do
service_name system_service_name
provider Chef::Provider::Service::Upstart
supports status: true
action [:stop, :disable]
end
end
def delete_stop_service
service "#{new_resource.name} :delete #{mysql_name}" do
service_name mysql_name
provider Chef::Provider::Service::Upstart
action [:disable, :stop]
only_if { ::File.exist?("#{etc_dir}/init/#{mysql_name}") }
end
end
end
end
end

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