Skip to content

Commit

Permalink
Release v2.4.0
Browse files Browse the repository at this point in the history
- Convert everything to Ruby 1.9 syntax because I'm tired of people removing trailing commas despite the **massive** warning in the README
- Update to the latest and greatest testing gems and practices
- Remove strainer in favor of a purer solution
- Update `.gitignore` to ignore additional files
- Add more platforms to the `.kitchen.yml`
  • Loading branch information
sethvargo committed Oct 2, 2013
1 parent b284174 commit 166b33a
Show file tree
Hide file tree
Showing 43 changed files with 382 additions and 278 deletions.
4 changes: 0 additions & 4 deletions .cane

This file was deleted.

27 changes: 17 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
*.rbc
.bundle
.config
.yardoc
_yardoc
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
*.tmp
*.bk
*.bkup
.kitchen.local.yml
Berksfile.lock
Gemfile.lock
coverage/
doc/
tmp

.bundle/
.cache/
.kitchen/
.kitchen.local.yml
.vagrant/
.vagrant.d/
bin/
.rspec
tmp/
vendor/
24 changes: 15 additions & 9 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true

platforms:
- name: ubuntu-12.10
- name: ubuntu-13.04
- name: centos-6.4

suites:
- name: append
run_list: ['recipe[fake::append]']
run_list:
- recipe[fake::append]
- name: append_existing
run_list: ['recipe[fake::append_existing]']
run_list:
- recipe[fake::append_existing]
- name: create
run_list: ['recipe[fake::create]']
run_list:
- recipe[fake::create]
- name: create_if_missing
run_list: ['recipe[fake::create_if_missing]']
run_list:
- recipe[fake::create_if_missing]
- name: default
run_list: ['recipe[fake::default]']
run_list:
- recipe[fake::default]
- name: options
run_list: ['recipe[fake::options]']
run_list:
- recipe[fake::options]
- name: unique
run_list:
- recipe[fake::unique]
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
rvm:
- 2.0.0
- 1.9.3
script: bundle exec strainer test --except kitchen
- 2.0.0
script:
- bundle exec foodcritic -f any .
- bundle exec rspec --color --format progress
2 changes: 1 addition & 1 deletion Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ site :opscode
metadata

group :integration do
cookbook 'fake', :path => 'spec/cookbooks/fake'
cookbook 'fake', path: 'test/fixtures/cookbooks/fake'
end
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
CHANGELOG
=========
hostsfile Cookbook CHANGELOG
=======================
This file
is used to list changes made in each version of the hostsfile cookbook.

v2.1.0
------
- Convert everything to Ruby 1.9 syntax because I'm tired of people removing trailing commas despite the **massive** warning in the README: ([#29](https://github.com/customink-webops/hostsfile/issues/29), [#30](https://github.com/customink-webops/hostsfile/issues/30), [#32](https://github.com/customink-webops/hostsfile/issues/32), [#33](https://github.com/customink-webops/hostsfile/issues/33), [#34](https://github.com/customink-webops/hostsfile/issues/34), [#35](https://github.com/customink-webops/hostsfile/issues/35), [#36](https://github.com/customink-webops/hostsfile/issues/36), [#38](https://github.com/customink-webops/hostsfile/issues/38), [#39](https://github.com/customink-webops/hostsfile/issues/39))
- Update to the latest and greatest testing gems and practices
- Remove strainer in favor of a purer solution
- Update `.gitignore` to ignore additional files
- Add more platforms to the `.kitchen.yml`
- Use `converge_by` and support whyruny mode

v2.0.0
------
- Completely manage the hostsfile, ensuring no duplicate entries
Expand Down
15 changes: 5 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
source 'https://rubygems.org'

gem 'chef', '~> 11.6'

group :test do
gem 'cane', '~> 2.6'
gem 'chefspec', '~> 1.3'
gem 'strainer', '~> 3.2'
end
gem 'berkshelf', '~> 2.0'
gem 'chefspec', '~> 2.0'
gem 'foodcritic', '~> 3.0'

group :integration do
gem 'berkshelf', '~> 2.0'
gem 'test-kitchen', '~> 1.0.0.beta'
gem 'kitchen-vagrant', '~> 0.11'
gem 'test-kitchen', '~> 1.0.0.beta'
gem 'kitchen-vagrant', path: '~/Development/kitchen-vagrant' #~> 0.11'
end
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ hostsfile LWRP

