guard-strainer 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +3 -0
- data/CONTRIBUTING.md +29 -0
- data/Gemfile +12 -0
- data/Guardfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +34 -0
- data/guard-strainer.gemspec +25 -0
- data/lib/guard/strainer.rb +112 -0
- data/lib/guard/strainer/runner.rb +48 -0
- data/lib/guard/strainer/templates/Guardfile +7 -0
- data/lib/guard/strainer/version.rb +5 -0
- data/spec/fixtures/cookbooks/git/.gitignore +14 -0
- data/spec/fixtures/cookbooks/git/.kitchen.yml +46 -0
- data/spec/fixtures/cookbooks/git/Berksfile +8 -0
- data/spec/fixtures/cookbooks/git/CHANGELOG.md +76 -0
- data/spec/fixtures/cookbooks/git/CONTRIBUTING +29 -0
- data/spec/fixtures/cookbooks/git/Gemfile +3 -0
- data/spec/fixtures/cookbooks/git/LICENSE +201 -0
- data/spec/fixtures/cookbooks/git/README.md +115 -0
- data/spec/fixtures/cookbooks/git/TESTING.md +25 -0
- data/spec/fixtures/cookbooks/git/attributes/default.rb +40 -0
- data/spec/fixtures/cookbooks/git/metadata.rb +35 -0
- data/spec/fixtures/cookbooks/git/recipes/default.rb +46 -0
- data/spec/fixtures/cookbooks/git/recipes/server.rb +57 -0
- data/spec/fixtures/cookbooks/git/recipes/source.rb +49 -0
- data/spec/fixtures/cookbooks/git/recipes/windows.rb +32 -0
- data/spec/fixtures/cookbooks/git/templates/default/git-xinetd.d.erb +10 -0
- data/spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +2 -0
- data/spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-run.erb +3 -0
- data/spec/fixtures/cookbooks/sudo/.chef/knife.rb +1 -0
- data/spec/fixtures/cookbooks/sudo/.gitignore +14 -0
- data/spec/fixtures/cookbooks/sudo/.kitchen.yml +35 -0
- data/spec/fixtures/cookbooks/sudo/.rspec +2 -0
- data/spec/fixtures/cookbooks/sudo/Berksfile +8 -0
- data/spec/fixtures/cookbooks/sudo/CHANGELOG.md +63 -0
- data/spec/fixtures/cookbooks/sudo/CONTRIBUTING.md +257 -0
- data/spec/fixtures/cookbooks/sudo/Gemfile +12 -0
- data/spec/fixtures/cookbooks/sudo/LICENSE +201 -0
- data/spec/fixtures/cookbooks/sudo/README.md +229 -0
- data/spec/fixtures/cookbooks/sudo/TESTING.md +25 -0
- data/spec/fixtures/cookbooks/sudo/attributes/default.rb +25 -0
- data/spec/fixtures/cookbooks/sudo/files/default/README +17 -0
- data/spec/fixtures/cookbooks/sudo/metadata.rb +46 -0
- data/spec/fixtures/cookbooks/sudo/providers/default.rb +135 -0
- data/spec/fixtures/cookbooks/sudo/recipes/default.rb +54 -0
- data/spec/fixtures/cookbooks/sudo/resources/default.rb +38 -0
- data/spec/fixtures/cookbooks/sudo/templates/default/sudoer.erb +6 -0
- data/spec/fixtures/cookbooks/sudo/templates/default/sudoers.erb +26 -0
- data/spec/fixtures/cookbooks/tmux/.chef/knife.rb +2 -0
- data/spec/fixtures/cookbooks/tmux/.gitignore +1 -0
- data/spec/fixtures/cookbooks/tmux/.travis.yml +7 -0
- data/spec/fixtures/cookbooks/tmux/CHANGELOG.md +39 -0
- data/spec/fixtures/cookbooks/tmux/CONTRIBUTING.md +257 -0
- data/spec/fixtures/cookbooks/tmux/Gemfile +6 -0
- data/spec/fixtures/cookbooks/tmux/LICENSE +201 -0
- data/spec/fixtures/cookbooks/tmux/README.md +52 -0
- data/spec/fixtures/cookbooks/tmux/Rakefile +34 -0
- data/spec/fixtures/cookbooks/tmux/attributes/default.rb +15 -0
- data/spec/fixtures/cookbooks/tmux/metadata.rb +7 -0
- data/spec/fixtures/cookbooks/tmux/recipes/default.rb +33 -0
- data/spec/fixtures/cookbooks/tmux/recipes/package.rb +5 -0
- data/spec/fixtures/cookbooks/tmux/recipes/source.rb +45 -0
- data/spec/fixtures/cookbooks/tmux/templates/default/tmux.conf.erb +35 -0
- data/spec/fixtures/cookbooks/tmux/test/kitchen/Kitchenfile +6 -0
- data/spec/guard/strainer/runner_spec.rb +66 -0
- data/spec/guard/strainer_spec.rb +114 -0
- data/spec/spec_helper.rb +24 -0
- metadata +213 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: sudo
|
3
|
+
# Attribute File:: default
|
4
|
+
#
|
5
|
+
# Copyright 2008-2011, Opscode, Inc.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
default['authorization']['sudo']['groups'] = []
|
21
|
+
default['authorization']['sudo']['users'] = []
|
22
|
+
default['authorization']['sudo']['passwordless'] = false
|
23
|
+
default['authorization']['sudo']['include_sudoers_d'] = false
|
24
|
+
default['authorization']['sudo']['agent_forwarding'] = false
|
25
|
+
default['authorization']['sudo']['sudoers_defaults'] = ['!lecture,tty_tickets,!fqdn']
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on
|
3
|
+
# installation of the package now includes the directive:
|
4
|
+
#
|
5
|
+
# #includedir /etc/sudoers.d
|
6
|
+
#
|
7
|
+
# This will cause sudo to read and parse any files in the /etc/sudoers.d
|
8
|
+
# directory that do not end in '~' or contain a '.' character.
|
9
|
+
#
|
10
|
+
# Note that there must be at least one file in the sudoers.d directory (this
|
11
|
+
# one will do), and all files in this directory should be mode 0440.
|
12
|
+
#
|
13
|
+
# Note also, that because sudoers contents can vary widely, no attempt is
|
14
|
+
# made to add this directive to existing sudoers files on upgrade. Feel free
|
15
|
+
# to add the above directive to the end of your /etc/sudoers file to enable
|
16
|
+
# this functionality for existing installations if you wish!
|
17
|
+
#
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name 'sudo'
|
2
|
+
maintainer 'Opscode, Inc.'
|
3
|
+
maintainer_email 'cookbooks@opscode.com'
|
4
|
+
license 'Apache 2.0'
|
5
|
+
description 'Installs sudo and configures /etc/sudoers'
|
6
|
+
version '2.1.5'
|
7
|
+
|
8
|
+
recipe 'sudo', 'Installs sudo and configures /etc/sudoers'
|
9
|
+
|
10
|
+
%w{redhat centos fedora ubuntu debian freebsd}.each do |os|
|
11
|
+
supports os
|
12
|
+
end
|
13
|
+
|
14
|
+
attribute 'authorization',
|
15
|
+
:display_name => 'Authorization',
|
16
|
+
:description => 'Hash of Authorization attributes',
|
17
|
+
:type => 'hash'
|
18
|
+
|
19
|
+
attribute 'authorization/sudo',
|
20
|
+
:display_name => 'Authorization Sudoers',
|
21
|
+
:description => 'Hash of Authorization/Sudo attributes',
|
22
|
+
:type => 'hash'
|
23
|
+
|
24
|
+
attribute 'authorization/sudo/users',
|
25
|
+
:display_name => 'Sudo Users',
|
26
|
+
:description => 'Users who are allowed sudo ALL',
|
27
|
+
:type => 'array',
|
28
|
+
:default => ''
|
29
|
+
|
30
|
+
attribute 'authorization/sudo/groups',
|
31
|
+
:display_name => 'Sudo Groups',
|
32
|
+
:description => 'Groups who are allowed sudo ALL',
|
33
|
+
:type => 'array',
|
34
|
+
:default => ''
|
35
|
+
|
36
|
+
attribute 'authorization/sudo/passwordless',
|
37
|
+
:display_name => 'Passwordless Sudo',
|
38
|
+
:description => '',
|
39
|
+
:type => 'string',
|
40
|
+
:default => 'false'
|
41
|
+
|
42
|
+
attribute 'authorization/sudo/include_sudoers_d',
|
43
|
+
:display_name => 'Include sudoers.d',
|
44
|
+
:description => 'Whether to create the sudoers.d includedir',
|
45
|
+
:type => 'string',
|
46
|
+
:default => 'false'
|
@@ -0,0 +1,135 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
|
3
|
+
# Author:: Seth Vargo (<sethvargo@gmail.com>)
|
4
|
+
# Cookbook Name:: sudo
|
5
|
+
# Provider:: default
|
6
|
+
#
|
7
|
+
# Copyright 2011, Bryan w. Berry
|
8
|
+
# Copyright 2012, Seth Vargo
|
9
|
+
#
|
10
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
# you may not use this file except in compliance with the License.
|
12
|
+
# You may obtain a copy of the License at
|
13
|
+
#
|
14
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
#
|
16
|
+
# Unless required by applicable law or agreed to in writing, software
|
17
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
# See the License for the specific language governing permissions and
|
20
|
+
# limitations under the License.
|
21
|
+
#
|
22
|
+
|
23
|
+
# This LWRP supports whyrun mode
|
24
|
+
def whyrun_supported?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
# Ensure that the inputs are valid (we cannot just use the resource for this)
|
29
|
+
def check_inputs(user, group, foreign_template, foreign_vars)
|
30
|
+
# if group, user, and template are nil, throw an exception
|
31
|
+
if user == nil && group == nil && foreign_template == nil
|
32
|
+
Chef::Application.fatal!('You must provide a user, group, or template!')
|
33
|
+
elsif user != nil && group != nil && template != nil
|
34
|
+
Chef::Application.fatal!('You cannot specify user, group, and template!')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Validate the given resource (template) by writing it out to a file and then
|
39
|
+
# ensuring that file's contents pass `visudo -c`
|
40
|
+
def validate_fragment!(resource)
|
41
|
+
file = Tempfile.new('sudoer')
|
42
|
+
|
43
|
+
begin
|
44
|
+
file.write(capture(resource))
|
45
|
+
|
46
|
+
cmd = Mixlib::ShellOut.new("visudo -cf #{file.path}").run_command
|
47
|
+
unless cmd.exitstatus == 0
|
48
|
+
Chef::Log.error("Fragment validation failed: \n\n")
|
49
|
+
Chef::Log.error(file.read)
|
50
|
+
Chef::Application.fatal!("Template #{file.path} failed fragment validation!")
|
51
|
+
end
|
52
|
+
ensure
|
53
|
+
file.close
|
54
|
+
file.unlink
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Render a single sudoer template. This method has two modes:
|
59
|
+
# 1. using the :template option - the user can specify a template
|
60
|
+
# that exists in the local cookbook for writing out the attributes
|
61
|
+
# 2. using the built-in template (recommended) - simply pass the
|
62
|
+
# desired variables to the method and the correct template will be
|
63
|
+
# written out for the user
|
64
|
+
def render_sudoer
|
65
|
+
if new_resource.template
|
66
|
+
Chef::Log.debug('Template attribute provided, all other attributes ignored.')
|
67
|
+
|
68
|
+
resource = template "/etc/sudoers.d/#{new_resource.name}" do
|
69
|
+
source new_resource.template
|
70
|
+
owner 'root'
|
71
|
+
group 'root'
|
72
|
+
mode '0440'
|
73
|
+
variables new_resource.variables
|
74
|
+
action :nothing
|
75
|
+
end
|
76
|
+
else
|
77
|
+
sudoer = new_resource.user || "%#{new_resource.group}".squeeze('%')
|
78
|
+
|
79
|
+
resource = template "/etc/sudoers.d/#{new_resource.name}" do
|
80
|
+
source 'sudoer.erb'
|
81
|
+
cookbook 'sudo'
|
82
|
+
owner 'root'
|
83
|
+
group 'root'
|
84
|
+
mode '0440'
|
85
|
+
variables :sudoer => sudoer,
|
86
|
+
:host => new_resource.host,
|
87
|
+
:runas => new_resource.runas,
|
88
|
+
:nopasswd => new_resource.nopasswd,
|
89
|
+
:commands => new_resource.commands
|
90
|
+
action :nothing
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Ensure that, adding this sudoer, would not break sudo
|
95
|
+
validate_fragment!(resource)
|
96
|
+
|
97
|
+
resource.run_action(:create)
|
98
|
+
new_resource.updated_by_last_action(true) if resource.updated_by_last_action?
|
99
|
+
end
|
100
|
+
|
101
|
+
# Default action - install a single sudoer
|
102
|
+
action :install do
|
103
|
+
render_sudoer
|
104
|
+
end
|
105
|
+
|
106
|
+
# Removes a user from the sudoers group
|
107
|
+
action :remove do
|
108
|
+
resource = file "/etc/sudoers.d/#{new_resource.name}" do
|
109
|
+
action :nothing
|
110
|
+
end
|
111
|
+
resource.run_action(:delete)
|
112
|
+
new_resource.updated_by_last_action(true) if resource.updated_by_last_action?
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
# Capture a template to a string
|
117
|
+
def capture(template)
|
118
|
+
context = {}
|
119
|
+
context.merge!(template.variables)
|
120
|
+
context[:node] = node
|
121
|
+
|
122
|
+
eruby = Erubis::Eruby.new(::File.read(template_location(template)))
|
123
|
+
return eruby.evaluate(context)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Find the template
|
127
|
+
def template_location(template)
|
128
|
+
if template.local
|
129
|
+
template.source
|
130
|
+
else
|
131
|
+
context = template.instance_variable_get('@run_context')
|
132
|
+
cookbook = context.cookbook_collection[template.cookbook || template.cookbook_name]
|
133
|
+
cookbook.preferred_filename_on_disk_location(node, :templates, template.source)
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: sudo
|
3
|
+
# Recipe:: default
|
4
|
+
#
|
5
|
+
# Copyright 2008-2011, Opscode, Inc.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
package 'sudo' do
|
21
|
+
action :install
|
22
|
+
end
|
23
|
+
|
24
|
+
if node['authorization']['sudo']['include_sudoers_d']
|
25
|
+
directory '/etc/sudoers.d' do
|
26
|
+
mode '0755'
|
27
|
+
owner 'root'
|
28
|
+
group 'root'
|
29
|
+
action :create
|
30
|
+
end
|
31
|
+
|
32
|
+
cookbook_file '/etc/sudoers.d/README' do
|
33
|
+
source 'README'
|
34
|
+
mode '0440'
|
35
|
+
owner 'root'
|
36
|
+
group 'root'
|
37
|
+
action :create
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
template '/etc/sudoers' do
|
42
|
+
source 'sudoers.erb'
|
43
|
+
mode '0440'
|
44
|
+
owner 'root'
|
45
|
+
group platform?('freebsd') ? 'wheel' : 'root'
|
46
|
+
variables(
|
47
|
+
:sudoers_groups => node['authorization']['sudo']['groups'],
|
48
|
+
:sudoers_users => node['authorization']['sudo']['users'],
|
49
|
+
:passwordless => node['authorization']['sudo']['passwordless'],
|
50
|
+
:include_sudoers_d => node['authorization']['sudo']['include_sudoers_d'],
|
51
|
+
:agent_forwarding => node['authorization']['sudo']['agent_forwarding'],
|
52
|
+
:sudoers_defaults => node['authorization']['sudo']['sudoers_defaults']
|
53
|
+
)
|
54
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
|
3
|
+
# Cookbook Name:: sudo
|
4
|
+
# Resource:: default
|
5
|
+
#
|
6
|
+
# Copyright 2011, Bryan w. Berry
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
actions :install, :remove
|
21
|
+
default_action :install
|
22
|
+
|
23
|
+
attribute :user, :kind_of => String, :default => nil
|
24
|
+
attribute :group, :kind_of => String, :default => nil
|
25
|
+
attribute :commands, :kind_of => Array, :default => ['ALL']
|
26
|
+
attribute :host, :kind_of => String, :default => 'ALL'
|
27
|
+
attribute :runas, :kind_of => String, :default => 'ALL'
|
28
|
+
attribute :nopasswd, :equal_to => [true, false], :default => false
|
29
|
+
attribute :template, :regex => /^[a-z_]+.erb$/, :default => nil
|
30
|
+
attribute :variables, :kind_of => Hash, :default => nil
|
31
|
+
|
32
|
+
# Set default for the supports attribute in initializer since it is
|
33
|
+
# a 'reserved' attribute name
|
34
|
+
def initialize(*args)
|
35
|
+
super
|
36
|
+
@action = :install
|
37
|
+
@supports = { :report => true, :exception => true }
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This file is managed by Chef.
|
2
|
+
# Do NOT modify this file directly.
|
3
|
+
|
4
|
+
<% @sudoers_defaults.each do |defaults| -%>
|
5
|
+
Defaults <%= defaults %>
|
6
|
+
<% end -%>
|
7
|
+
<% if @agent_forwarding -%>
|
8
|
+
Defaults env_keep+=SSH_AUTH_SOCK
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
# User privilege specification
|
12
|
+
root ALL=(ALL) ALL
|
13
|
+
|
14
|
+
<% @sudoers_users.each do |user| -%>
|
15
|
+
<%= user %> ALL=(ALL) <%= "NOPASSWD:" if @passwordless %>ALL
|
16
|
+
<% end -%>
|
17
|
+
|
18
|
+
# Members of the sysadmin group may gain root privileges
|
19
|
+
%sysadmin ALL=(ALL) <%= "NOPASSWD:" if @passwordless %>ALL
|
20
|
+
|
21
|
+
<% @sudoers_groups.each do |group| -%>
|
22
|
+
# Members of the group '<%= group %>' may gain root privileges
|
23
|
+
%<%= group %> ALL=(ALL) <%= "NOPASSWD:" if @passwordless %>ALL
|
24
|
+
<% end -%>
|
25
|
+
|
26
|
+
<%= '#includedir /etc/sudoers.d' if @include_sudoers_d %>
|
@@ -0,0 +1 @@
|
|
1
|
+
tmp
|
@@ -0,0 +1,39 @@
|
|
1
|
+
## v1.3.0:
|
2
|
+
|
3
|
+
### Improvement
|
4
|
+
|
5
|
+
- [COOK-2547]: Add more options to tmux.conf template
|
6
|
+
|
7
|
+
## v1.2.2:
|
8
|
+
|
9
|
+
The repository didn't have pushed commits, and so the following
|
10
|
+
changes from earlier-than-latest versions wouldn't be available on the
|
11
|
+
community site. We're releasing 1.2.2 to correct this.
|
12
|
+
|
13
|
+
* [COOK-1841] - recipe downloads tmux tar everytime, even if its
|
14
|
+
installed
|
15
|
+
|
16
|
+
## v1.2.0:
|
17
|
+
|
18
|
+
* [COOK-1649] - Typo in tmux default attributes
|
19
|
+
* [COOK-1652] - Missing deps for building tmux on centos
|
20
|
+
* [COOK-1756] - Allow tmux to be installed via source or package based
|
21
|
+
on attribute
|
22
|
+
|
23
|
+
## v1.1.2:
|
24
|
+
|
25
|
+
* [COOK-1841] - recipe downloads tmux tar everytime, even if its
|
26
|
+
installed
|
27
|
+
|
28
|
+
## v1.1.0:
|
29
|
+
|
30
|
+
* Added test-kitchen support
|
31
|
+
|
32
|
+
## v1.0.1:
|
33
|
+
|
34
|
+
* Add test kitchen support (test directory not included in release to community site)
|
35
|
+
* [COOK-1366] - default config template, TravisCI and CentOS support
|
36
|
+
|
37
|
+
## v1.0.0:
|
38
|
+
|
39
|
+
* Initial Release
|
@@ -0,0 +1,257 @@
|
|
1
|
+
# Contributing to Opscode Cookbooks
|
2
|
+
|
3
|
+
We are glad you want to contribute to Opscode Cookbooks! The first
|
4
|
+
step is the desire to improve the project.
|
5
|
+
|
6
|
+
You can find the answers to additional frequently asked questions
|
7
|
+
[on the wiki](http://wiki.opscode.com/display/chef/How+to+Contribute).
|
8
|
+
|
9
|
+
You can find additional information about
|
10
|
+
[contributing to cookbooks](http://wiki.opscode.com/display/chef/How+to+Contribute+to+Opscode+Cookbooks)
|
11
|
+
on the wiki as well.
|
12
|
+
|
13
|
+
## Quick-contribute
|
14
|
+
|
15
|
+
* Create an account on our [bug tracker](http://tickets.opscode.com)
|
16
|
+
* Sign our contributor agreement (CLA)
|
17
|
+
[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L)
|
18
|
+
(keep reading if you're contributing on behalf of your employer)
|
19
|
+
* Create a ticket for your change on the
|
20
|
+
[bug tracker](http://tickets.opscode.com)
|
21
|
+
* Link to your patch as a rebased git branch or pull request from the
|
22
|
+
ticket
|
23
|
+
* Resolve the ticket as fixed
|
24
|
+
|
25
|
+
We regularly review contributions and will get back to you if we have
|
26
|
+
any suggestions or concerns.
|
27
|
+
|
28
|
+
## The Apache License and the CLA/CCLA
|
29
|
+
|
30
|
+
Licensing is very important to open source projects, it helps ensure
|
31
|
+
the software continues to be available under the terms that the author
|
32
|
+
desired. Chef uses the Apache 2.0 license to strike a balance between
|
33
|
+
open contribution and allowing you to use the software however you
|
34
|
+
would like to.
|
35
|
+
|
36
|
+
The license tells you what rights you have that are provided by the
|
37
|
+
copyright holder. It is important that the contributor fully
|
38
|
+
understands what rights they are licensing and agrees to them.
|
39
|
+
Sometimes the copyright holder isn't the contributor, most often when
|
40
|
+
the contributor is doing work for a company.
|
41
|
+
|
42
|
+
To make a good faith effort to ensure these criteria are met, Opscode
|
43
|
+
requires a Contributor License Agreement (CLA) or a Corporate
|
44
|
+
Contributor License Agreement (CCLA) for all contributions. This is
|
45
|
+
without exception due to some matters not being related to copyright
|
46
|
+
and to avoid having to continually check with our lawyers about small
|
47
|
+
patches.
|
48
|
+
|
49
|
+
It only takes a few minutes to complete a CLA, and you retain the
|
50
|
+
copyright to your contribution.
|
51
|
+
|
52
|
+
You can complete our contributor agreement (CLA)
|
53
|
+
[ online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L).
|
54
|
+
If you're contributing on behalf of your employer, have your employer
|
55
|
+
fill out our
|
56
|
+
[Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856)
|
57
|
+
instead.
|
58
|
+
|
59
|
+
## Ticket Tracker (JIRA)
|
60
|
+
|
61
|
+
The [ticket tracker](http://tickets.opscode.com) is the most important
|
62
|
+
documentation for the code base. It provides significant historical
|
63
|
+
information, such as:
|
64
|
+
|
65
|
+
* Which release a bug fix is included in
|
66
|
+
* Discussion regarding the design and merits of features
|
67
|
+
* Error output to aid in finding similar bugs
|
68
|
+
|
69
|
+
Each ticket should aim to fix one bug or add one feature.
|
70
|
+
|
71
|
+
## Using git
|
72
|
+
|
73
|
+
You can get a quick copy of the repository for this cookbook by
|
74
|
+
running `git clone
|
75
|
+
git://github.com/opscode-coobkooks/COOKBOOKNAME.git`.
|
76
|
+
|
77
|
+
For collaboration purposes, it is best if you create a Github account
|
78
|
+
and fork the repository to your own account. Once you do this you will
|
79
|
+
be able to push your changes to your Github repository for others to
|
80
|
+
see and use.
|
81
|
+
|
82
|
+
If you have another repository in your GitHub account named the same
|
83
|
+
as the cookbook, we suggest you suffix the repository with -cookbook.
|
84
|
+
|
85
|
+
### Branches and Commits
|
86
|
+
|
87
|
+
You should submit your patch as a git branch named after the ticket,
|
88
|
+
such as COOK-1337. This is called a _topic branch_ and allows users to
|
89
|
+
associate a branch of code with the ticket.
|
90
|
+
|
91
|
+
It is a best practice to have your commit message have a _summary
|
92
|
+
line_ that includes the ticket number, followed by an empty line and
|
93
|
+
then a brief description of the commit. This also helps other
|
94
|
+
contributors understand the purpose of changes to the code.
|
95
|
+
|
96
|
+
[COOK-1757] - platform_family and style
|
97
|
+
|
98
|
+
* use platform_family for platform checking
|
99
|
+
* update notifies syntax to "resource_type[resource_name]" instead of
|
100
|
+
resources() lookup
|
101
|
+
* COOK-692 - delete config files dropped off by packages in conf.d
|
102
|
+
* dropped debian 4 support because all other platforms have the same
|
103
|
+
values, and it is older than "old stable" debian release
|
104
|
+
|
105
|
+
Remember that not all users use Chef in the same way or on the same
|
106
|
+
operating systems as you, so it is helpful to be clear about your use
|
107
|
+
case and change so they can understand it even when it doesn't apply
|
108
|
+
to them.
|
109
|
+
|
110
|
+
### Github and Pull Requests
|
111
|
+
|
112
|
+
All of Opscode's open source cookbook projects are available on
|
113
|
+
[Github](http://www.github.com/opscode-cookbooks).
|
114
|
+
|
115
|
+
We don't require you to use Github, and we will even take patch diffs
|
116
|
+
attached to tickets on the tracker. However Github has a lot of
|
117
|
+
convenient features, such as being able to see a diff of changes
|
118
|
+
between a pull request and the main repository quickly without
|
119
|
+
downloading the branch.
|
120
|
+
|
121
|
+
If you do choose to use a pull request, please provide a link to the
|
122
|
+
pull request from the ticket __and__ a link to the ticket from the
|
123
|
+
pull request. Because pull requests only have two states, open and
|
124
|
+
closed, we can't easily filter pull requests that are waiting for a
|
125
|
+
reply from the author for various reasons.
|
126
|
+
|
127
|
+
### More information
|
128
|
+
|
129
|
+
Additional help with git is available on the
|
130
|
+
[Working with Git](http://wiki.opscode.com/display/chef/Working+with+Git)
|
131
|
+
wiki page.
|
132
|
+
|
133
|
+
## Functional and Unit Tests
|
134
|
+
|
135
|
+
This cookbook is set up to run tests under
|
136
|
+
[Opscode's test-kitchen](https://github.com/opscode/test-kitchen). It
|
137
|
+
uses minitest-chef to run integration tests after the node has been
|
138
|
+
converged to verify that the state of the node.
|
139
|
+
|
140
|
+
Test kitchen should run completely without exception using the default
|
141
|
+
[baseboxes provided by Opscode](https://github.com/opscode/bento).
|
142
|
+
Because Test Kitchen creates VirtualBox machines and runs through
|
143
|
+
every configuration in the Kitchenfile, it may take some time for
|
144
|
+
these tests to complete.
|
145
|
+
|
146
|
+
If your changes are only for a specific recipe, run only its
|
147
|
+
configuration with Test Kitchen. If you are adding a new recipe, or
|
148
|
+
other functionality such as a LWRP or definition, please add
|
149
|
+
appropriate tests and ensure they run with Test Kitchen.
|
150
|
+
|
151
|
+
If any don't pass, investigate them before submitting your patch.
|
152
|
+
|
153
|
+
Any new feature should have unit tests included with the patch with
|
154
|
+
good code coverage to help protect it from future changes. Similarly,
|
155
|
+
patches that fix a bug or regression should have a _regression test_.
|
156
|
+
Simply put, this is a test that would fail without your patch but
|
157
|
+
passes with it. The goal is to ensure this bug doesn't regress in the
|
158
|
+
future. Consider a regular expression that doesn't match a certain
|
159
|
+
pattern that it should, so you provide a patch and a test to ensure
|
160
|
+
that the part of the code that uses this regular expression works as
|
161
|
+
expected. Later another contributor may modify this regular expression
|
162
|
+
in a way that breaks your use cases. The test you wrote will fail,
|
163
|
+
signalling to them to research your ticket and use case and accounting
|
164
|
+
for it.
|
165
|
+
|
166
|
+
If you need help writing tests, please ask on the Chef Developer's
|
167
|
+
mailing list, or the #chef-hacking IRC channel.
|
168
|
+
|
169
|
+
## Code Review
|
170
|
+
|
171
|
+
Opscode regularly reviews code contributions and provides suggestions
|
172
|
+
for improvement in the code itself or the implementation.
|
173
|
+
|
174
|
+
We find contributions by searching the ticket tracker for _resolved_
|
175
|
+
tickets with a status of _fixed_. If we have feedback we will reopen
|
176
|
+
the ticket and you should resolve it again when you've made the
|
177
|
+
changes or have a response to our feedback. When we believe the patch
|
178
|
+
is ready to be merged, we will tag the _Code Reviewed_ field with
|
179
|
+
_Reviewed_.
|
180
|
+
|
181
|
+
Depending on the project, these tickets are then merged within a week
|
182
|
+
or two, depending on the current release cycle.
|
183
|
+
|
184
|
+
## Release Cycle
|
185
|
+
|
186
|
+
The versioning for Opscode Cookbook projects is X.Y.Z.
|
187
|
+
|
188
|
+
* X is a major release, which may not be fully compatible with prior
|
189
|
+
major releases
|
190
|
+
* Y is a minor release, which adds both new features and bug fixes
|
191
|
+
* Z is a patch release, which adds just bug fixes
|
192
|
+
|
193
|
+
A released version of a cookbook will end in an even number, e.g.
|
194
|
+
"1.2.4" or "0.8.0". When development for the next version of the
|
195
|
+
cookbook begins, the "Z" patch number is incremented to the next odd
|
196
|
+
number, however the next release of the cookbook may be a major or
|
197
|
+
minor incrementing version.
|
198
|
+
|
199
|
+
Releases of Opscode's cookbooks are usually announced on the Chef user
|
200
|
+
mailing list. Releases of several cookbooks may be batched together
|
201
|
+
and announced on the [Opscode Blog](http://www.opscode.com/blog).
|
202
|
+
|
203
|
+
## Working with the community
|
204
|
+
|
205
|
+
These resources will help you learn more about Chef and connect to
|
206
|
+
other members of the Chef community:
|
207
|
+
|
208
|
+
* [chef](http://lists.opscode.com/sympa/info/chef) and
|
209
|
+
[chef-dev](http://lists.opscode.com/sympa/info/chef-dev) mailing
|
210
|
+
lists
|
211
|
+
* #chef and #chef-hacking IRC channels on irc.freenode.net
|
212
|
+
* [Community Cookbook site](http://community.opscode.com)
|
213
|
+
* [Chef wiki](http://wiki.opscode.com/display/chef)
|
214
|
+
* Opscode Chef [product page](http://www.opscode.com/chef)
|
215
|
+
|
216
|
+
|
217
|
+
## Cookbook Contribution Do's and Don't's
|
218
|
+
|
219
|
+
Please do include tests for your contribution. If you need help, ask
|
220
|
+
on the
|
221
|
+
[chef-dev mailing list](http://lists.opscode.com/sympa/info/chef-dev)
|
222
|
+
or the
|
223
|
+
[#chef-hacking IRC channel](http://community.opscode.com/chat/chef-hacking).
|
224
|
+
Not all platforms that a cookbook supports may be supported by Test
|
225
|
+
Kitchen. Please provide evidence of testing your contribution if it
|
226
|
+
isn't trivial so we don't have to duplicate effort in testing. Chef
|
227
|
+
10.14+ "doc" formatted output is sufficient.
|
228
|
+
|
229
|
+
Please do indicate new platform (families) or platform versions in the
|
230
|
+
commit message, and update the relevant ticket.
|
231
|
+
|
232
|
+
If a contribution adds new platforms or platform versions, indicate
|
233
|
+
such in the body of the commit message(s), and update the relevant
|
234
|
+
COOK ticket. When writing commit messages, it is helpful for others if
|
235
|
+
you indicate the COOK ticket. For example:
|
236
|
+
|
237
|
+
git commit -m '[COOK-1041] - Updated pool resource to correctly
|
238
|
+
delete.'
|
239
|
+
|
240
|
+
Please do use [foodcritic](http://acrmp.github.com/foodcritic) to
|
241
|
+
lint-check the cookbook. Except FC007, it should pass all correctness
|
242
|
+
rules. FC007 is okay as long as the dependent cookbooks are *required*
|
243
|
+
for the default behavior of the cookbook, such as to support an
|
244
|
+
uncommon platform, secondary recipe, etc.
|
245
|
+
|
246
|
+
Please do ensure that your changes do not break or modify behavior for
|
247
|
+
other platforms supported by the cookbook. For example if your changes
|
248
|
+
are for Debian, make sure that they do not break on CentOS.
|
249
|
+
|
250
|
+
Please do not modify the version number in the metadata.rb, Opscode
|
251
|
+
will select the appropriate version based on the release cycle
|
252
|
+
information above.
|
253
|
+
|
254
|
+
Please do not update the CHANGELOG.md for a new version. Not all
|
255
|
+
changes to a cookbook may be merged and released in the same versions.
|
256
|
+
Opscode will update the CHANGELOG.md when releasing a new version of
|
257
|
+
the cookbook.
|