diff --git a/chef/cookbooks/build-essential/attributes/default.rb b/chef/cookbooks/build-essential/attributes/default.rb index 850f65d..70bebcf 100644 --- a/chef/cookbooks/build-essential/attributes/default.rb +++ b/chef/cookbooks/build-essential/attributes/default.rb @@ -17,8 +17,8 @@ # limitations under the License. # -default['build_essential']['compiletime'] = false -#default['build_essential']['compiletime'] = true +#default['build_essential']['compiletime'] = false +default['build_essential']['compiletime'] = true case node['platform_family'] when "mac_os_x" diff --git a/chef/cookbooks/lvm/.gitignore b/chef/cookbooks/lvm/.gitignore new file mode 100644 index 0000000..a90cbbb --- /dev/null +++ b/chef/cookbooks/lvm/.gitignore @@ -0,0 +1,21 @@ +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ +*.tmp +*.bk +*.bkup +.kitchen.local.yml +Berksfile.lock +Gemfile.lock + +.bundle/ +.cache/ +.kitchen/ +.vagrant/ +.vagrant.d/ +bin/ +tmp/ +vendor/ diff --git a/chef/cookbooks/lvm/.kitchen.yml b/chef/cookbooks/lvm/.kitchen.yml new file mode 100644 index 0000000..709f37a --- /dev/null +++ b/chef/cookbooks/lvm/.kitchen.yml @@ -0,0 +1,70 @@ +--- +driver_plugin: vagrant +driver_plugin: digitalocean +driver_config: + digitalocean_client_id: <%= ENV['DIGITAL_OCEAN_CLIENT_ID'] %> + digitalocean_api_key: <%= ENV['DIGITAL_OCEAN_API_KEY'] %> + aws_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> + aws_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> + aws_ssh_key_id: <%= ENV['AWS_KEYPAIR_NAME'] %> + ssh_key: <%= ENV['AWS_PRIVATE_KEY_PATH'] %> + rackspace_username: <%= ENV['RACKSPACE_USERNAME'] %> + rackspace_api_key: <%= ENV['RACKSPACE_API_KEY'] %> + require_chef_omnibus: latest + +platforms: +- name: centos-5.8 + driver_plugin: digitalocean + driver_config: + image_id: 1601 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: centos-6.4 + driver_plugin: digitalocean + driver_config: + image_id: 562354 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: amazon-2013.09 + driver_plugin: ec2 + driver_config: + image_id: ami-3be4bc52 + username: ec2-user + +# - name: fedora-19 +# driver_plugin: digitalocean +# driver_config: +# image_id: 696598 +# flavor_id: 63 +# region_id: 4 +# ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + +- name: ubuntu-1004 + driver_plugin: digitalocean + driver_config: + image_id: 14097 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +- name: ubuntu-1204 + driver_plugin: digitalocean + driver_config: + image_id: 1505447 + flavor_id: 63 + region_id: 4 + ssh_key_ids: <%= ENV['DIGITAL_OCEAN_SSH_KEY_IDS'] %> + run_list: + - recipe[apt] + +suites: + - name: create + run_list: + - recipe[lvm] + - recipe[fake::create] \ No newline at end of file diff --git a/chef/cookbooks/lvm/.rubocop.yml b/chef/cookbooks/lvm/.rubocop.yml new file mode 100644 index 0000000..406195e --- /dev/null +++ b/chef/cookbooks/lvm/.rubocop.yml @@ -0,0 +1,23 @@ +AlignParameters: + Enabled: false + +Encoding: + Enabled: false + +LineLength: + Max: 200 + +HashSyntax: + EnforcedStyle: hash_rockets + +MethodLength: + Max: 30 + +CyclomaticComplexity: + Max: 16 + +ParameterLists: + Enabled: false + +ClassLength: + Max: 117 \ No newline at end of file diff --git a/chef/cookbooks/lvm/.travis.yml b/chef/cookbooks/lvm/.travis.yml new file mode 100644 index 0000000..01655a9 --- /dev/null +++ b/chef/cookbooks/lvm/.travis.yml @@ -0,0 +1,9 @@ +rvm: + - 1.9.3 + - 2.0.0 +before_script: + - bundle exec berks install +script: + - bundle exec foodcritic -f any . + - bundle exec rspec --color --format progress + - bundle exec rubocop diff --git a/chef/cookbooks/lvm/Berksfile b/chef/cookbooks/lvm/Berksfile new file mode 100644 index 0000000..68884e4 --- /dev/null +++ b/chef/cookbooks/lvm/Berksfile @@ -0,0 +1,8 @@ +site :opscode +metadata + +group :integration do + cookbook 'apt', '~> 2.0' + cookbook 'yum', '~> 2.0' + cookbook 'fake', path: 'test/fixtures/cookbooks/fake' +end diff --git a/chef/cookbooks/lvm/CHANGELOG.md b/chef/cookbooks/lvm/CHANGELOG.md new file mode 100644 index 0000000..8a6481a --- /dev/null +++ b/chef/cookbooks/lvm/CHANGELOG.md @@ -0,0 +1,63 @@ +lvm Cookbook CHANGELOG +====================== +This file is used to list changes made in each version of the lvm cookbook. + + +v1.0.4 (2013-12-28) +------------------- +### Bug +- **[COOK-3987](https://tickets.opscode.com/browse/COOK-3987)** - Volumes are created with the wrong # of extents. Size = '2%VG' is treated as a size of 2 extents. + + +v1.0.2 +------ +### Bug +- **[COOK-3935](https://tickets.opscode.com/browse/COOK-3935)** - fix minor typo +- Fixing up style +- Updating test harness + + +v1.0.0 +------ +### Improvement +- **[COOK-3357](https://tickets.opscode.com/browse/COOK-3357)** - Complete refactor into a heavy-weight provider with tests + +v0.8.12 +------- +### Improvement +- **[COOK-2991](https://tickets.opscode.com/browse/COOK-2991)** - Add SLES support + +### Bug +- **[COOK-2348](https://tickets.opscode.com/browse/COOK-2348)** - Fix `lvm_logical_volume` when `mount_point` parameter is a String + +v0.8.10 +------- +### Bug +- [COOK-3031]: `ruby_block` to create logical volume is improperly named, causing collisions + +v0.8.8 +------ +- [COOK-2283] - lvm version mismatch on fresh amazon linux install +- [COOK-2733] - Fix invalid only_if command in lvm cookbook +- [COOK-2822] - install, don't upgrade, lvm2 package + +v0.8.6 +------ +- [COOK-2348] - lvm `logical_volume` doesn't work with `mount_point` parameter as String + +v0.8.4 +------ +- [COOK-1977] - Typo "stripesize" in LVM cookbook +- [COOK-1994] - Cannot create a logical volume if fstype is not given + +v0.8.2 +------ +- [COOK-1857] - `lvm_logical_volume` resource callback conflicts with code in provider. + +v0.8.0 +------ +- Added providers for managing the creation of LVM physical volumes, volume groups, and logical volumes. + +v0.7.1 +------ +- Current public release diff --git a/chef/cookbooks/lvm/CONTRIBUTING.md b/chef/cookbooks/lvm/CONTRIBUTING.md new file mode 100644 index 0000000..3a99897 --- /dev/null +++ b/chef/cookbooks/lvm/CONTRIBUTING.md @@ -0,0 +1,257 @@ +# Contributing to Opscode Cookbooks + +We are glad you want to contribute to Opscode Cookbooks! The first +step is the desire to improve the project. + +You can find the answers to additional frequently asked questions +[on the wiki](http://wiki.opscode.com/display/chef/How+to+Contribute). + +You can find additional information about +[contributing to cookbooks](http://wiki.opscode.com/display/chef/How+to+Contribute+to+Opscode+Cookbooks) +on the wiki as well. + +## Quick-contribute + +* Create an account on our [bug tracker](http://tickets.opscode.com) +* Sign our contributor agreement (CLA) +[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L) +(keep reading if you're contributing on behalf of your employer) +* Create a ticket for your change on the + [bug tracker](http://tickets.opscode.com) +* Link to your patch as a rebased git branch or pull request from the + ticket +* Resolve the ticket as fixed + +We regularly review contributions and will get back to you if we have +any suggestions or concerns. + +## The Apache License and the CLA/CCLA + +Licensing is very important to open source projects, it helps ensure +the software continues to be available under the terms that the author +desired. Chef uses the Apache 2.0 license to strike a balance between +open contribution and allowing you to use the software however you +would like to. + +The license tells you what rights you have that are provided by the +copyright holder. It is important that the contributor fully +understands what rights they are licensing and agrees to them. +Sometimes the copyright holder isn't the contributor, most often when +the contributor is doing work for a company. + +To make a good faith effort to ensure these criteria are met, Opscode +requires a Contributor License Agreement (CLA) or a Corporate +Contributor License Agreement (CCLA) for all contributions. This is +without exception due to some matters not being related to copyright +and to avoid having to continually check with our lawyers about small +patches. + +It only takes a few minutes to complete a CLA, and you retain the +copyright to your contribution. + +You can complete our contributor agreement (CLA) +[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L). +If you're contributing on behalf of your employer, have your employer +fill out our +[Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856) +instead. + +## Ticket Tracker (JIRA) + +The [ticket tracker](http://tickets.opscode.com) is the most important +documentation for the code base. It provides significant historical +information, such as: + +* Which release a bug fix is included in +* Discussion regarding the design and merits of features +* Error output to aid in finding similar bugs + +Each ticket should aim to fix one bug or add one feature. + +## Using git + +You can get a quick copy of the repository for this cookbook by +running `git clone +git://github.com/opscode-coobkooks/COOKBOOKNAME.git`. + +For collaboration purposes, it is best if you create a Github account +and fork the repository to your own account. Once you do this you will +be able to push your changes to your Github repository for others to +see and use. + +If you have another repository in your GitHub account named the same +as the cookbook, we suggest you suffix the repository with -cookbook. + +### Branches and Commits + +You should submit your patch as a git branch named after the ticket, +such as COOK-1337. This is called a _topic branch_ and allows users to +associate a branch of code with the ticket. + +It is a best practice to have your commit message have a _summary +line_ that includes the ticket number, followed by an empty line and +then a brief description of the commit. This also helps other +contributors understand the purpose of changes to the code. + + [COOK-1757] - platform_family and style + + * use platform_family for platform checking + * update notifies syntax to "resource_type[resource_name]" instead of + resources() lookup + * COOK-692 - delete config files dropped off by packages in conf.d + * dropped debian 4 support because all other platforms have the same + values, and it is older than "old stable" debian release + +Remember that not all users use Chef in the same way or on the same +operating systems as you, so it is helpful to be clear about your use +case and change so they can understand it even when it doesn't apply +to them. + +### Github and Pull Requests + +All of Opscode's open source cookbook projects are available on +[Github](http://www.github.com/opscode-cookbooks). + +We don't require you to use Github, and we will even take patch diffs +attached to tickets on the tracker. However Github has a lot of +convenient features, such as being able to see a diff of changes +between a pull request and the main repository quickly without +downloading the branch. + +If you do choose to use a pull request, please provide a link to the +pull request from the ticket __and__ a link to the ticket from the +pull request. Because pull requests only have two states, open and +closed, we can't easily filter pull requests that are waiting for a +reply from the author for various reasons. + +### More information + +Additional help with git is available on the +[Working with Git](http://wiki.opscode.com/display/chef/Working+with+Git) +wiki page. + +## Functional and Unit Tests + +This cookbook is set up to run tests under +[Opscode's test-kitchen](https://github.com/opscode/test-kitchen). It +uses minitest-chef to run integration tests after the node has been +converged to verify that the state of the node. + +Test kitchen should run completely without exception using the default +[baseboxes provided by Opscode](https://github.com/opscode/bento). +Because Test Kitchen creates VirtualBox machines and runs through +every configuration in the Kitchenfile, it may take some time for +these tests to complete. + +If your changes are only for a specific recipe, run only its +configuration with Test Kitchen. If you are adding a new recipe, or +other functionality such as a LWRP or definition, please add +appropriate tests and ensure they run with Test Kitchen. + +If any don't pass, investigate them before submitting your patch. + +Any new feature should have unit tests included with the patch with +good code coverage to help protect it from future changes. Similarly, +patches that fix a bug or regression should have a _regression test_. +Simply put, this is a test that would fail without your patch but +passes with it. The goal is to ensure this bug doesn't regress in the +future. Consider a regular expression that doesn't match a certain +pattern that it should, so you provide a patch and a test to ensure +that the part of the code that uses this regular expression works as +expected. Later another contributor may modify this regular expression +in a way that breaks your use cases. The test you wrote will fail, +signalling to them to research your ticket and use case and accounting +for it. + +If you need help writing tests, please ask on the Chef Developer's +mailing list, or the #chef-hacking IRC channel. + +## Code Review + +Opscode regularly reviews code contributions and provides suggestions +for improvement in the code itself or the implementation. + +We find contributions by searching the ticket tracker for _resolved_ +tickets with a status of _fixed_. If we have feedback we will reopen +the ticket and you should resolve it again when you've made the +changes or have a response to our feedback. When we believe the patch +is ready to be merged, we will tag the _Code Reviewed_ field with +_Reviewed_. + +Depending on the project, these tickets are then merged within a week +or two, depending on the current release cycle. + +## Release Cycle + +The versioning for Opscode Cookbook projects is X.Y.Z. + +* X is a major release, which may not be fully compatible with prior + major releases +* Y is a minor release, which adds both new features and bug fixes +* Z is a patch release, which adds just bug fixes + +A released version of a cookbook will end in an even number, e.g. +"1.2.4" or "0.8.0". When development for the next version of the +cookbook begins, the "Z" patch number is incremented to the next odd +number, however the next release of the cookbook may be a major or +minor incrementing version. + +Releases of Opscode's cookbooks are usually announced on the Chef user +mailing list. Releases of several cookbooks may be batched together +and announced on the [Opscode Blog](http://www.opscode.com/blog). + +## Working with the community + +These resources will help you learn more about Chef and connect to +other members of the Chef community: + +* [chef](http://lists.opscode.com/sympa/info/chef) and + [chef-dev](http://lists.opscode.com/sympa/info/chef-dev) mailing + lists +* #chef and #chef-hacking IRC channels on irc.freenode.net +* [Community Cookbook site](http://community.opscode.com) +* [Chef wiki](http://wiki.opscode.com/display/chef) +* Opscode Chef [product page](http://www.opscode.com/chef) + + +## Cookbook Contribution Do's and Don't's + +Please do include tests for your contribution. If you need help, ask +on the +[chef-dev mailing list](http://lists.opscode.com/sympa/info/chef-dev) +or the +[#chef-hacking IRC channel](http://community.opscode.com/chat/chef-hacking). +Not all platforms that a cookbook supports may be supported by Test +Kitchen. Please provide evidence of testing your contribution if it +isn't trivial so we don't have to duplicate effort in testing. Chef +10.14+ "doc" formatted output is sufficient. + +Please do indicate new platform (families) or platform versions in the +commit message, and update the relevant ticket. + +If a contribution adds new platforms or platform versions, indicate +such in the body of the commit message(s), and update the relevant +COOK ticket. When writing commit messages, it is helpful for others if +you indicate the COOK ticket. For example: + + git commit -m '[COOK-1041] - Updated pool resource to correctly + delete.' + +Please do use [foodcritic](http://acrmp.github.com/foodcritic) to +lint-check the cookbook. Except FC007, it should pass all correctness +rules. FC007 is okay as long as the dependent cookbooks are *required* +for the default behavior of the cookbook, such as to support an +uncommon platform, secondary recipe, etc. + +Please do ensure that your changes do not break or modify behavior for +other platforms supported by the cookbook. For example if your changes +are for Debian, make sure that they do not break on CentOS. + +Please do not modify the version number in the metadata.rb, Opscode +will select the appropriate version based on the release cycle +information above. + +Please do not update the CHANGELOG.md for a new version. Not all +changes to a cookbook may be merged and released in the same versions. +Opscode will update the CHANGELOG.md when releasing a new version of +the cookbook. diff --git a/chef/cookbooks/lvm/Gemfile b/chef/cookbooks/lvm/Gemfile new file mode 100644 index 0000000..f465c78 --- /dev/null +++ b/chef/cookbooks/lvm/Gemfile @@ -0,0 +1,13 @@ +source 'https://rubygems.org' + +gem 'berkshelf', '~> 2.0' +gem 'chefspec', '~> 3.0' +gem 'foodcritic', '~> 3.0' +gem 'rubocop' + +group :integration do + gem 'test-kitchen', '~> 1.0' + gem 'kitchen-vagrant', '~> 0.11' + gem 'kitchen-digitalocean' + gem 'kitchen-ec2' +end diff --git a/chef/cookbooks/lvm/LICENSE b/chef/cookbooks/lvm/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/chef/cookbooks/lvm/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/chef/cookbooks/lvm/README.md b/chef/cookbooks/lvm/README.md new file mode 100644 index 0000000..6f6ab33 --- /dev/null +++ b/chef/cookbooks/lvm/README.md @@ -0,0 +1,345 @@ +lvm Cookbook +============ +[![Build Status](https://secure.travis-ci.org/opscode-cookbooks/lvm.png?branch=master)](http://travis-ci.org/opscode-cookbooks/lvm) + +Installs lvm2 package and includes resources for managing LVM. The default recipe simply installs LVM and the supporting Ruby gem. The cookbook includes providers for managing LVMs. + + +Requirements +------------ +- Chef 10 or higher + + +Resources/Providers +------------------- +#### `lvm_physical_volume` +Manages LVM physical volumes. + +##### Actions + + + + + + + + + +
ActionDescription
:create(default) Creates a new physical volume
+ +##### Parameters + + + + + + + + + + + + + +
ParameterDescriptionExampleDefault
name(required) The device to create the new physical volume on'/dev/sda'
+ +##### Examples +```ruby +lvm_physical_volume '/dev/sda' +``` + +--- + + +#### `lvm_logical_volume` +Manages LVM logical volumes. + +##### Actions + + + + + + + + + +
ActionDescription
:create(default) Creates a new logical volume
+ +##### Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionExampleDefault
name(name attribute) Name of the logical volumebacon
group(required) Volume group in which to create the new volume (not required if the volume is declared inside of an `lvm_volume_group` block)bits
size(required) Size of the volume. +
    +
  • It can be the size of the volume with units (k, K, m, M, g, G, t, T)
  • +
  • It can be specified as the percentage of the size of the volume group
  • +