`hostsfile` provides an LWRP for managing your `/etc/hosts` (or Windows equivalent) file using Chef.


Requirements
------------
- Chef 11 or higher
- **Ruby 1.9.3 or higher**

**Please stop opening Pull Requests to restore Ruby 1.8 support!** Any of the `1.x.y` series of this cookbook will work with Chef 10 and Ruby 1.8. You can use Opscode's [Omnibus installer](http://www.opscode.com/blog/2012/06/29/omnibus-chef-packaging/) to install Ruby 1.9+ and Seth Chisamore's [Vagrant Omnibus plugin](https://github.com/schisamo/vagrant-omnibus) to get Ruby 1.9+ on your Vagrant box.


Attributes
----------
<table>
Expand All @@ -32,6 +34,12 @@ Attributes
<td><tt>example.com</tt></td>
<td></td>
</tr>
<tr>
<td>unique</td>
<td>remove any existing entries that have the same <tt>hostname</tt></td>
<td><tt>true</tt></td>
<td><tt>false</tt></td>
</tr>
<tr>
<td>aliases</td>
<td>array of aliases for the entry</td>
Expand All @@ -52,25 +60,29 @@ Attributes
</tr>
</table>


Actions
-------
**Please note**: As of `v0.1.2`, specifying a hostname or alias that exists in another entry will remove that hostname from the other entry before adding to this one. For example:
**Please note**: In `v0.1.2`, specifying a hostname or alias that existed in another automatically removed that hostname from the other entry before. In `v2.1.0`, the `unique` option was added to give the user case-by-case control of this behavior. For example, given an `/etc/hosts` file that contains:

1.2.3.4 example.com www.example.com

and
when the Chef recipe below is converged:

```ruby
hostsfile_entry '2.3.4.5' do
hostname 'www.example.com'
unique true
end
```

would yield an /etc/hosts file like this:
then the `/etc/hosts` file will look like this:

1.2.3.4 example.com
2.3.4.5 www.example.com

Not specifying the `unique` parameter will result in duplicate hostsfile entries.

#### `create`
Creates a new hosts file entry. If an entry already exists, it will be overwritten by this one.

Expand Down Expand Up @@ -141,6 +153,7 @@ end

This will remove the entry for `1.2.3.4`.


Usage
-----
If you're using [Berkshelf](http://berkshelf.com/), just add `hostsfile` to your `Berksfile`:
Expand All @@ -160,6 +173,7 @@ Have any other cookbooks *depend* on hostsfile by editing editing the `metadata.
depends 'hostsfile'
```


Priority
--------
Priority is a relatively new addition to the cookbook. It gives you the ability to (somewhat) specify the relative order of entries. By default, the priority is calculated for you as follows:
Expand All @@ -170,19 +184,22 @@ Priority is a relatively new addition to the cookbook. It gives you the ability

However, you can override it using the `priority` option.


Contributing
------------
1. Fork the project
2. Create a feature branch corresponding to you change
3. Commit and test thoroughly
4. Create a Pull Request on github
- ensure you add a detailed description of your changes

License and Authors
-------------------

License & Authors
-----------------
- Author:: Seth Vargo ([email protected])

Copyright 2012 Seth Vargo, CustomInk, LLC
```text
Copyright 2012-2013, Seth Vargo
Copyright 2012, CustomInk, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -195,3 +212,4 @@ 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.
```
3 changes: 0 additions & 3 deletions Strainerfile

This file was deleted.

13 changes: 7 additions & 6 deletions libraries/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Cookbook:: hostsfile
# Library:: entry
#
# Copyright 2012, Seth Vargo, CustomInk, LCC
# Copyright 2012-2013, Seth Vargo
# Copyright 2012, CustomInk, LCC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,11 +44,11 @@ def parse(line)
return nil if entries.nil? || entries.empty?

return self.new(
:ip_address => entries[0],
:hostname => entries[1],
:aliases => entries[2..-1],
:comment => comment,
:priority => priority
ip_address: entries[0],
hostname: entries[1],
aliases: entries[2..-1],
comment: comment,
priority: priority,
)
end

Expand Down
Loading

0 comments on commit 166b33a

Please sign in to comment.