├── .delivery └── project.toml ├── .gitignore ├── .kitchen.dokken.yml ├── .kitchen.yml ├── .travis.yml ├── Berksfile ├── CHANGELOG.md ├── Gemfile ├── LICENSE ├── README.md ├── chefignore ├── libraries └── matchers.rb ├── metadata.rb ├── resources ├── mysql2_chef_gem_mariadb.rb └── mysql2_chef_gem_mysql.rb ├── spec ├── default_spec.rb └── spec_helper.rb └── test ├── fixtures └── cookbooks │ └── mysql2_chef_gem_test │ ├── metadata.rb │ └── recipes │ └── default.rb └── integration ├── client50-mysql └── serverspec │ └── assert_functioning_spec.rb ├── client51-mysql └── serverspec │ └── assert_functioning_spec.rb ├── client55-mariadb └── serverspec │ └── assert_functioning_spec.rb ├── client55-mysql └── serverspec │ └── assert_functioning_spec.rb ├── client56-mysql └── serverspec │ └── assert_functioning_spec.rb └── client57-mysql └── serverspec └── assert_functioning_spec.rb /.delivery/project.toml: -------------------------------------------------------------------------------- 1 | remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml" 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.rbc 2 | .config 3 | coverage 4 | InstalledFiles 5 | lib/bundler/man 6 | pkg 7 | rdoc 8 | spec/reports 9 | test/tmp 10 | test/version_tmp 11 | tmp 12 | _Store 13 | *~ 14 | *# 15 | .#* 16 | \#*# 17 | .*.sw[a-z] 18 | *.un~ 19 | *.tmp 20 | *.bk 21 | *.bkup 22 | 23 | # ruby/bundler files 24 | .ruby-version 25 | .ruby-gemset 26 | .rvmrc 27 | Gemfile.lock 28 | .bundle 29 | *.gem 30 | 31 | # YARD artifacts 32 | .yardoc 33 | _yardoc 34 | doc/ 35 | .idea 36 | 37 | # chef stuff 38 | Berksfile.lock 39 | .kitchen 40 | .kitchen.local.yml 41 | vendor/ 42 | .coverage/ 43 | .zero-knife.rb 44 | Policyfile.lock.json 45 | Cheffile.lock 46 | .librarian/ 47 | 48 | # vagrant stuff 49 | .vagrant/ 50 | .vagrant.d/ 51 | .kitchen/ 52 | -------------------------------------------------------------------------------- /.kitchen.dokken.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: dokken 3 | privileged: true # because Docker and SystemD/Upstart 4 | chef_version: current 5 | volumes: [ '/mnt' ] 6 | 7 | transport: 8 | name: dokken 9 | 10 | provisioner: 11 | name: dokken 12 | deprecations_as_errors: true 13 | 14 | verifier: 15 | name: inspec 16 | 17 | platforms: 18 | - name: amazonlinux 19 | driver: 20 | privileged: true 21 | image: dokken/amazonlinux 22 | pid_one_command: /sbin/init 23 | 24 | - name: debian-7 25 | driver: 26 | privileged: true 27 | image: dokken/debian-7 28 | pid_one_command: /sbin/init 29 | intermediate_instructions: 30 | - RUN /usr/bin/apt-get update 31 | 32 | - name: debian-8 33 | driver: 34 | privileged: true 35 | image: dokken/debian-8 36 | pid_one_command: /bin/systemd 37 | intermediate_instructions: 38 | - RUN /usr/bin/apt-get update 39 | 40 | - name: debian-9 41 | driver: 42 | privileged: true 43 | image: dokken/debian-9 44 | pid_one_command: /bin/systemd 45 | intermediate_instructions: 46 | - RUN /usr/bin/apt-get update 47 | 48 | - name: centos-6 49 | driver: 50 | privileged: true 51 | image: dokken/centos-6 52 | pid_one_command: /sbin/init 53 | 54 | - name: centos-7 55 | driver: 56 | privileged: true 57 | image: dokken/centos-7 58 | pid_one_command: /usr/lib/systemd/systemd 59 | 60 | - name: fedora-25 61 | driver: 62 | image: fedora:25 63 | privileged: true 64 | pid_one_command: /usr/lib/systemd/systemd 65 | intermediate_instructions: 66 | - RUN dnf -y install yum which systemd-sysv initscripts wget net-tools 67 | 68 | - name: ubuntu-14.04 69 | driver: 70 | privileged: true 71 | image: dokken/ubuntu-14.04 72 | pid_one_command: /sbin/init 73 | intermediate_instructions: 74 | - RUN /usr/bin/apt-get update 75 | 76 | - name: ubuntu-16.04 77 | driver: 78 | privileged: true 79 | image: dokken/ubuntu-16.04 80 | pid_one_command: /bin/systemd 81 | intermediate_instructions: 82 | - RUN /usr/bin/apt-get update 83 | 84 | - name: opensuse-leap 85 | driver: 86 | privileged: true 87 | image: dokken/opensuse-leap 88 | pid_one_command: /bin/systemd 89 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: vagrant 3 | 4 | provisioner: 5 | name: chef_zero 6 | deprecations_as_errors: true 7 | 8 | verifier: 9 | name: inspec 10 | 11 | platforms: 12 | - name: centos-6 13 | driver: 14 | box: bento/centos-6.8 15 | 16 | - name: centos-7 17 | driver: 18 | box: bento/centos-7.3 19 | 20 | - name: debian-7 21 | driver: 22 | box: bento/debian-7.11 23 | 24 | - name: debian-8 25 | driver: 26 | box: bento/debian-8.8 27 | 28 | - name: fedora-25 29 | driver: 30 | box: bento/fedora-25 31 | 32 | - name: opensuse-leap 33 | driver: 34 | box: bento/opensuse-leap-42.2 35 | 36 | - name: ubuntu-14.04 37 | driver: 38 | box: bento/ubuntu-14.04 39 | 40 | - name: ubuntu-16.04 41 | driver: 42 | box: bento/ubuntu-16.04 43 | 44 | suites: 45 | # 46 | # mysql2_chef_gem 47 | # 48 | - name: client51-mysql 49 | run_list: 50 | - recipe[mysql2_chef_gem_test::default] 51 | attributes: 52 | mysql2_chef_gem: 53 | package_version: '5.1' 54 | provider: 'mysql' 55 | includes: [ 56 | 'centos-6', 57 | ] 58 | 59 | - name: client55-mysql 60 | run_list: 61 | - recipe[mysql2_chef_gem_test::default] 62 | attributes: 63 | mysql2_chef_gem: 64 | package_version: '5.5' 65 | provider: 'mysql' 66 | includes: [ 67 | 'ubuntu-14.04', 68 | 'debian-7', 69 | 'debian-8', 70 | 'centos-6', 71 | 'centos-7' 72 | ] 73 | 74 | - name: client56-mysql 75 | run_list: 76 | - recipe[mysql2_chef_gem_test::default] 77 | attributes: 78 | mysql2_chef_gem: 79 | package_version: '5.6' 80 | provider: 'mysql' 81 | includes: [ 82 | 'centos-6', 83 | 'centos-7', 84 | 'fedora-25', 85 | 'ubuntu-14.04' 86 | ] 87 | 88 | - name: client57-mysql 89 | run_list: 90 | - recipe[mysql2_chef_gem_test::default] 91 | attributes: 92 | mysql2_chef_gem: 93 | package_version: '5.7' 94 | provider: 'mysql' 95 | includes: [ 96 | 'centos-6', 97 | 'centos-7', 98 | 'ubuntu-16.04' 99 | ] 100 | 101 | - name: client57-mariadb 102 | run_list: 103 | - recipe[mysql2_chef_gem_test::default] 104 | attributes: 105 | mysql2_chef_gem: 106 | provider: 'mariadb' 107 | mariadb: 108 | install: 109 | version: '5.5.52' 110 | includes: [ 111 | 'centos-7' 112 | ] 113 | 114 | ## MariaDB 115 | - name: client55-mariadb 116 | run_list: 117 | - recipe[mysql2_chef_gem_test::default] 118 | attributes: 119 | mysql2_chef_gem: 120 | provider: 'mariadb' 121 | mariadb: 122 | install: 123 | version: '5.5' 124 | includes: [ 125 | 'ubuntu-14.04' 126 | ] 127 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | 4 | addons: 5 | apt: 6 | sources: 7 | - chef-current-trusty 8 | packages: 9 | - chefdk 10 | 11 | # Don't `bundle install` which takes about 1.5 mins 12 | install: echo "skip bundle install" 13 | 14 | branches: 15 | only: 16 | - master 17 | 18 | services: docker 19 | 20 | env: 21 | matrix: 22 | 23 | - INSTANCE=client55-mysql-centos-6 24 | - INSTANCE=client55-mysql-centos-7 25 | - INSTANCE=client55-mysql-ubuntu-1404 26 | - INSTANCE=client56-mysql-centos-6 27 | - INSTANCE=client56-mysql-centos-7 28 | - INSTANCE=client56-mysql-ubuntu-1404 29 | - INSTANCE=client57-mysql-centos-6 30 | - INSTANCE=client57-mysql-centos-7 31 | - INSTANCE=client57-mysql-ubuntu-1604 32 | - INSTANCE=client55-mariadb-ubuntu-1404 33 | 34 | # Ensure we make ChefDK's Ruby the default 35 | before_script: 36 | - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) 37 | - eval "$(chef shell-init bash)" 38 | - chef --version 39 | - cookstyle --version 40 | - foodcritic --version 41 | 42 | script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml kitchen verify ${INSTANCE} 43 | 44 | matrix: 45 | include: 46 | - script: 47 | - chef exec delivery local all 48 | env: UNIT_AND_LINT=1 49 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'mysql2_chef_gem_test', path: 'test/fixtures/cookbooks/mysql2_chef_gem_test' 7 | end 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # mysql2_chef_gem CHANGELOG 2 | 3 | ## 2.1.0 (2017-08-23) 4 | 5 | - This cookbook now requires Chef 12.7 as 12.5/12.6 have issues with action_class and weren't actually functional in the previous releases 6 | - The resource now installs the mysql2 0.4.9 gem 7 | - Enabled FC016 testing once again 8 | - Switch the kitchen-dokken config to use dokken images 9 | - Update platforms we test in Test Kitchen and expand suites 10 | - Updates the supported and tested platforms in the readme 11 | - Updated the metadata to use a SPDX compliant license string 12 | 13 | ## 2.0.1 (2017-03-28) 14 | 15 | - Include usage examples for installing on a mariadb server and included a note in the readme regarding the 2.0 changes. 16 | 17 | ## 2.0.0 (2017-03-28) 18 | 19 | - Converted the previously HWRP resources/providers to a custom resource. This changes the behavior of choosing to install on mysql or mariadb in a breaking way. Instead of specifying the providers you need to call the resources directly. Specifying mysql2_chef_gem will default to mysql, but using mariadb will require using the mysql2_chef_gem_mariadb resource directly. 20 | - Increase the minimum chef version to 12.5 21 | - Require mysql cookbook 8.2+ and build-essential cookbook 2.4+ 22 | - Install the 0.4.5 gem by default 23 | - Expand test recipe to cover more scenarios 24 | - Switched testing to use Delivery local mode 25 | - Switched from kitchen-docker to kitchen-dokken and removed testing for CentOS 5 / Ubuntu 12.04 as these are both going EOL 26 | - Switched from Rubocop to cookstyle for linting 27 | - Removed yum/apt from the Berksfile 28 | - Remove test dependencies from the Gemfile and instead use ChefDK for testing 29 | 30 | ## 1.1.0 (2016-04-27) 31 | 32 | - Added a chefignore file 33 | - Loosen the dependency on mysql cookbook to allow for the use of the latest version 34 | - Added source_url and issue_url metadata 35 | - Added long_description metadata 36 | - Removed the AWS based Test Kitchen testing and replaced with with kitchen-docker in Travis 37 | - Updated Chefspec format to remove deprecation warnings 38 | - Added Oracle Linux to the metadata 39 | 40 | ## 1.0.2 (2015-06-29) 41 | 42 | - Updating metadata to depend on mysql ~> 6.0 43 | 44 | ## 1.0.1 (2014-12-25) 45 | 46 | - Moving from recipe_eval in to include_recipe LWRP 47 | 48 | ## 1.0.0 (2014-12-23) 49 | 50 | - Replacing recipes with resources 51 | - Mysql and MariaDB providers for linking mysql2 gem 52 | - Expanded platform test coverage 53 | 54 | ## 0.1.1 (2014-09-15) 55 | 56 | - Correct a typo in documentation 57 | - Correct a test failing with Travis CI 58 | 59 | ## 0.1.0 (2014-09-15) 60 | 61 | - Correct documentation 62 | - Correct rubocop offenses 63 | 64 | ## 0.0.3 (2014-09-12) 65 | 66 | - Initial release (copy of mysql-chef_gem, but for mysql2) 67 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # This gemfile provides additional gems for testing and releasing this cookbook 2 | # It is meant to be installed on top of ChefDK which provides the majority 3 | # of the necessary gems for testing this cookbook 4 | # 5 | # Run 'chef exec bundle install' to install these dependencies 6 | 7 | source 'https://rubygems.org' 8 | 9 | gem 'stove' 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mysql2 Chef Gem Installer Cookbook 2 | 3 | [![Build Status](https://travis-ci.org/sinfomicien/mysql2_chef_gem.svg)](https://travis-ci.org/sinfomicien/mysql2_chef_gem) [![Cookbook Version](http://img.shields.io/cookbook/v/mysql2_chef_gem.svg)](https://supermarket.chef.io/cookbooks/mysql2_chef_gem) 4 | 5 | mysql2_chef_gem is a library cookbook that provides a resource for installing the mysql2 gem against either mysql or mariadb depending on usage. 6 | 7 | ## Scope 8 | 9 | This cookbook is concerned with the installation of the `mysql2` Rubygem into Chef's gem path. Installation into other Ruby environments, or installation of related gems such as `mysql` are outside the scope of this cookbook. 10 | 11 | ## Requirements 12 | 13 | - Chef 12.7+ 14 | 15 | ## Platform Support 16 | 17 | The following platforms have been tested with Test Kitchen and are known to work. 18 | 19 | ``` 20 | |---------------------------------------+-----+-----+-----+-----| 21 | | | 5.1 | 5.5 | 5.6 | 5.7 | 22 | |---------------------------------------+-----+-----+-----+-----| 23 | | Mysql2ChefGem::Mysql / centos-6 | X | X | X | X | 24 | |---------------------------------------+-----+-----+-----+-----| 25 | | Mysql2ChefGem::Mysql / centos-7 | | X | X | X | 26 | |---------------------------------------+-----+-----+-----+-----| 27 | | Mysql2ChefGem::Mysql / fedora | | X | X | X | 28 | |---------------------------------------+-----+-----+-----+-----| 29 | | Mysql2ChefGem::Mysql / debian-7 | | X | | | 30 | |---------------------------------------+-----+-----+-----+-----| 31 | | Mysql2ChefGem::Mysql / ubuntu-14.04 | | X | X | | 32 | |---------------------------------------+-----+-----+-----+-----| 33 | | Mysql2ChefGem::Mysql / ubuntu-16.04 | | | | X | 34 | |---------------------------------------+-----+-----+-----+-----| 35 | | Mysql2ChefGem::Mariadb / fedora | | X | | | 36 | |---------------------------------------+-----+-----+-----+-----| 37 | | Mysql2ChefGem::Mariadb / ubuntu-14.04 | | X | | | 38 | |---------------------------------------+-----+-----+-----+-----| 39 | ``` 40 | 41 | ## Usage 42 | 43 | Place a dependency on the mysql cookbook in your cookbook's metadata.rb 44 | 45 | ```ruby 46 | depends 'mysql2_chef_gem' 47 | ``` 48 | 49 | Then, in a recipe: 50 | 51 | ```ruby 52 | mysql2_chef_gem 'default' do 53 | action :install 54 | end 55 | ``` 56 | 57 | ### 2.0 Compatibility 58 | 59 | In order to ensure compatibility with Chef 13, the 2.0 release of this cookbook changed the method used to specify installation against mariadb. Instead of specifying the underlying provider, you instead reference the mariadb specific resource. See the example below for the new syntax. 60 | 61 | ## Resources Overview 62 | 63 | ### mysql2_chef_gem 64 | 65 | The `mysql2_chef_gem` resource installs mysql client development dependencies and installs the `mysql2` rubygem into Chef's Ruby environment. 66 | 67 | #### Example 68 | 69 | ```ruby 70 | mysql2_chef_gem 'default' do 71 | gem_version '0.4.5' 72 | action :install 73 | end 74 | ``` 75 | 76 | #### Properties 77 | 78 | - `gem_version` - The version of the `mysql` Rubygem to install into the Chef environment. Defaults to '0.4.5' connector libraries 79 | - `package_version` - The version of the mysql client libraries to install and link against 80 | 81 | #### Actions 82 | 83 | - `:install` - Build and install the gem into the Chef environment 84 | - `:remove` - Delete the gem from the Chef environment 85 | 86 | ### mysql2_chef_gem_mariadb 87 | 88 | To install the mysql2 gem against an installation of mariadb reference the `mysql2_chef_gem_mariadb` resource directly. This resource includes all the same properties of the standard `mysql2_chef_gem` resource. 89 | 90 | ```ruby 91 | mysql2_chef_gem_mariadb 'default' do 92 | action :install 93 | end 94 | ``` 95 | 96 | ## License & Authors 97 | 98 | - Author:: Sean OMeara ([someara@sean.io](mailto:someara@sean.io)) 99 | - Author:: Tim Smith ([tsmith@chef.io](mailto:tsmith@chef.io)) 100 | - Author:: Nicolas Blanc([sinfomicien@gmail.com](mailto:sinfomicien@gmail.com)) 101 | 102 | ``` 103 | Licensed under the Apache License, Version 2.0 (the "License"); 104 | you may not use this file except in compliance with the License. 105 | You may obtain a copy of the License at 106 | 107 | http://www.apache.org/licenses/LICENSE-2.0 108 | 109 | Unless required by applicable law or agreed to in writing, software 110 | distributed under the License is distributed on an "AS IS" BASIS, 111 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 112 | See the License for the specific language governing permissions and 113 | limitations under the License. 114 | ``` 115 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # to a chef-server or supermarket. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | examples/* 55 | Guardfile 56 | Procfile 57 | .kitchen* 58 | .rubocop.yml 59 | spec/* 60 | Rakefile 61 | .travis.yml 62 | .foodcritic 63 | .codeclimate.yml 64 | 65 | # SCM # 66 | ####### 67 | .git 68 | */.git 69 | .gitignore 70 | .gitmodules 71 | .gitconfig 72 | .gitattributes 73 | .svn 74 | */.bzr/* 75 | */.hg/* 76 | */.svn/* 77 | 78 | # Berkshelf # 79 | ############# 80 | Berksfile 81 | Berksfile.lock 82 | cookbooks/* 83 | tmp 84 | 85 | # Policyfile # 86 | ############## 87 | Policyfile.rb 88 | Policyfile.lock.json 89 | 90 | # Cookbooks # 91 | ############# 92 | CONTRIBUTING* 93 | CHANGELOG* 94 | TESTING* 95 | MAINTAINERS.toml 96 | 97 | # Strainer # 98 | ############ 99 | Colanderfile 100 | Strainerfile 101 | .colander 102 | .strainer 103 | 104 | # Vagrant # 105 | ########### 106 | .vagrant 107 | Vagrantfile 108 | -------------------------------------------------------------------------------- /libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | if defined?(ChefSpec) 2 | def install_mysql2_chef_gem(resource_name) 3 | ChefSpec::Matchers::ResourceMatcher.new(:mysql2_chef_gem, :install, resource_name) 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'mysql2_chef_gem' 2 | maintainer 'Nicolas Blanc' 3 | maintainer_email 'sinfomicien@gmail.com' 4 | license 'Apache-2.0' 5 | description 'Provides the mysql2_chef_gem resource' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '2.1.0' 8 | 9 | %w(centos redhat scientific oracle fedora debian ubuntu).each do |platorm| 10 | supports platorm 11 | end 12 | 13 | depends 'build-essential', '>= 2.4.0' 14 | depends 'mysql', '>= 8.2.0' 15 | depends 'mariadb' 16 | 17 | chef_version '>= 12.7' if respond_to?(:chef_version) 18 | source_url 'https://github.com/sinfomicien/mysql2_chef_gem' 19 | issues_url 'https://github.com/sinfomicien/mysql2_chef_gem/issues' 20 | -------------------------------------------------------------------------------- /resources/mysql2_chef_gem_mariadb.rb: -------------------------------------------------------------------------------- 1 | property :mysql2_chef_gem_name, String, name_property: true, required: true 2 | property :gem_version, String, default: '0.4.9' 3 | property :package_version, String 4 | 5 | provides :mysql2_chef_gem_mariadb 6 | 7 | action :install do 8 | recipe_eval do 9 | run_context.include_recipe 'build-essential::default' 10 | end 11 | 12 | # As a recipe: must rely on global node attributes 13 | recipe_eval do 14 | run_context.include_recipe 'mariadb::client' 15 | end 16 | 17 | gem_package 'mysql2' do 18 | gem_binary RbConfig::CONFIG['bindir'] + '/gem' 19 | version new_resource.gem_version 20 | action :install 21 | end 22 | end 23 | 24 | action :remove do 25 | gem_package 'mysql2' do 26 | gem_binary RbConfig::CONFIG['bindir'] + '/gem' 27 | action :remove 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /resources/mysql2_chef_gem_mysql.rb: -------------------------------------------------------------------------------- 1 | property :mysql2_chef_gem_name, String, name_property: true, required: true 2 | property :gem_version, String, default: '0.4.9' 3 | property :package_version, String 4 | 5 | provides :mysql2_chef_gem 6 | provides :mysql2_chef_gem_mysql 7 | 8 | action :install do 9 | include_recipe 'build-essential::default' 10 | 11 | # As a resource: can pass version from calling recipe 12 | mysql_client 'default' do 13 | version new_resource.package_version if new_resource.package_version 14 | action :create 15 | end 16 | 17 | gem_package 'mysql2' do 18 | gem_binary RbConfig::CONFIG['bindir'] + '/gem' 19 | version new_resource.gem_version 20 | action :install 21 | end 22 | end 23 | 24 | action :remove do 25 | gem_package 'mysql2' do 26 | gem_binary RbConfig::CONFIG['bindir'] + '/gem' 27 | action :remove 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /spec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'mysql2_chef_gem_test::default' do 4 | let(:chef_run) do 5 | ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node| 6 | node.default['mysql2_chef_gem']['provider'] = 'mysql' 7 | end.converge('mysql2_chef_gem_test::default') 8 | end 9 | 10 | context 'when using default parameters' do 11 | it 'creates mysql2_chef_gem[default]' do 12 | expect(chef_run).to install_mysql2_chef_gem('default') 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'chefspec' 2 | require 'chefspec/berkshelf' 3 | 4 | RSpec.configure do |config| 5 | config.color = true # Use color in STDOUT 6 | config.formatter = :documentation # Use the specified formatter 7 | config.log_level = :error # Avoid deprecation notice SPAM 8 | end 9 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/mysql2_chef_gem_test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'mysql2_chef_gem_test' 2 | version '0.0.1' 3 | depends 'mysql2_chef_gem' 4 | depends 'yum-mysql-community' 5 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/mysql2_chef_gem_test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | apt_update 'update' 2 | 3 | case node['mysql2_chef_gem']['package_version'] 4 | when '5.5' 5 | include_recipe 'yum-mysql-community::mysql55' 6 | when '5.6' 7 | include_recipe 'yum-mysql-community::mysql56' 8 | when '5.7' 9 | include_recipe 'yum-mysql-community::mysql57' 10 | end 11 | 12 | if node['mysql2_chef_gem']['provider'] == 'mysql' 13 | mysql2_chef_gem 'default' do 14 | package_version node['mysql2_chef_gem']['package_version'] if node['mysql2_chef_gem'] 15 | action :install 16 | end 17 | else 18 | mysql2_chef_gem_mariadb 'default' do 19 | package_version node['mysql2_chef_gem']['package_version'] if node['mysql2_chef_gem'] 20 | action :install 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/integration/client50-mysql/serverspec/assert_functioning_spec.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | describe command('/opt/chef/embedded/bin/gem list mysql2 | grep mysql2') do 6 | its(:exit_status) { should eq 0 } 7 | its(:stdout) { should match("mysql2 (0.4.5)\n") } 8 | end 9 | -------------------------------------------------------------------------------- /test/integration/client51-mysql/serverspec/assert_functioning_spec.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | describe command('/opt/chef/embedded/bin/gem list mysql2 | grep mysql2') do 6 | its(:exit_status) { should eq 0 } 7 | its(:stdout) { should match("mysql2 (0.4.5)\n") } 8 | end 9 | -------------------------------------------------------------------------------- /test/integration/client55-mariadb/serverspec/assert_functioning_spec.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | describe command('/opt/chef/embedded/bin/gem list mysql2 | grep mysql2') do 6 | its(:exit_status) { should eq 0 } 7 | its(:stdout) { should match("mysql2 (0.4.5)\n") } 8 | end 9 | -------------------------------------------------------------------------------- /test/integration/client55-mysql/serverspec/assert_functioning_spec.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | describe command('/opt/chef/embedded/bin/gem list mysql2 | grep mysql2') do 6 | its(:exit_status) { should eq 0 } 7 | its(:stdout) { should match("mysql2 (0.4.5)\n") } 8 | end 9 | -------------------------------------------------------------------------------- /test/integration/client56-mysql/serverspec/assert_functioning_spec.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | describe command('/opt/chef/embedded/bin/gem list mysql2 | grep mysql2') do 6 | its(:exit_status) { should eq 0 } 7 | its(:stdout) { should match("mysql2 (0.4.5)\n") } 8 | end 9 | -------------------------------------------------------------------------------- /test/integration/client57-mysql/serverspec/assert_functioning_spec.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | describe command('/opt/chef/embedded/bin/gem list mysql2 | grep mysql2') do 6 | its(:exit_status) { should eq 0 } 7 | its(:stdout) { should match("mysql2 (0.4.5)\n") } 8 | end 9 | --------------------------------------------------------------------------------