+
+
    +
  • 10G
  • +
  • 25%VG
  • +
+
filesystemThe format for the file system'ext4'
mount_point + Either a String containing the path to the mount point, or a Hash with the following keys: +
    +
  • location - (required) the directory to mount the volume on
  • +
  • options - the mount options for the volume
  • +
  • dump - the dump field for the fstab entry
  • +
  • pass - the pass field for the fstab entry
  • +
+
'/var/my/mount'
physical_volumesArray of physical volumes that the volume will be + restricted to['/dev/sda', '/dev/sdb']
stripesNumber of stripes for the volume5
stripe_sizeNumber of kilobytes per stripe segment (must be a power of 2 less than or equal to the physical extent size for the volume group)24
mirrorsNumber of mirrors for the volume5
contiguousWhether or not volume should use the contiguous allocation + policytruefalse
readaheadThe readahead sector count for the volume (can be a value + between 2 and 120, 'auto', or 'none')'auto'
+ +##### Examples + +```ruby +lvm_logical_volume 'home' do + group 'vg00' + size '25%VG' + filesystem 'ext4' + mount_point '/home' + stripes 3 + mirrors 2 +end +``` + +--- + + +#### `lvm_volume_group` +Manages LVM volume groups. + +##### Actions + + + + + + + + + +
ActionDescription
:create(default) Creates a new volume group
+ +##### Parameters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionExampleDefault
name(required) Name of the volume group'bacon'
physical_volumes(required) The device or list of devices to use as physical volumes (if they haven't already been initialized as physical volumes, they will be initialized automatically)['/dev/sda', '/dev/sdb']
physical_extent_sizeThe physical extent size for the volume group
logical_volumeShortcut for creating a new `lvm_logical_volume` definition (the logical volumes will be created in the order they are declared)
+ +##### Examples +```ruby +lvm_volume_group 'vg00' do + physical_volumes ['/dev/sda', '/dev/sdb', '/dev/sdc'] + + logical_volume 'logs' do + size '1G' + filesystem 'xfs' + mount_point location: '/var/log', options: 'noatime,nodiratime' + stripes 3 + end + + logical_volume 'home' do + size '25%VG' + filesystem 'ext4' + mount_point '/home' + stripes 3 + mirrors 2 + end +end +``` + + +Usage +----- +If you're using [Berkshelf](http://berkshelf.com), just add this cookbook to your `Berksfile`: + +```ruby +cookbook 'lvm' +``` + +You can also install it from the community site: + +```ruby +knife cookbook site install lvm +``` + +Include the default recipe in your run list on a node, in a role, or in another recipe: + +```ruby +run_list( + 'recipe[lvm::default]' +) +``` + +Depend on `lvm` in any cookbook that uses its Resources/Providers: + +```ruby +# other_cookbook/metadata.rb +depends 'lvm' +``` + + +Caveats +------- +This cookbook depends on the [di-ruby-lvm](https://github.com/DrillingInfo/di-ruby-lvm) and [di-ruby-lvm-attrib](https://github.com/DrillingInfo/di-ruby-lvm-attrib) gems. The di-ruby-lvm-attrib gem in particular is a common cause of failures when using the providers. If you get a failure with an error message similar to + +```text +No such file or directory - /opt/chef/.../di-ruby-lvm-attrib-0.0.3/lib/lvm/attributes/2.02.86(2)/lvs.yaml +``` + +then you are running a version of lvm that the gems do not support. However, getting support added is usually pretty easy. Just follow the instructions on "Adding Attributes" in the [di-ruby-lvm-attrib README](https://github.com/DrillingInfo/di-ruby-lvm-attrib). + + +Development +----------- +This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]]. + +1. Clone this repository from GitHub: + + $ git clone git@github.com:opscode-cookbooks/lvm.git + +2. Create a git branch + + $ git checkout -b my_bug_fix + +3. Install dependencies: + + $ bundle install + +4. Make your changes/patches/fixes, committing appropiately +5. **Write tests** +6. Run the tests: + - `bundle exec foodcritic -f any .` + - `bundle exec rspec` + - `bundle exec rubocop` + - `bundle exec kitchen test` + + In detail: + - Foodcritic will catch any Chef-specific style errors + - RSpec will run the unit tests + - Rubocop will check for Ruby-specific style errors + - Test Kitchen will run and converge the recipes + + +License and Authors +------------------- +- Author:: Joshua Timberman +- Author:: Greg Symons + +```text +Copyright:: 2011, Opscode, Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` diff --git a/chef/cookbooks/lvm/TESTING.md b/chef/cookbooks/lvm/TESTING.md new file mode 100644 index 0000000..b4102e3 --- /dev/null +++ b/chef/cookbooks/lvm/TESTING.md @@ -0,0 +1,53 @@ +This cookbook uses a variety of testing components: + +- Unit tests: [ChefSpec](https://github.com/acrmp/chefspec) +- Integration tests: [Test Kitchen](https://github.com/opscode/test-kitchen) +- Chef Style lints: [Foodcritic](https://github.com/acrmp/foodcritic) +- Ruby Style lints: [Rubocop](https://github.com/bbatsov/rubocop) + + +Prerequisites +------------- +To develop on this cookbook, you must have a sane Ruby 1.9+ environment. Given the nature of this installation process (and it's variance across multiple operating systems), we will leave this installation process to the user. + +You must also have `bundler` installed: + + $ gem install bundler + +You must also have Vagrant and VirtualBox installed: + +- [Vagrant](https://vagrantup.com) +- [VirtualBox](https://virtualbox.org) + +Once installed, you must install the `vagrant-berkshelf` plugin: + + $ vagrant plugin install vagrant-berkshelf + + +Development +----------- +1. Clone the git repository from GitHub: + + $ git clone git@github.com:opscode-cookbooks/COOKBOOK.git + +2. Install the dependencies using bundler: + + $ bundle install + +3. Create a branch for your changes: + + $ git checkout -b my_bug_fix + +4. Make any changes +5. Write tests to support those changes. It is highly recommended you write both unit and integration tests. +6. Run the tests: + - `bundle exec rspec` + - `bundle exec foodcritic .` + - `bundle exec rubocop` + - `bundle exec kitchen test` + +7. Assuming the tests pass, open a Pull Request on GitHub +8. Open a JIRA ticket for this compontent, linking the JIRA ticket to the Pull Request and visa versa. +9. Mark the JIRA ticket as "Fix Provided" + +For more information, see [Opscode's Contribution Guidelines](https://wiki.opscode.com/display/chef/How+to+Contribute). diff --git a/chef/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb b/chef/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb new file mode 100644 index 0000000..b55ec60 --- /dev/null +++ b/chef/cookbooks/lvm/libraries/provider_lvm_logical_volume.rb @@ -0,0 +1,157 @@ +# +# Cookbook Name:: lvm +# Library:: provider_lvm_logical_volume +# +# Copyright 2009-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'chef/mixin/shell_out' + +class Chef + class Provider + # The provider for lvm_logical_volume resource + # + class LvmLogicalVolume < Chef::Provider + include Chef::Mixin::ShellOut + + # Loads the current resource attributes + # + # @return [Chef::Resource::LvmLogicalVolume] the lvm_logical_volume resource + # + def load_current_resource + @current_resource ||= Chef::Resource::LvmLogicalVolume.new(@new_resource.name) + @current_resource + end + + # The create action + # + def action_create # rubocop:disable MethodLength + require 'lvm' + lvm = LVM::LVM.new + name = new_resource.name + group = new_resource.group + fs_type = new_resource.filesystem + device_name = "/dev/mapper/#{to_dm_name(group)}-#{to_dm_name(name)}" + + vg = lvm.volume_groups[new_resource.group] + # Create the logical volume + if vg.nil? || vg.logical_volumes.select { |lv| lv.name == name }.empty? + device_name = "/dev/mapper/#{to_dm_name(group)}-#{to_dm_name(name)}" + size = + case new_resource.size + when /\d+[kKmMgGtT]/ + "--size #{new_resource.size}" + when /(\d{1,2}|100)%(FREE|VG|PVS)/ + "--extents #{new_resource.size}" + when /(\d+)/ + "--size #{$1}" # rubocop:disable PerlBackrefs + end + + stripes = new_resource.stripes ? "--stripes #{new_resource.stripes}" : '' + stripe_size = new_resource.stripe_size ? "--stripesize #{new_resource.stripe_size}" : '' + mirrors = new_resource.mirrors ? "--mirrors #{new_resource.mirrors}" : '' + contiguous = new_resource.contiguous ? '--contiguous y' : '' + readahead = new_resource.readahead ? "--readahead #{new_resource.readahead}" : '' + physical_volumes = [new_resource.physical_volumes].flatten.join ' ' if new_resource.physical_volumes + + command = "lvcreate #{size} #{stripes} #{stripe_size} #{mirrors} #{contiguous} #{readahead} --name #{name} #{group} #{physical_volumes}" + Chef::Log.debug "Executing lvm command: '#{command}'" + output = lvm.raw(command) + Chef::Log.debug "Command output: '#{output}'" + new_resource.updated_by_last_action(true) + else + Chef::Log.info "Logical volume '#{name}' already exists. Not creating..." + end + + # If file system is specified, format the logical volume + if fs_type.nil? + Chef::Log.info 'File system type is not set. Not formatting...' + elsif device_formatted?(device_name, fs_type) + Chef::Log.info "Volume '#{device_name}' is already formatted. Not formatting..." + else + shell_out!("yes | mkfs -t #{fs_type} #{device_name}") + new_resource.updated_by_last_action(true) + end + + # If the mount point is specified, mount the logical volume + if new_resource.mount_point + if new_resource.mount_point.is_a?(String) + mount_spec = { :location => new_resource.mount_point } + else + mount_spec = new_resource.mount_point + end + + # Create the mount point + dir_resource = directory mount_spec[:location] do + mode 0777 + owner 'root' + group 'root' + recursive true + action :nothing + end + dir_resource.run_action(:create) + # Mark the resource as updated if the directory resource is updated + new_resource.updated_by_last_action(dir_resource.updated?) + + # Mount the logical volume + mount_resource = mount mount_spec[:location] do + options mount_spec[:options] + dump mount_spec[:dump] + pass mount_spec[:pass] + device device_name + fstype fs_type + action :nothing + end + mount_resource.run_action(:mount) + mount_resource.run_action(:enable) + # Mark the resource as updated if the mount resource is updated + new_resource.updated_by_last_action(mount_resource.updated?) + end + end + + private + + # Converts the device name to the dm name format + # + # The device mapper will double any hyphens found in a volume group or + # logical volume name so that it can properly locate the separator between + # the volume group and the logical volume in the device name. + # + # @param name [String] the name to map + # + # @return [String] the mapped dm name + # + def to_dm_name(name) + name.gsub(/-/, '--') + end + + # Checks if the device is formatted with the given file system type + # + # @param device_name [String] the device name + # @param fs_type [String] the file system type + # + # @return [Boolean] whether the device is formatted with the given file + # system type or not + # + def device_formatted?(device_name, fs_type) + Chef::Log.debug "Checking to see if #{device_name} is formatted..." + # Do not raise when there is an error in running the blkid command. If the exitstatus is not 0, + # the device is perhaps not formatted. + blkid = shell_out("blkid -o value -s TYPE #{device_name}") + blkid.exitstatus == 0 && blkid.stdout.strip == fs_type.strip + end + end + end +end diff --git a/chef/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb b/chef/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb new file mode 100644 index 0000000..520a973 --- /dev/null +++ b/chef/cookbooks/lvm/libraries/provider_lvm_physical_volume.rb @@ -0,0 +1,51 @@ +# +# Cookbook Name:: lvm +# Library:: provider_lvm_physical_volume +# +# Copyright 2009-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'chef/provider' + +class Chef + class Provider + # The provider for lvm_physical_volume resource + # + class LvmPhysicalVolume < Chef::Provider + # Loads the current resource attributes + # + # @return [Chef::Resource::LvmPhysicalVolume] the lvm_physical_volume resource + # + def load_current_resource + @current_resource ||= Chef::Resource::LvmPhysicalVolume.new(@new_resource.name) + @current_resource + end + + # The create action + # + def action_create + require 'lvm' + lvm = LVM::LVM.new + if lvm.physical_volumes[new_resource.name].nil? + Chef::Log.info "Creating physical volume '#{new_resource.name}'" + lvm.raw "pvcreate #{new_resource.name}" + new_resource.updated_by_last_action(true) + else + Chef::Log.info "Physical volume '#{new_resource.name}' found. Not creating..." + end + end + end + end +end diff --git a/chef/cookbooks/lvm/libraries/provider_lvm_volume_group.rb b/chef/cookbooks/lvm/libraries/provider_lvm_volume_group.rb new file mode 100644 index 0000000..ba7ef83 --- /dev/null +++ b/chef/cookbooks/lvm/libraries/provider_lvm_volume_group.rb @@ -0,0 +1,106 @@ +# +# Cookbook Name:: lvm +# Library:: provider_lvm_volume_group +# +# Copyright 2009-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'chef/mixin/shell_out' + +class Chef + class Provider + # The provider for lvm_volume_group resource + # + class LvmVolumeGroup < Chef::Provider + include Chef::Mixin::ShellOut + + # Loads the current resource attributes + # + # @return [Chef::Resource::LvmVolumeGroup] the lvm_volume_group resource + # + def load_current_resource + @current_resource ||= Chef::Resource::LvmVolumeGroup.new(@new_resource.name) + @current_resource + end + + # The create action + # + def action_create + require 'lvm' + name = new_resource.name + physical_volume_list = [new_resource.physical_volumes].flatten + + # Make sure any pvs are not being used as filesystems (e.g. ephemeral0 on + # AWS is always mounted at /mnt as an ext3 fs). + # + physical_volume_list.select { |pv| ::File.exist?(pv) }.each do |pv| + # If the device is mounted, the mount point will be returned else nil will be returned. + # mount_point is required by the mount resource for umount and disable actions. + # + mount_point = get_mount_point(pv) + unless mount_point.nil? + mount_resource = mount mount_point do + device pv + action :nothing + end + mount_resource.run_action(:umount) + mount_resource.run_action(:disable) + end + end + + lvm = LVM::LVM.new + # Create the volume group + if lvm.volume_groups[name] + Chef::Log.info "Volume group '#{name}' already exists. Not creating..." + else + physical_volumes = physical_volume_list.join(' ') + physical_extent_size = new_resource.physical_extent_size ? "-s #{new_resource.physical_extent_size}" : '' + command = "vgcreate #{name} #{physical_extent_size} #{physical_volumes}" + + Chef::Log.debug "Executing lvm command: '#{command}'" + output = lvm.raw command + Chef::Log.debug "Command output: '#{output}'" + # Create the logical volumes specified as sub-resources + new_resource.logical_volumes.each do |lv| + lv.group new_resource.name + lv.run_action :create + end + new_resource.updated_by_last_action(true) + end + end + + private + + # Obtains the mount point of a device and returns nil if the device is not mounted + # + # @param device [String] the physical device + # + # @return [String] the mount point of the device if mounted and nil otherwise + # + def get_mount_point(device) + mount_point = nil + shell_out!('mount').stdout.each_line do |line| + matched = line.match(/#{Regexp.escape(device)}\s+on\s+(.*)\s+type.*/) + # If a match is found in the mount, obtain the mount point and return it + unless matched.nil? + mount_point = matched[1] + break + end + end + mount_point + end + end + end +end diff --git a/chef/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb b/chef/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb new file mode 100644 index 0000000..3acb2a8 --- /dev/null +++ b/chef/cookbooks/lvm/libraries/resource_lvm_logical_volume.rb @@ -0,0 +1,231 @@ +# +# Cookbook Name:: lvm +# Library:: resource_lvm_logical_volume +# +# Copyright 2009-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'chef/resource' + +class Chef + class Resource + # The lvm_logical_volume resource + # + class LvmLogicalVolume < Chef::Resource + # Initializes the lvm_logical_volume resource + # + # @param name [String] name of the resource + # @param run_context [Chef::RunContext] the run context of chef run + # + # @return [Chef::Resource::LvmLogicalVolume] the lvm_logical_volume resource + # + def initialize(name, run_context = nil) + super + @resource_name = :lvm_logical_volume + @action = :create + @allowed_actions.push :create + @provider = Chef::Provider::LvmLogicalVolume + end + + # Attribute: name - name of the logical volume + # + # @param arg [String] the name of the logical volume + # + # @return [String] the name of the logical volume + # + def name(arg = nil) + set_or_return( + :name, + arg, + :kind_of => String, + :regex => /[\w+.-]+/, + :name_attribute => true, + :required => true, + :callbacks => { + "cannot be '.', '..', 'snapshot', or 'pvmove'" => proc do |value| + !(value == '.' || value == '..' || value == 'snapshot' || value == 'pvmove') + end, + "cannot contain the strings '_mlog' or '_mimage'" => proc do |value| + !value.match(/.*(_mlog|_mimage).*/) + end + } + ) + end + + # Attribute: group - the volume group the logical volume belongs to + # + # @param arg [String] the volume group name + # + # @return [String] the volume group name + # + def group(arg = nil) + set_or_return( + :group, + arg, + :kind_of => String + ) + end + + # Attribute: size - size of the logical volume + # + # @param arg [String] the size of the logical volume + # + # @return [String] the size of the logical volume + # + def size(arg = nil) + set_or_return( + :size, + arg, + :kind_of => String, + :regex => /^(\d+[kKmMgGtTpPeE]|(\d{1,2}|100)%(FREE|VG|PVS)|\d+)$/, + :required => true + ) + end + + # Attribute: filesystem - the file system type + # + # @param arg [String] the file system type + # + # @return [String] the file system type + # + def filesystem(arg = nil) + set_or_return( + :filesystem, + arg, + :kind_of => String + ) + end + + # Attribute: mount_point - mount point for the logical volume + # + # @param arg [String] the mount point + # + # @return [String] the mount point + # + def mount_point(arg = nil) + set_or_return( + :mount_point, + arg, + :kind_of => [String, Hash], + :callbacks => { + ': location is required!' => proc do |value| + value.class == String || (value[:location] && !value[:location].empty?) + end, + ': location must be an absolute path!' => proc do |value| + # this can be a string or a hash, so attempt to match either for + # the regex + matches = value =~ /^\/[^\0]*/ || value[:location] =~ /^\/[^\0]*/ + !matches.nil? + end + } + ) + end + + # Attribute: physical_volumes - list of physical volumes to be used for creation + # + # @param arg [String, Array] - list of physical devices + # + # @return [String, Array] - list of physical devices + # + def physical_volumes(arg = nil) + set_or_return( + :physical_volumes, + arg, + :kind_of => [String, Array] + ) + end + + # Attribute: stripes - number of stripes for the volume + # + # @param arg [String] number of stripes + # + # @return [String] number of stripes + # + def stripes(arg = nil) + set_or_return( + :stripes, + arg, + :kind_of => Integer, + :callbacks => { + 'must be greater than 0' => proc { |value| value > 0 } + } + ) + end + + # Attribute: stripe_size - the stripe size + # + # @param arg [String] the stripe size + # + # @return [String] the stripe size + # + def stripe_size(arg = nil) + set_or_return( + :stripe_size, + arg, + :kind_of => Integer, + :callbacks => { + 'must be a power of 2' => proc { |value| Math.log2(value) % 1 == 0 } + } + ) + end + + # Attribute: mirrors - number of mirrors for the volume + # + # @param arg [Integer] number of mirrors + # + # @return [Integer] number of mirrors + # + def mirrors(arg = nil) + set_or_return( + :mirrors, + arg, + :kind_of => Integer, + :callbacks => { + 'must be greater than 0' => proc { |value| value > 0 } + } + ) + end + + # Attribute: contiguous - whether to use contiguous allocation policy + # + # @param arg [Boolean] whether to use contiguous allocation policy + # + # @return [Boolean] the contiguous allocation policy setting + # + def contiguous(arg = nil) + set_or_return( + :contiguous, + arg, + :kind_of => [TrueClass, FalseClass] + ) + end + + # Attribute: readahead - the read ahead sector count of the logical volume + # + # @param arg [Integer, String] the read ahead sector count + # + # @return [Integer, String] the read ahead sector count + # + def readahead(arg = nil) + set_or_return( + :readahead, + arg, + :kind_of => [Integer, String], + :equal_to => [2..120, 'auto', 'none'].flatten! + ) + end + end + end +end diff --git a/chef/cookbooks/lvm/libraries/resource_lvm_physical_volume.rb b/chef/cookbooks/lvm/libraries/resource_lvm_physical_volume.rb new file mode 100644 index 0000000..b42f0b9 --- /dev/null +++ b/chef/cookbooks/lvm/libraries/resource_lvm_physical_volume.rb @@ -0,0 +1,59 @@ +# +# Cookbook Name:: lvm +# Library:: resource_lvm_physical_volume +# +# Copyright 2009-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'chef/resource' + +class Chef + class Resource + # The lvm_physical_volume resource + # + class LvmPhysicalVolume < Chef::Resource + # Initializes lvm_physical_volume resource + # + # @param name [String] name of the resource + # @param run_context [Chef::RunContext] the run context of chef run + # + # @return [Chef::Resource::LvmPhysicalVolume] the lvm_physical_volume resource + # + def initialize(name, run_context = nil) + super + @resource_name = :lvm_physical_volume + @action = :create + @allowed_actions.push :create + @provider = Chef::Provider::LvmPhysicalVolume + end + + # Attribute: name - the physical device + # + # @param arg [String] the physical device + # + # @return [String] the physical device + # + def name(arg = nil) + set_or_return( + :name, + arg, + :kind_of => String, + :name_attribute => true, + :required => true + ) + end + end + end +end diff --git a/chef/cookbooks/lvm/libraries/resource_lvm_volume_group.rb b/chef/cookbooks/lvm/libraries/resource_lvm_volume_group.rb new file mode 100644 index 0000000..4905bab --- /dev/null +++ b/chef/cookbooks/lvm/libraries/resource_lvm_volume_group.rb @@ -0,0 +1,116 @@ +# +# Cookbook Name:: lvm +# Library:: resource_lvm_volume_group +# +# Copyright 2009-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'chef/resource' + +class Chef + class Resource + # The lvm_volume_group resource + # + class LvmVolumeGroup < Chef::Resource + include Chef::DSL::Recipe + + # Logical volumes to be created in the volume group + attr_reader :logical_volumes + + # Initializes the lvm_volume_group resource + # + # @param name [String] name of the resource + # @param run_context [Chef::RunContext] the run context of chef run + # + # @return [Chef::Resource::LvmVolumeGroup] the lvm_volume_group resource + # + def initialize(name, run_context = nil) + super + @resource_name = :lvm_volume_group + @action = :create + @allowed_actions.push :create + @logical_volumes = [] + @provider = Chef::Provider::LvmVolumeGroup + end + + # Attribute: name - name of the volume group + # + # @param arg [String] the name of the volume group + # + # @return [String] the name of the volume group + # + def name(arg = nil) + set_or_return( + :name, + arg, + :kind_of => String, + :name_attribute => true, + :regex => /[\w+.-]+/, + :required => true, + :callbacks => { + "cannot be '.' or '..'" => proc do |value| + !(value == '.' || value == '..') + end + } + ) + end + + # Attribute: physical_volumes - list of physical devices this volume group should be restricted to + # + # @param arg [Array, String] list of physical devices + # + # @return [String] list of physical devices + # + def physical_volumes(arg = nil) + set_or_return( + :physical_volumes, + arg, + :kind_of => [Array, String], + :required => true + ) + end + + # Attribute: physical_extent_size - the physical_extent_size + # + # @param arg [String] the physical extent size + # + # @return [String] the physical extent size + # + def physical_extent_size(arg = nil) + set_or_return( + :physical_extent_size, + arg, + :kind_of => String, + :regex => /\d+[bBsSkKmMgGtTpPeE]?/ + ) + end + + # A shortcut for creating a logical volume when creating the volume group + # + # @param name [String] the name of the logical volume + # @param block [Proc] the block defining the lvm_logical_volume resource + # + # @return [Chef::Resource::LvmLogicalVolume] the lvm_logical_volume resource + # + def logical_volume(name, &block) + Chef::Log.debug "Creating logical volume #{name}" + volume = lvm_logical_volume(name, &block) + volume.action :nothing + @logical_volumes << volume + volume + end + end + end +end diff --git a/chef/cookbooks/lvm/metadata.rb b/chef/cookbooks/lvm/metadata.rb new file mode 100644 index 0000000..23bca41 --- /dev/null +++ b/chef/cookbooks/lvm/metadata.rb @@ -0,0 +1,14 @@ +name 'lvm' +maintainer 'Opscode, Inc.' +maintainer_email 'cookbooks@opscode.com' +license 'Apache 2.0' +description 'Installs lvm2 package' +version '1.0.5' + +supports 'centos' +supports 'debian' +supports 'redhat' +supports 'sles' +supports 'ubuntu' + +recipe 'lvm', 'Installs lvm2 package' diff --git a/chef/cookbooks/lvm/recipes/default.rb b/chef/cookbooks/lvm/recipes/default.rb new file mode 100644 index 0000000..bce1fc5 --- /dev/null +++ b/chef/cookbooks/lvm/recipes/default.rb @@ -0,0 +1,22 @@ +# +# Cookbook Name:: lvm +# Recipe:: default +# +# Copyright 2009-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package 'lvm2' +chef_gem 'di-ruby-lvm' +chef_gem 'set_partition' diff --git a/chef/cookbooks/lvm/spec/default_spec.rb b/chef/cookbooks/lvm/spec/default_spec.rb new file mode 100644 index 0000000..9e9a7d4 --- /dev/null +++ b/chef/cookbooks/lvm/spec/default_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe 'lvm::default' do + let(:chef_run) do + ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04').converge('lvm::default') + end + + it 'installs lvm2' do + expect(chef_run).to install_package('lvm2') + end + + it 'installs `di-ruby-lvm` as a Ruby gem' do + expect(chef_run).to install_chef_gem('di-ruby-lvm') + end +end diff --git a/chef/cookbooks/lvm/spec/spec_helper.rb b/chef/cookbooks/lvm/spec/spec_helper.rb new file mode 100644 index 0000000..1dd5126 --- /dev/null +++ b/chef/cookbooks/lvm/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'chefspec' +require 'chefspec/berkshelf' diff --git a/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/libraries/helper.rb b/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/libraries/helper.rb new file mode 100644 index 0000000..2ba25cc --- /dev/null +++ b/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/libraries/helper.rb @@ -0,0 +1,51 @@ +# +# Cookbook Name:: fake +# Library:: helper +# +# Copyright (C) 2013 Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module LvmTest + # Helper definitions for lvmtest + module Helper + # Creates given loop devices + # + # @param devices [Integer] the devices to create + # + def self.create_loop_devices(devices) + Array(devices).each do |device| + num = device.slice(/\d+/) + mk_vfile_cmd = "dd if=/dev/zero of=/vfile#{num} bs=1024 count=65536" + Mixlib::ShellOut.new(mk_vfile_cmd).run_command.error! + mk_loop_dev_cmd = "losetup #{device} /vfile#{num}" + Mixlib::ShellOut.new(mk_loop_dev_cmd).run_command.error! + end + end + + # Removes the given loop devices + # + # @param devices [Array, String] list of loop devices to remove + # + def self.remove_loop_devices(devices) + require 'fileutils' + Array(devices).each do |device| + Chef::Log.info "Removing loop device: #{device}" + num = device.slice(/\d+/) + Mixlib::ShellOut.new("losetup -d #{device}").run_command.error! + FileUtils.rm_rf("/vfile#{num}") + end + end + end +end diff --git a/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/metadata.rb b/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/metadata.rb new file mode 100644 index 0000000..b38398d --- /dev/null +++ b/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/metadata.rb @@ -0,0 +1,8 @@ +name 'fake' +maintainer 'Opscode, Inc.' +maintainer_email 'cookbooks@opscode.com' +license 'Apache 2.0' +description 'A fake cookbook to test lvm cookbook' +version '0.1.0' + +depends 'lvm' diff --git a/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/recipes/create.rb b/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/recipes/create.rb new file mode 100644 index 0000000..7b118dd --- /dev/null +++ b/chef/cookbooks/lvm/test/fixtures/cookbooks/fake/recipes/create.rb @@ -0,0 +1,86 @@ +# +# Cookbook Name:: fake +# Recipe:: create +# +# Copyright (C) 2013 Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distribued on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# The test device to use +devices = [ + '/dev/loop0', + '/dev/loop1', + '/dev/loop2', + '/dev/loop3', + '/dev/loop4', + '/dev/loop5', + '/dev/loop6', + '/dev/loop7' +] + +# Creates the loop back device +LvmTest::Helper.create_loop_devices(devices) + +# Creates the physical device + +log 'Creating physical volume for test' +devices.each do |device| + lvm_physical_volume device +end + +# Verify that the create action is idempotent +lvm_physical_volume devices.first + +# Creates the volume group +# +lvm_volume_group 'vg-data' do + physical_volumes ['/dev/loop0', '/dev/loop1', '/dev/loop2', '/dev/loop3'] + + logical_volume 'logs' do + size '10M' + filesystem 'ext2' + mount_point :location => '/mnt/logs', :options => 'noatime,nodiratime' + stripes 2 + end + + logical_volume 'home' do + size '5M' + filesystem 'ext2' + mount_point '/mnt/home' + stripes 1 + mirrors 2 + end +end + +lvm_volume_group 'vg-test' do + physical_volumes ['/dev/loop4', '/dev/loop5', '/dev/loop6', '/dev/loop7'] +end + +# Creates the logical volume +# +lvm_logical_volume 'test' do + group 'vg-test' + size '50%VG' + filesystem 'ext3' + mount_point '/mnt/test' +end + +# Creates a small logical volume +# +lvm_logical_volume 'small' do + group 'vg-test' + size '2%VG' + filesystem 'ext3' + mount_point '/mnt/small' +end diff --git a/chef/cookbooks/lvm/test/integration/create/bats/verify_created.bats b/chef/cookbooks/lvm/test/integration/create/bats/verify_created.bats new file mode 100644 index 0000000..b6d856f --- /dev/null +++ b/chef/cookbooks/lvm/test/integration/create/bats/verify_created.bats @@ -0,0 +1,80 @@ +#!/usr/bin/env bats + +# On CentOS 5.9, most of the commands used here are not in PATH. So add them +# here. +export PATH=$PATH:/sbin:/usr/sbin + +@test "creates the physical volumes" { + pvs | grep /dev/loop0 + pvs | grep /dev/loop1 + pvs | grep /dev/loop2 + pvs | grep /dev/loop3 + pvs | grep /dev/loop4 +} + +@test "creates the volume group vg-data" { + vgs | grep vg-data +} + +@test "creates the logical volume logs on vg-data" { + lvs | grep logs | grep vg-data +} + +@test "logical volume logs is formatted as ext2 filesystem" { + blkid /dev/mapper/vg--data-logs | grep "TYPE=\"ext2\"" +} + +@test "mounts the logical volume logs to /mnt/logs" { + mountpoint /mnt/logs + mount | grep /dev/mapper/vg--data-logs | grep /mnt/logs +} + +@test "creates the logical volume home on vg-data" { + lvs | grep home | grep vg-data +} + +@test "logical volume home is formatted as ext2 filesystem" { + blkid /dev/mapper/vg--data-home | grep "TYPE=\"ext2\"" +} + +@test "mounts the logical volume home to /mnt/home" { + mountpoint /mnt/home + mount | grep /dev/mapper/vg--data-home | grep /mnt/home +} + +@test "creates the volume group vg-test" { + vgs | grep vg-test +} + +@test "creates the logical volume 'test' on 'vg-test'" { + lvs | grep test | grep vg-test +} + +@test "logical volume 'test' is formatted as 'ext3' filesystem" { + blkid /dev/mapper/vg--test-test | grep "TYPE=\"ext3\"" +} + +@test "mounts the logical volume to /mnt/test" { + mountpoint /mnt/test + mount | grep /dev/mapper/vg--test-test | grep /mnt/test +} + +@test "creates the logical volume 'small' on 'vg-test'" { + lvs | grep small | grep vg-test +} + +@test "logical volume 'test' is formatted as 'ext3' filesystem" { + blkid /dev/mapper/vg--test-small | grep "TYPE=\"ext3\"" +} + +@test "mounts the logical volume to /mnt/small" { + mountpoint /mnt/small + mount | grep /dev/mapper/vg--test-small | grep /mnt/small +} + +@test "creates the logical volume using 2% of the available vg extents" { + vgsize="$(vgdisplay vg-test|awk '/Total PE/ {print $3}')" + lvsize="$(lvdisplay /dev/mapper/vg--test-small|awk '/Current LE/ {print $3}')" + vg2pct="$(( $vgsize/50 ))" + [ "$lvsize" -ge "$vg2pct" ] +} diff --git a/chef/cookbooks/net/.gitignore b/chef/cookbooks/net/.gitignore new file mode 100644 index 0000000..eac6c39 --- /dev/null +++ b/chef/cookbooks/net/.gitignore @@ -0,0 +1,2 @@ +.bundle +.cookbooks/ diff --git a/chef/cookbooks/net/.travis.yml b/chef/cookbooks/net/.travis.yml new file mode 100644 index 0000000..2704782 --- /dev/null +++ b/chef/cookbooks/net/.travis.yml @@ -0,0 +1,4 @@ +language: ruby +rvm: + - 1.9.3 +script: ./run_tests.bash diff --git a/chef/cookbooks/net/Berksfile b/chef/cookbooks/net/Berksfile new file mode 100644 index 0000000..850a120 --- /dev/null +++ b/chef/cookbooks/net/Berksfile @@ -0,0 +1 @@ +metadata diff --git a/chef/cookbooks/net/Berksfile.lock b/chef/cookbooks/net/Berksfile.lock new file mode 100644 index 0000000..124fa4e --- /dev/null +++ b/chef/cookbooks/net/Berksfile.lock @@ -0,0 +1 @@ +cookbook 'parted', :path => '/home/jdewey/git/cookbook-parted' \ No newline at end of file diff --git a/chef/cookbooks/net/Gemfile b/chef/cookbooks/net/Gemfile new file mode 100644 index 0000000..36a4481 --- /dev/null +++ b/chef/cookbooks/net/Gemfile @@ -0,0 +1,5 @@ +source :rubygems + +gem "berkshelf", "~> 1.0.4" +gem "chefspec", "~> 0.9.0" +gem "foodcritic", "~> 1.6.1" diff --git a/chef/cookbooks/net/Gemfile.lock b/chef/cookbooks/net/Gemfile.lock new file mode 100644 index 0000000..dbdda2c --- /dev/null +++ b/chef/cookbooks/net/Gemfile.lock @@ -0,0 +1,177 @@ +GEM + remote: http://rubygems.org/ + specs: + activemodel (3.2.11) + activesupport (= 3.2.11) + builder (~> 3.0.0) + activesupport (3.2.11) + i18n (~> 0.6) + multi_json (~> 1.0) + addressable (2.3.2) + archive-tar-minitar (0.5.2) + berkshelf (1.0.4) + activesupport + chef (>= 10.16.2) + chozo (>= 0.2.3) + hashie + minitar + multi_json (>= 1.3.0) + ridley (>= 0.4.1) + solve (>= 0.4.0.rc1) + thor (~> 0.16.0) + vagrant (~> 1.0.5) + yajl-ruby + builder (3.0.4) + bunny (0.7.9) + celluloid (0.12.4) + facter (>= 1.6.12) + timers (>= 1.0.0) + chef (10.18.2) + bunny (>= 0.6.0, < 0.8.0) + erubis + highline (>= 1.6.9) + json (>= 1.4.4, <= 1.6.1) + mixlib-authentication (>= 1.3.0) + mixlib-cli (>= 1.1.0) + mixlib-config (>= 1.1.2) + mixlib-log (>= 1.3.0) + mixlib-shellout + moneta (< 0.7.0) + net-ssh (~> 2.2.2) + net-ssh-multi (~> 1.1.0) + ohai (>= 0.6.0) + rest-client (>= 1.0.4, < 1.7.0) + treetop (~> 1.4.9) + uuidtools + yajl-ruby (~> 1.1) + chefspec (0.9.0) + chef (>= 0.9.12) + erubis + minitest-chef-handler (~> 0.6.0) + rspec (~> 2.11.0) + childprocess (0.3.7) + ffi (~> 1.0, >= 1.0.6) + chozo (0.4.2) + activesupport (>= 3.2.0) + hashie + multi_json (>= 1.3.0) + ci_reporter (1.8.3) + builder (>= 2.1.2) + coderay (1.0.8) + diff-lcs (1.1.3) + erubis (2.7.0) + facter (1.6.17) + faraday (0.8.4) + multipart-post (~> 1.1) + ffi (1.3.1) + foodcritic (1.6.1) + erubis + gherkin (~> 2.11.1) + gist (~> 3.1.0) + nokogiri (= 1.5.0) + pry (~> 0.9.8.4) + rak (~> 1.4) + treetop (~> 1.4.10) + yajl-ruby (~> 1.1.0) + gherkin (2.11.5) + json (>= 1.4.6) + gist (3.1.1) + hashie (1.2.0) + highline (1.6.15) + i18n (0.6.1) + ipaddress (0.8.0) + json (1.5.4) + log4r (1.1.10) + method_source (0.7.1) + mime-types (1.19) + minitar (0.5.4) + minitest (4.5.0) + minitest-chef-handler (0.6.5) + chef + ci_reporter + minitest + mixlib-authentication (1.3.0) + mixlib-log + mixlib-cli (1.3.0) + mixlib-config (1.1.2) + mixlib-log (1.4.1) + mixlib-shellout (1.1.0) + moneta (0.6.0) + multi_json (1.5.0) + multipart-post (1.1.5) + net-http-persistent (2.8) + net-scp (1.0.4) + net-ssh (>= 1.99.1) + net-ssh (2.2.2) + net-ssh-gateway (1.1.0) + net-ssh (>= 1.99.1) + net-ssh-multi (1.1) + net-ssh (>= 2.1.4) + net-ssh-gateway (>= 0.99.0) + nokogiri (1.5.0) + ohai (6.16.0) + ipaddress + mixlib-cli + mixlib-config + mixlib-log + mixlib-shellout + systemu + yajl-ruby + polyglot (0.3.3) + pry (0.9.8.4) + coderay (~> 1.0.5) + method_source (~> 0.7.1) + slop (>= 2.4.4, < 3) + rak (1.4) + rest-client (1.6.7) + mime-types (>= 1.16) + ridley (0.6.3) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + addressable + celluloid + chozo (>= 0.2.2) + erubis + faraday + json (>= 1.5.0) + mixlib-authentication + mixlib-log + multi_json (>= 1.0.4) + net-http-persistent (>= 2.8) + net-ssh + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.3) + diff-lcs (~> 1.1.3) + rspec-mocks (2.11.3) + slop (2.4.4) + solve (0.4.1) + json + systemu (2.5.2) + thor (0.16.0) + timers (1.1.0) + treetop (1.4.12) + polyglot + polyglot (>= 0.3.1) + uuidtools (2.1.3) + vagrant (1.0.5) + archive-tar-minitar (= 0.5.2) + childprocess (~> 0.3.1) + erubis (~> 2.7.0) + i18n (~> 0.6.0) + json (~> 1.5.1) + log4r (~> 1.1.9) + net-scp (~> 1.0.4) + net-ssh (~> 2.2.2) + yajl-ruby (1.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + berkshelf (~> 1.0.4) + chefspec (~> 0.9.0) + foodcritic (~> 1.6.1) diff --git a/chef/cookbooks/net/LICENSE b/chef/cookbooks/net/LICENSE new file mode 100644 index 0000000..68c771a --- /dev/null +++ b/chef/cookbooks/net/LICENSE @@ -0,0 +1,176 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + diff --git a/chef/cookbooks/net/README.md b/chef/cookbooks/net/README.md new file mode 100644 index 0000000..e69de29 diff --git a/chef/cookbooks/net/attributes/default.rb b/chef/cookbooks/net/attributes/default.rb new file mode 100644 index 0000000..c2c2028 --- /dev/null +++ b/chef/cookbooks/net/attributes/default.rb @@ -0,0 +1,43 @@ +# +# Cookbook Name:: net +# Attributes:: default +# +# Copyright 2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +default['nic']['vender']['drvier'] = { + "Mellanox" => { + "localpath" => '/tmp/mlnx_en-2.1-1.0.0.0.gfeee0c2.2.6.32_431.el6.x86_64.x86_64.rpm', + "source" => 'http://10.1.0.201/download/mlnx_en-2.1-1.0.0.0.gfeee0c2.2.6.32_431.el6.x86_64.x86_64.rpm', + "load" => "rmmod mlx4_core; modprobe mlx4_en", + "status" => '' + } +} + +default['nic']['config'] = { + "eth5" => { + "ip" => '', + "network" => "10.5.0.0", + "netmask" => "255.255.0.0", + "conf" => "/etc/sysconfig/network-scripts/ifcfg-eth5", + "status" => '' + }, + "eth6" => { + "ip" => '', + "network" => "10.6.0.0", + "netmask" => "255.255.0.0", + "conf" => "/etc/sysconfig/network-scripts/ifcfg-eth6", + "status" => '' + } +} diff --git a/chef/cookbooks/net/metadata.rb b/chef/cookbooks/net/metadata.rb new file mode 100644 index 0000000..1a83ef1 --- /dev/null +++ b/chef/cookbooks/net/metadata.rb @@ -0,0 +1,13 @@ +name "net" +maintainer "Sam" +maintainer_email "sam.su@huawei.com" +license "Apache 2.0" +description "Install NIC driver and configure NIC's IP address" +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version "1.0.0" + +recipe "default", "Installs/Configures 10g NICs" + +%w{ centos debian ubuntu }.each do |os| + supports os +end diff --git a/chef/cookbooks/net/providers/ip.rb b/chef/cookbooks/net/providers/ip.rb new file mode 100644 index 0000000..71aa9a7 --- /dev/null +++ b/chef/cookbooks/net/providers/ip.rb @@ -0,0 +1,70 @@ +# +# Cookbook Name:: net +# Provider:: net +# +# Copyright 2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +require 'chef/mixin/shell_out' +include Chef::Mixin::ShellOut + +def set resource + cmd = "ifconfig eth0 |grep 'inet addr' | cut -f 2 -d ':' | cut -f 1 -d ' '" + rc = shell_out(cmd) + if rc.valid_exit_codes.include?(0) + net = node['nic']['config']["#{resource.device}"] + if net['status'].eql?('') or net['status'].nil? + ip = %x{ifconfig eth0 |grep 'inet addr' | cut -f 2 -d ":" | cut -f 1 -d " "}.split[0].split('.') + ip[0] = net['network'].split('.')[0] + ip[1] = net['network'].split('.')[1] + mac = %x{ifconfig #{resource.device}|grep "HWaddr"}.split()[4] + node.set['nic']['config']["#{resource.device}"]['ip'] = ip.join('.') + node.set['nic']['config']["#{resource.device}"]['mac'] = mac + node.set['nic']['config']["#{resource.device}"]['status'] = "initial" + else + Chef::Log.error("Cannot get the device info of #{resource.device}.") + end + end +end + + +action :create do + set new_resource + net = node['nic']['config']["#{new_resource.device}"] + if !net['status'].nil? and net['status'].include?("initial") + if not ::File.exist?(net['conf']) + service "network" do + action :enable + subscribes :restart, "template[net['conf']]" + end + + template net['conf'] do + source "ifcfg.erb" + mode 00644 + owner "root" + group "root" + variables({ + :eth => new_resource.device, + :mac => net['mac'], + :ip => net['ip'], + :netmask => net['netmask'] + }) + notifies :restart, "service[network]", :immediately + end + node.set['nic']['config']["#{new_resource.device}"]['status'] = "config" + end + new_resource.updated_by_last_action(true) + end +end + diff --git a/chef/cookbooks/net/providers/nic.rb b/chef/cookbooks/net/providers/nic.rb new file mode 100644 index 0000000..503e806 --- /dev/null +++ b/chef/cookbooks/net/providers/nic.rb @@ -0,0 +1,70 @@ +# +# Cookbook Name:: net +# Provider:: net +# +# Copyright 2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +require 'chef/mixin/shell_out' +include Chef::Mixin::ShellOut + +def check resource + cmd = "lspci |grep -i #{resource.vender_name}" + rc = shell_out(cmd) + if rc.valid_exit_codes.include?(0) + driver = node['nic']['vender']['drvier']["#{new_resource.vender_name}"] + if driver['status'].eql?('') + node.set['nic']['vender']['drvier']["#{resource.vender_name}"]['status'] = "exist" + end + else + Chef::Log.error("There is not exist the device of #{resource.vender_name}.") + end +end + +action :prepare do + package "pciutils" do + action :upgrade + end + new_resource.updated_by_last_action(true) +end + +action :install do + check new_resource + driver = node['nic']['vender']['drvier']["#{new_resource.vender_name}"] + if driver['status'].include?("exist") + #download driver file + if not ::File.exist?(driver['localpath']) + remote_file driver['localpath'] do + source driver['source'] + end + end + + execute "load_driver" do + command node['nic']['vender']['drvier']["#{new_resource.vender_name}"]['load'] + action :nothing + subscribes :run, "package[nic_driver]", :immediately + end + + # install driver + package "nic_driver" do + source driver['localpath'] + action :install + notifies :run, 'execute[load_driver]', :immediately + end + + node.set['nic']['vender']['drvier']["#{new_resource.vender_name}"]['status'] = "installed" + new_resource.updated_by_last_action(true) + end +end + diff --git a/chef/cookbooks/net/recipes/default.rb b/chef/cookbooks/net/recipes/default.rb new file mode 100644 index 0000000..774cd95 --- /dev/null +++ b/chef/cookbooks/net/recipes/default.rb @@ -0,0 +1,36 @@ +# +# Cookbook Name:: net +# Recipe:: default +# +# Copyright 2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +net_nic "prepare" do + action :prepare +end + + +node['nic']['vender']['drvier'].each_key do |vender| + # Install the driver package + net_nic vender do + action :install + end +end + +node['nic']['config'].each_key do |nic| + net_ip nic.to_s do + action :create + end +end diff --git a/chef/cookbooks/net/resources/ip.rb b/chef/cookbooks/net/resources/ip.rb new file mode 100644 index 0000000..369a28a --- /dev/null +++ b/chef/cookbooks/net/resources/ip.rb @@ -0,0 +1,27 @@ +# +# Cookbook Name:: net +# Resource:: net +# +# Copyright 2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +actions :create + +attribute :device, :kind_of => String, :name_attribute => true + +def initialize(*args) + super + @action = :create +end diff --git a/chef/cookbooks/net/resources/nic.rb b/chef/cookbooks/net/resources/nic.rb new file mode 100644 index 0000000..eccac43 --- /dev/null +++ b/chef/cookbooks/net/resources/nic.rb @@ -0,0 +1,27 @@ +# +# Cookbook Name:: net +# Resource:: net +# +# Copyright 2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +actions :prepare, :install + +attribute :vender_name, :kind_of => String, :name_attribute => true + +def initialize(*args) + super + @action = :prepare +end diff --git a/chef/cookbooks/net/templates/default/ifcfg.erb b/chef/cookbooks/net/templates/default/ifcfg.erb new file mode 100644 index 0000000..dbe190d --- /dev/null +++ b/chef/cookbooks/net/templates/default/ifcfg.erb @@ -0,0 +1,11 @@ +## Automaticlly generated by Chef +## DO NOT change the file, if want to change the IP address, +## please change the default attribute file of the cookbok "net" +## +DEVICE=<%= @eth %> +ONBOOT=yes +HWADDR=<%= @mac %> +TYPE=Ethernet +BOOTPROTO=static +IPADDR=<%= @ip %> +NETMASK=<%= @netmask %> diff --git a/chef/cookbooks/openstack-block-storage/attributes/default.rb b/chef/cookbooks/openstack-block-storage/attributes/default.rb index 31682bf..d07aee3 100644 --- a/chef/cookbooks/openstack-block-storage/attributes/default.rb +++ b/chef/cookbooks/openstack-block-storage/attributes/default.rb @@ -113,7 +113,7 @@ default["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drive default["openstack"]["block-storage"]["volume"]["volume_group"] = "cinder-volumes" default["openstack"]["block-storage"]["volume"]["iscsi_helper"] = "tgtadm" default["openstack"]["volume"]["mode"] = "loopfile" -default["openstack"]["volume"]["size"] = "3G" +default["openstack"]["volume"]["disk"] = "/dev/sdb" # Ceph/RADOS options diff --git a/chef/cookbooks/openstack-block-storage/providers/.volume.rb.swp b/chef/cookbooks/openstack-block-storage/providers/.volume.rb.swp new file mode 100644 index 0000000..c7a1a81 Binary files /dev/null and b/chef/cookbooks/openstack-block-storage/providers/.volume.rb.swp differ diff --git a/chef/cookbooks/openstack-block-storage/providers/volume.rb b/chef/cookbooks/openstack-block-storage/providers/volume.rb new file mode 100644 index 0000000..7292e31 --- /dev/null +++ b/chef/cookbooks/openstack-block-storage/providers/volume.rb @@ -0,0 +1,173 @@ +# +# Cookbook Name:: openstack-block-storage +# Provider:: openstack-block-storage +# +# Copyright 2014-2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +require 'chef/mixin/shell_out' +include Chef::Mixin::ShellOut + +def partition_num resource + cmd = "parted #{resource.device} --script -- p | awk '{print $1}'" + rc = shell_out(cmd) + p_num = rc.stdout.split.select{|e| e[/\d/]} + if p_num.include? "Number" + last_num = 0 + Chef::Log.info("There is not any partition created at #{resource.device} yet.") + end + return p_num +end + +def partition_start_size resource + cmd = "parted #{resource.device} --script -- p | awk '{print $3}' | tail -n 2" + rc = shell_out(cmd) + resource.start_size = rc.stdout.split[0] + if resource.start_size.include? "End" + resource.start_size = 0 + end +end + +def disk_total_size resource + cmd = "parted #{resource.device} --script -- p | grep #{resource.device} | cut -f 2 -d ':'" + rc = shell_out(cmd) + resource.total_size = rc.stdout.split[0] +end + +def mklabel resource + queryresult = %x{parted #{resource.device} --script -- print |grep 'Partition Table: #{new_resource.label_type}'} + if not queryresult.include?(new_resource.label_type) + cmd = "parted #{resource.device} --script -- mklabel #{resource.label_type}" + rc = shell_out(cmd) + if not rc.exitstatus.eql?(0) + Chef::Log.error("Creating disk label was failed.") + end + end +end + +def mkpart resource + disk_total_size resource + partition_start_size resource + if not resource.start_size.eql?(resource.total_size) + p_num_old = partition_num resource + output = %x{parted #{resource.device} --script -- mkpart #{resource.part_type} #{resource.start_size} -1} + p_num_new = partition_num resource + p_num = (p_num_new - p_num_old)[0] + if p_num.nil? + Chef::Log.error("Making partition was failed.") + else + resource.partition = resource.device + p_num + if node['partitions'].nil? + node.set['partitions'] = resource.partition.lines.to_a + else + if not node['partitions'].include?(resource.partition) + node.set['partitions'] = node['partitions'] + resource.partition.lines.to_a + end + end + end + end +end + +def file_partition_size + output = %x{df -h /} + available_size = (output.lines.to_a[1].split[3].nil?) \ + ?(output.lines.to_a[1].split + output.lines.to_a[2].split)[3] \ + :(output.lines.to_a[1].split[3]) + file_size = ((available_size.scan(/\d+/)[0].to_i)/2).to_s + + available_size.scan(/[MGTEY]/)[0] + return file_size +end + +def select_loop_device resource + output = %x{losetup -a|grep "/mnt/cinder-volumes"}.split(':') + if output.empty? + used_loop_device = %x{losetup -a |cut -f 1 -d ':'}.split + total_loop_device = %x{ls /dev/loop*}.split + available_loop = total_loop_device - used_loop_device + if available_loop.nil? + resource.partition = nil + Chef::Log.error("There is not any loop device available.") + else + resource.partition = available_loop[0] + end + else + resource.partition = output[0] + end +end + +def create_file_partition resource + # use half root partition space as file volume + if not ::File.exist?("/mnt/cinder-volumes") + cmd = "dd if=/dev/zero of=/mnt/cinder-volumes bs=1 count=0 seek=#{file_partition_size}" + rc = shell_out(cmd) + end + output = %x{losetup -a|grep '/mnt/cinder-volumes'} + if not output.include?("/mnt/cinder-volumes") + select_loop_device resource + if not resource.partition.nil? + output = %x{losetup #{resource.partition} /mnt/cinder-volumes} + end + else + resource.partition = output.split(":")[0] + end + if node['partitions'].nil? + node.set['partitions'] = resource.partition.lines.to_a if not resource.partition.nil? + else + if not node['partitions'].include?(resource.partition) + node.set['partitions'] = node['partitions'] + resource.partition.lines.to_a + end + end +end + +def create_disk_partition resource + mklabel resource + mkpart resource +end + +action :create_partition do + if node['partitions'].nil? or not node['partitions'].any?{|s| s.include?(new_resource.device)} + disk_total_size new_resource + partition_start_size new_resource + if new_resource.start_size.eql?(new_resource.total_size) + create_file_partition new_resource + else + create_disk_partition new_resource + end + new_resource.updated_by_last_action(true) + end +end + +action :mk_cinder_vol do + if node['partitions'].nil? + Chef::Log.error("\nThere is not any partition created before trying to create a volume.") + else + node['partitions'].each do |partition| + if partition.include?(new_resource.device) or partition.include?("/dev/loop") + query = %x{vgscan |grep cinder-volumes} + if query.eql?("") + execute "vgcreate cinder-volumes #{partition}" do + new_resource.updated_by_last_action(true) + end + else + query = %x{pvscan |grep cinder-volumes|grep #{partition}} + if query.eql?("") + execute "vgextend cinder-volumes #{partition}" do + new_resource.updated_by_last_action(true) + end + end + end + end + end + end +end diff --git a/chef/cookbooks/openstack-block-storage/recipes/api.rb b/chef/cookbooks/openstack-block-storage/recipes/api.rb index 72387f3..650fdfe 100644 --- a/chef/cookbooks/openstack-block-storage/recipes/api.rb +++ b/chef/cookbooks/openstack-block-storage/recipes/api.rb @@ -49,6 +49,12 @@ directory ::File.dirname(node["openstack"]["block-storage"]["api"]["auth"]["cach mode 00700 end +directory "/var/lock/cinder" do + owner node["openstack"]["block-storage"]["user"] + group node["openstack"]["block-storage"]["group"] + mode 00700 +end + service "cinder-api" do service_name platform_options["cinder_api_service"] supports :status => true, :restart => true diff --git a/chef/cookbooks/openstack-block-storage/recipes/test.rb b/chef/cookbooks/openstack-block-storage/recipes/test.rb new file mode 100644 index 0000000..04237ae --- /dev/null +++ b/chef/cookbooks/openstack-block-storage/recipes/test.rb @@ -0,0 +1,20 @@ +#include_recipe "openstack-block-storage::cinder-common" +#include_recipe "parted::default" + +node.set['create_partition'] = false +node.set['partitions'] = nil +openstack_block_storage_volume "/dev/sdb" do + action :create_partition +end + +openstack_block_storage_volume "/dev/sdc" do + action :create_partition +end + +openstack_block_storage_volume "/dev/sdb" do + action :mk_cinder_vol +end + +openstack_block_storage_volume "/dev/sdc" do + action :mk_cinder_vol +end diff --git a/chef/cookbooks/openstack-block-storage/recipes/volume.rb b/chef/cookbooks/openstack-block-storage/recipes/volume.rb index 9ff4019..00d08da 100644 --- a/chef/cookbooks/openstack-block-storage/recipes/volume.rb +++ b/chef/cookbooks/openstack-block-storage/recipes/volume.rb @@ -28,6 +28,10 @@ include_recipe "openstack-block-storage::cinder-common" platform_options = node["openstack"]["block-storage"]["platform"] +package "parted" do + action :upgrade +end + platform_options["cinder_volume_packages"].each do |pkg| package pkg do options platform_options["package_overrides"] @@ -51,9 +55,10 @@ platform_options["cinder_iscsitarget_packages"].each do |pkg| end end -execute "create_cinder_volumes" do - command "sh /tmp/cinder_volumes.sh" - action :nothing +directory "/var/lock/cinder" do + owner node["openstack"]["block-storage"]["user"] + group node["openstack"]["block-storage"]["group"] + mode 00700 end case node["openstack"]["block-storage"]["volume"]["driver"] @@ -93,17 +98,35 @@ case node["openstack"]["block-storage"]["volume"]["driver"] end when "cinder.volume.drivers.lvm.LVMISCSIDriver" - template "/tmp/cinder_volumes.sh" do - source "cinder_volumes.sh.erb" - owner "root" - group "root" - mode 00755 - variables( - :volumesize => node["openstack"]["volume"]["size"] - ) - notifies :run, "execute[create_cinder_volumes]", :delayed - only_if { node["openstack"]["volume"]["mode"] == "loopfile" } + package "bc" do + action :install end + + openstack_block_storage_volume node["openstack"]["volume"]["disk"] do + action :create_partition + end + + openstack_block_storage_volume node["openstack"]["volume"]["disk"] do + action :mk_cinder_vol + end + +# template "/tmp/cinder_volumes.sh" do +# source "cinder_volumes.sh.erb" +# owner "root" +# group "root" +# mode 00755 +# variables( +# :volumesize => node["openstack"]["volume"]["size"] +# ) +# notifies :run, "execute[create_cinder_volumes]", :immediately +# only_if { node["openstack"]["volume"]["mode"] == "loopfile" } +# end + +# execute "create_cinder_volumes" do +# command "sh /tmp/cinder_volumes.sh" +# action :run +# only_if { node["openstack"]["volume"]["mode"] == "loopfile" } +# end end service "cinder-volume" do diff --git a/chef/cookbooks/openstack-block-storage/resources/volume.rb b/chef/cookbooks/openstack-block-storage/resources/volume.rb new file mode 100644 index 0000000..e9793f9 --- /dev/null +++ b/chef/cookbooks/openstack-block-storage/resources/volume.rb @@ -0,0 +1,36 @@ +# +# Cookbook Name:: openstack-block-storage +# Resource:: openstack-block-storage +# +# Copyright 2014-2014, Sam Su +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +actions :create_partition, :mk_cinder_vol + +attribute :device, :kind_of => String, :name_attribute => true +attribute :label_type, :kind_of => String, :default => "gpt" +attribute :file_system, :kind_of => String, :default => "ext4" +attribute :part_type, :kind_of => String, :default => "primary" +#attribute :partition, :kind_of => String, :default => "0" + +attr_accessor :last_num +attr_accessor :start_size +attr_accessor :total_size +attr_accessor :partition + +def initialize(*args) + super + @action = :mk_cinder_vol +end diff --git a/chef/cookbooks/openstack-block-storage/templates/default/cinder.conf.erb b/chef/cookbooks/openstack-block-storage/templates/default/cinder.conf.erb index fc07768..74837ba 100644 --- a/chef/cookbooks/openstack-block-storage/templates/default/cinder.conf.erb +++ b/chef/cookbooks/openstack-block-storage/templates/default/cinder.conf.erb @@ -11,7 +11,7 @@ verbose=<%= node["openstack"]["block-storage"]["verbose"] %> #### (BoolOpt) Print more verbose output # lock_path -lock_path=<%= node["openstack"]["block-storage"]["lock_path"] %> +#lock_path=<%= node["openstack"]["block-storage"]["lock_path"] %> notification_driver=cinder.openstack.common.notifier.rpc_notifier # log_config= diff --git a/chef/cookbooks/openstack-block-storage/templates/default/cinder_volumes.sh.erb b/chef/cookbooks/openstack-block-storage/templates/default/cinder_volumes.sh.erb index 666ed51..08a93d5 100644 --- a/chef/cookbooks/openstack-block-storage/templates/default/cinder_volumes.sh.erb +++ b/chef/cookbooks/openstack-block-storage/templates/default/cinder_volumes.sh.erb @@ -1,12 +1,30 @@ #!/bin/bash # This file is going to create a loop file as volume disk. # +ERRTRAP() +{ + echo "[FILE: "$PWD/$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")", LINE: $1] Error: Command or function exited with status $?" +} + +trap 'ERRTRAP $LINENO' ERR vgdisplay |grep cinder-volumes + if [ $? -ne 0 ]; then - dd if=/dev/zero of=/mnt/cinder-volumes bs=1 count=0 seek=<%=@volumesize %> - losetup /dev/loop0 /mnt/cinder-volumes - pvcreate /dev/loop0 - vgcreate cinder-volumes /dev/loop0 + SPACESIZE=$(df -P |grep -vE "^tmpfs|cdrom|tmp" | sed '1d' | awk '{print $4}' | sort -nr | sed -n -e '1{p;q}') + MOUNTPOINT=$(df -P |grep -vE "^tmpfs|cdrom|tmp" | sed '1d' | awk '{print $6}' | sort -nr | sed -n -e '1{p;q}') + G_SPACESIZE=$(echo "$SPACESIZE/1000/1000/2" | bc -l) + echo $G_SPACESIZE + VOLSIZE=${G_SPACESIZE/.*} + echo $VOLSIZE + if [ $VOLSIZE -ge "1" ]; then + dd if=/dev/zero of=$MOUNTPOINT/cinder-volumes bs=1 count=0 seek="$VOLSIZE"G + losetup /dev/loop0 $MOUNTPOINT/cinder-volumes + pvcreate /dev/loop0 + vgcreate cinder-volumes /dev/loop0 + else + echo "The current spare disk space only $SPACESIZE < 1G, no enough disk space is available for the cinder-volume" + exit 0 + fi fi diff --git a/chef/cookbooks/openstack-common/attributes/default.rb b/chef/cookbooks/openstack-common/attributes/default.rb index 60210e4..384586b 100644 --- a/chef/cookbooks/openstack-common/attributes/default.rb +++ b/chef/cookbooks/openstack-common/attributes/default.rb @@ -26,10 +26,6 @@ # pass = secret "passwords", "nova" # # The value of pass will be "nova" -ENV['http_proxy']=Chef::Config.http_proxy -ENV['https_proxy']=Chef::Config.https_proxy -ENV['no_proxy']=Chef::Config.no_proxy - default["openstack"]["developer_mode"] = true # The type of token signing to use (uuid or pki) @@ -282,8 +278,8 @@ default['openstack']['identity']['admin_token'] = "openstack_identity_bootstrap_ default['openstack']['identity']['admin_tenant_name'] = "admin" default['openstack']['identity']['admin_user'] = "admin" default['openstack']['identity']['admin_password'] = "admin" -#default['openstack']['identity']['roles']['admin'] = "admin" -#default['openstack']['identity']['roles']['member'] = "Member" +default['openstack']['identity']['roles']['admin'] = "admin" +default['openstack']['identity']['roles']['member'] = "Member" # define enable services default['openstack']['services'] = { diff --git a/chef/cookbooks/openstack-common/recipes/databag.rb b/chef/cookbooks/openstack-common/recipes/databag.rb index 10792f3..0e4e66c 100644 --- a/chef/cookbooks/openstack-common/recipes/databag.rb +++ b/chef/cookbooks/openstack-common/recipes/databag.rb @@ -332,7 +332,8 @@ node.override["openstack"]["network"]["openvswitch"]["tunnel_bridge"] = mydata[' # this hypervisor or set the local_ip_interface parameter to use the IP # address of the specified interface. If local_ip_interface is set # it will take precedence. -local_ip_interface = mydata['networking']['plugins']['ovs']["#{tenant_network_type}"]['local_ip_interface'] +#local_ip_interface = mydata['networking']['plugins']['ovs']["#{tenant_network_type}"]['local_ip_interface'] +local_ip_interface = mydata['networking']['tenant']['interface'] if local_ip_interface != ("nil") local_ip= address_for(local_ip_interface) else diff --git a/chef/cookbooks/openstack-compute/attributes/default.rb b/chef/cookbooks/openstack-compute/attributes/default.rb index 1189d43..b154d10 100644 --- a/chef/cookbooks/openstack-compute/attributes/default.rb +++ b/chef/cookbooks/openstack-compute/attributes/default.rb @@ -297,9 +297,9 @@ when "ubuntu" default["openstack"]["compute"]["platform"] = { "api_ec2_packages" => ["nova-api-ec2"], "api_ec2_service" => "nova-api-ec2", - "api_os_compute_packages" => ["nova-api-os-compute"], - "api_os_compute_process_name" => "nova-api-os-compute", - "api_os_compute_service" => "nova-api-os-compute", + "api_os_compute_packages" => ["nova-api"], + "api_os_compute_process_name" => "nova-api", + "api_os_compute_service" => "nova-api", "memcache_python_packages" => ["python-memcache"], "neutron_python_packages" => ["python-quantumclient", "python-pyparsing"], "compute_api_metadata_packages" => ["nova-api-metadata"], diff --git a/chef/cookbooks/openstack-compute/recipes/compute.rb b/chef/cookbooks/openstack-compute/recipes/compute.rb index f37a0dd..6ecdfc3 100644 --- a/chef/cookbooks/openstack-compute/recipes/compute.rb +++ b/chef/cookbooks/openstack-compute/recipes/compute.rb @@ -52,7 +52,6 @@ end compute_compute_packages.each do |pkg| package pkg do options platform_options["package_overrides"] - action :upgrade end end diff --git a/chef/cookbooks/openstack-compute/recipes/vncproxy.rb b/chef/cookbooks/openstack-compute/recipes/vncproxy.rb index 9ea8a7f..a694d9e 100644 --- a/chef/cookbooks/openstack-compute/recipes/vncproxy.rb +++ b/chef/cookbooks/openstack-compute/recipes/vncproxy.rb @@ -51,7 +51,7 @@ service proxy_service do supports :status => true, :restart => true subscribes :restart, resources("template[/etc/nova/nova.conf]") - action :enable + action [:enable, :start] end service "nova-console" do diff --git a/chef/cookbooks/openstack-dashboard/templates/default/dash-site.erb b/chef/cookbooks/openstack-dashboard/templates/default/dash-site.erb index 359d59b..922eca0 100644 --- a/chef/cookbooks/openstack-dashboard/templates/default/dash-site.erb +++ b/chef/cookbooks/openstack-dashboard/templates/default/dash-site.erb @@ -9,7 +9,11 @@ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R] -WSGISocketPrefix run/wsgi +<% if %w{debian ubuntu}.include?(node["platform"]) -%> + WSGISocketPrefix /var/run/apache2/wsgi +<% else -%> + WSGISocketPrefix run/wsgi +<% end -%> <% if node["openstack"]["dashboard"]["server_hostname"] -%> diff --git a/chef/cookbooks/openstack-image/attributes/default.rb b/chef/cookbooks/openstack-image/attributes/default.rb index a8cabcf..231e0f7 100644 --- a/chef/cookbooks/openstack-image/attributes/default.rb +++ b/chef/cookbooks/openstack-image/attributes/default.rb @@ -90,12 +90,12 @@ default["openstack"]["image"]["registry"]["bind_interface"] = nil default["openstack"]["image"]["data_api"] = "glance.db.sqlalchemy.api" # Default Image Locations -default["openstack"]["image"]["image_upload"] = false -default["openstack"]["image"]["upload_images"] = [ "cirros" ] +default["openstack"]["image"]["image_upload"] = true +default["openstack"]["image"]["upload_images"] = [ "cirros-0.3.1-x86_64" ] default["openstack"]["image"]["upload_image"]["precise"] = "http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img" default["openstack"]["image"]["upload_image"]["oneiric"] = "http://cloud-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64-disk1.img" default["openstack"]["image"]["upload_image"]["natty"] = "http://cloud-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64-disk1.img" -default["openstack"]["image"]["upload_image"]["cirros"] = "https://launchpadlibrarian.net/83305348/cirros-0.3.0-x86_64-disk.img" +default["openstack"]["image"]["upload_image"]["cirros-0.3.1-x86_64"] = "http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img" # more images available at https://github.com/rackerjoe/oz-image-build default["openstack"]["image"]["upload_image"]["centos"] = "http://c250663.r63.cf1.rackcdn.com/centos60_x86_64.qcow2" diff --git a/chef/cookbooks/openstack-image/files/default/images/cirros-0.3.1-i386-disk.img b/chef/cookbooks/openstack-image/files/default/images/cirros-0.3.1-i386-disk.img new file mode 100644 index 0000000..95350c2 Binary files /dev/null and b/chef/cookbooks/openstack-image/files/default/images/cirros-0.3.1-i386-disk.img differ diff --git a/chef/cookbooks/openstack-image/files/default/images/cirros-0.3.1-x86_64-disk.img b/chef/cookbooks/openstack-image/files/default/images/cirros-0.3.1-x86_64-disk.img new file mode 100644 index 0000000..e7ffb30 Binary files /dev/null and b/chef/cookbooks/openstack-image/files/default/images/cirros-0.3.1-x86_64-disk.img differ diff --git a/chef/cookbooks/openstack-image/recipes/api.rb b/chef/cookbooks/openstack-image/recipes/api.rb index 2435121..2dd27e1 100644 --- a/chef/cookbooks/openstack-image/recipes/api.rb +++ b/chef/cookbooks/openstack-image/recipes/api.rb @@ -50,7 +50,7 @@ service "image-api" do service_name platform_options["image_api_service"] supports :status => true, :restart => true - action :enable + action [:enable,:start] end directory "/etc/glance" do @@ -59,6 +59,12 @@ directory "/etc/glance" do mode 00700 end +directory "/var/cache/glance/" do + owner node["openstack"]["image"]["user"] + group node["openstack"]["image"]["group"] + mode 00700 +end + directory ::File.dirname node["openstack"]["image"]["api"]["auth"]["cache_dir"] do owner node["openstack"]["image"]["user"] group node["openstack"]["image"]["group"] @@ -94,8 +100,8 @@ end #db_user = node["openstack"]["image"]["db"]["username"] #db_pass = db_password "glance" -db_user = node["openstack"]["db"]["image"]["password"] -db_pass = db_password node["openstack"]["db"]["image"]["password"] +db_user = node["openstack"]["db"]["image"]["username"] +db_pass = node["openstack"]["db"]["image"]["password"] sql_connection = db_uri("image", db_user, db_pass) diff --git a/chef/cookbooks/openstack-image/recipes/registry.rb b/chef/cookbooks/openstack-image/recipes/registry.rb index f043804..1798039 100644 --- a/chef/cookbooks/openstack-image/recipes/registry.rb +++ b/chef/cookbooks/openstack-image/recipes/registry.rb @@ -33,8 +33,10 @@ package "python-keystone" do action :install end -db_user = node['openstack']['db']['image']['username'] -db_pass = db_password node['openstack']['db']['image']['password'] +#db_user = node['openstack']['db']['image']['username'] +#db_pass = db_password node['openstack']['db']['image']['password'] +db_user = node["openstack"]["db"]["image"]["username"] +db_pass = node["openstack"]["db"]["image"]["password"] sql_connection = db_uri("image", db_user, db_pass) @@ -91,6 +93,18 @@ directory "/etc/glance" do mode 00700 end +directory "/var/log/glance" do + owner node["openstack"]["image"]["user"] + group node["openstack"]["image"]["group"] + mode 00700 +end + +directory "/var/cache/glance/" do + owner node["openstack"]["image"]["user"] + group node["openstack"]["image"]["group"] + mode 00700 +end + if node["openstack"]["image"]["registry"]["bind_interface"].nil? bind_address = registry_endpoint.host else @@ -99,8 +113,8 @@ end template "/etc/glance/glance-registry.conf" do source "glance-registry.conf.erb" - owner "root" - group "root" + owner node["openstack"]["image"]["user"] + group node["openstack"]["image"]["group"] mode 00644 variables( :registry_bind_address => bind_address, @@ -121,32 +135,12 @@ end template "/etc/glance/glance-registry-paste.ini" do source "glance-registry-paste.ini.erb" - owner "root" - group "root" + owner node["openstack"]["image"]["user"] + group node["openstack"]["image"]["group"] mode 00644 notifies :restart, "service[image-registry]", :immediately end -execute "tinyimage" do - command "sh /tmp/tinyimage.sh" - action :nothing -end - identity_endpoint = endpoint "identity-api" auth_uri = ::URI.decode identity_endpoint.to_s - -template "/tmp/tinyimage.sh" do - source "tinyimage.sh.erb" - owner "root" - group "root" - mode 00755 - variables( - :os_username => node['openstack']['identity']['admin_user'], - :os_password => node['openstack']['identity']['admin_password'], - :os_tenant_name => node['openstack']['identity']['admin_tenant_name'], - :os_auth_url => auth_uri - ) - - notifies :run, "execute[tinyimage]", :delayed -end diff --git a/chef/cookbooks/openstack-image/templates/default/tinyimage.sh.erb b/chef/cookbooks/openstack-image/templates/default/tinyimage.sh.erb index e493f75..3274c67 100644 --- a/chef/cookbooks/openstack-image/templates/default/tinyimage.sh.erb +++ b/chef/cookbooks/openstack-image/templates/default/tinyimage.sh.erb @@ -5,33 +5,34 @@ OS_PASSWORD=<%= @os_password %> OS_TENANT_NAME=<%= @os_tenant_name %> OS_AUTH_URL=<%= @os_auth_url %> +IMAGEDIR=/tmp/images + glance --os-username=<%= @os_username %> \ --os-password=<%= @os_password %> \ --os-tenant-name=<%= @os_tenant_name %> \ --os-auth-url=<%= @os_auth_url %> \ image-list |grep "cirros-0.3.1" -if [ $? -ne 0 ]; then - mkdir -p /tmp/images - cd /tmp/images/ - yum install -y wget - wget http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img - glance --os-username=<%= @os_username %> \ - --os-password=<%= @os_password %> \ - --os-tenant-name=<%= @os_tenant_name %> \ - --os-auth-url=<%= @os_auth_url %> \ - image-create \ - --name="cirros-0.3.1-x86_64" \ - --disk-format=qcow2 \ - --container-format bare < /tmp/images/cirros-0.3.1-x86_64-disk.img - wget http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-i386-disk.img - glance --os-username=<%= @os_username %> \ - --os-password=<%= @os_password %> \ - --os-tenant-name=<%= @os_tenant_name %> \ - --os-auth-url=<%= @os_auth_url %> \ - image-create \ - --name="cirros-0.3.1-i386" \ - --disk-format=qcow2 \ - --container-format bare < /tmp/images/cirros-0.3.1-i386-disk.img +if [ $? -ne 0 ]; then + if [ -d "$IMAGEDIR" ]; then + cd $IMAGEDIR + glance --os-username=<%= @os_username %> \ + --os-password=<%= @os_password %> \ + --os-tenant-name=<%= @os_tenant_name %> \ + --os-auth-url=<%= @os_auth_url %> \ + image-create \ + --name="cirros-0.3.1-x86_64" \ + --disk-format=qcow2 \ + --container-format bare < $IMAGEDIR/cirros-0.3.1-x86_64-disk.img + + glance --os-username=<%= @os_username %> \ + --os-password=<%= @os_password %> \ + --os-tenant-name=<%= @os_tenant_name %> \ + --os-auth-url=<%= @os_auth_url %> \ + image-create \ + --name="cirros-0.3.1-i386" \ + --disk-format=qcow2 \ + --container-format bare < $IMAGEDIR/cirros-0.3.1-i386-disk.img + fi fi diff --git a/chef/cookbooks/openstack-network/attributes/default.rb b/chef/cookbooks/openstack-network/attributes/default.rb index 32e12ad..db16f1b 100644 --- a/chef/cookbooks/openstack-network/attributes/default.rb +++ b/chef/cookbooks/openstack-network/attributes/default.rb @@ -123,8 +123,8 @@ default["openstack"]["network"]["dhcp_driver"] = 'quantum.agent.linux.dhcp.Dnsma # must enable namespaces to use overlapping ips. Also, # you must have kernel build with CONFIG_NET_NS=y and # iproute2 package that supports namespaces. -default["openstack"]["network"]["use_namespaces"] = "False" -default["openstack"]["network"]["allow_overlapping_ips"] = "False" +default["openstack"]["network"]["use_namespaces"] = "True" +default["openstack"]["network"]["allow_overlapping_ips"] = "True" # use quantum root wrap default["openstack"]["network"]["use_rootwrap"] = true diff --git a/chef/cookbooks/openstack-network/files/default/openvswitch/install.sh b/chef/cookbooks/openstack-network/files/default/openvswitch/install.sh deleted file mode 100644 index 5ec1cd3..0000000 --- a/chef/cookbooks/openstack-network/files/default/openvswitch/install.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -modinfo openvswitch |grep 56D59658C3B9FADCD146B12 -if [ $? -eq 0 ]; then - cd /tmp/openvswitch - - yum localinstall -y /tmp/openvswitch/kmod-openvswitch-1.11.0-1.el6.x86_64.rpm - yum localinstall -y /tmp/openvswitch/openvswitch-1.11.0-1.x86_64.rpm - service openvswitch start - modinfo openvswitch - - cd /tmp - rm -rf /tmp/openvswitch -fi - diff --git a/chef/cookbooks/openstack-network/files/default/openvswitch/kmod-openvswitch-1.11.0-1.el6.x86_64.rpm b/chef/cookbooks/openstack-network/files/default/openvswitch/kmod-openvswitch-1.11.0-1.el6.x86_64.rpm deleted file mode 100644 index 9274b86..0000000 Binary files a/chef/cookbooks/openstack-network/files/default/openvswitch/kmod-openvswitch-1.11.0-1.el6.x86_64.rpm and /dev/null differ diff --git a/chef/cookbooks/openstack-network/files/default/openvswitch/openvswitch-1.11.0-1.x86_64.rpm b/chef/cookbooks/openstack-network/files/default/openvswitch/openvswitch-1.11.0-1.x86_64.rpm deleted file mode 100644 index f9c408b..0000000 Binary files a/chef/cookbooks/openstack-network/files/default/openvswitch/openvswitch-1.11.0-1.x86_64.rpm and /dev/null differ diff --git a/chef/cookbooks/openstack-network/files/default/openvswitch/openvswitch-debuginfo-1.11.0-1.x86_64.rpm b/chef/cookbooks/openstack-network/files/default/openvswitch/openvswitch-debuginfo-1.11.0-1.x86_64.rpm deleted file mode 100644 index c9bccfd..0000000 Binary files a/chef/cookbooks/openstack-network/files/default/openvswitch/openvswitch-debuginfo-1.11.0-1.x86_64.rpm and /dev/null differ diff --git a/chef/cookbooks/openstack-network/recipes/common.rb b/chef/cookbooks/openstack-network/recipes/common.rb index a006843..ea39b50 100644 --- a/chef/cookbooks/openstack-network/recipes/common.rb +++ b/chef/cookbooks/openstack-network/recipes/common.rb @@ -94,8 +94,8 @@ template "/etc/quantum/policy.json" do notifies :restart, "service[quantum-server]", :delayed end -# Add by Sam, CentOS think Qpid as it's default queue, it will auto add qpid -# configuration at /etc/quantum/quantum.conf when invoke quantum-xxx-setup, +# Added by Sam, CentOS think Qpid as it's default queue, it will auto add qpid +# configuration at /etc/quantum/quantum.conf when invoke /usr/bin/quantum-xxx-setup, # because these scripts was hard coded a line as below: # "openstack-config --set ${Q_CONF} DEFAULT # rpc_backend quantum.openstack.common.rpc.impl_qpid" diff --git a/chef/cookbooks/openstack-network/recipes/openvswitch.rb b/chef/cookbooks/openstack-network/recipes/openvswitch.rb index 31bc267..2d9efc2 100644 --- a/chef/cookbooks/openstack-network/recipes/openvswitch.rb +++ b/chef/cookbooks/openstack-network/recipes/openvswitch.rb @@ -31,7 +31,6 @@ main_plugin = node["openstack"]["network"]["interface_driver_map"][driver_name] core_plugin = node["openstack"]["network"]["core_plugin"] if platform?("ubuntu", "debian") - # obtain kernel version for kernel header # installation on ubuntu and debian kernel_ver = node["kernel"]["release"] @@ -59,22 +58,23 @@ end # The current openvswitch package of centos 6.4 cannot create GRE tunnel successfully # The centos 6.4 kernel version is 2.6.32-358.18.1.el6.x86_64 -if platform?(%w(fedora redhat centos)) - remote_directory "/tmp/openvswitch" do - source "openvswitch" - files_owner "root" - files_group "root" - mode "0644" - recursive true - action :create - end +# This code block was deperated because the ovs package was updated. +#if platform?(%w(fedora redhat centos)) +# remote_directory "/tmp/openvswitch" do +# source "openvswitch" +# files_owner "root" +# files_group "root" +# mode "0644" +# recursive true +# action :create +# end - execute "update openvswitch package" do - ignore_failure true - command "chmod +x /tmp/openvswitch/install.sh; sh /tmp/openvswitch/install.sh" - action :run - end -end +# execute "update openvswitch package" do +# ignore_failure true +# command "chmod +x /tmp/openvswitch/install.sh; sh /tmp/openvswitch/install.sh" +# action :run +# end +#end service "quantum-server" do service_name node["openstack"]["network"]["platform"]["quantum_server_service"] diff --git a/chef/roles/os-controller.rb b/chef/roles/os-controller.rb new file mode 100644 index 0000000..7a35f03 --- /dev/null +++ b/chef/roles/os-controller.rb @@ -0,0 +1,17 @@ +name "os-single-controller" +description "Roll-up role for all of the OpenStack Compute services on a single, non-HA controller." +run_list( + 'role[os-dashboard]', + 'role[os-identity]', + 'role[os-identity-api]', + 'role[os-identity-api-admin]', + 'role[os-block-storage-api]', + 'role[os-block-storage-scheduler]', + 'role[os-compute-api]', + 'role[os-compute-api-os-compute]', + 'role[os-compute-cert]', + 'role[os-compute-controller]', + 'role[os-compute-scheduler]', + 'role[os-compute-vncproxy]', + 'role[os-network-server]' + ) diff --git a/chef/roles/os-single-controller.rb b/chef/roles/os-single-controller.rb index 88ad74f..b133e4e 100644 --- a/chef/roles/os-single-controller.rb +++ b/chef/roles/os-single-controller.rb @@ -2,10 +2,10 @@ name "os-single-controller" description "Roll-up role for all of the OpenStack Compute services on a single, non-HA controller." run_list( "role[os-base]", - "role[os-ops-database]", - "role[os-ops-messaging]", +# "role[os-ops-database]", +# "role[os-ops-messaging]", "role[os-identity]", - "role[os-image]", +# "role[os-image]", "role[os-network-server]", "role[os-block-storage]", "role[os-compute-scheduler]",