chef-vault 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,118 @@
1
+ # Contributing to Chef-Vault
2
+
3
+ We welcome contributions. Your patch is part of a vibrant open source
4
+ community which makes Chef-Vault great. These guidelines will help your pull
5
+ request to be merged sooner.
6
+
7
+ ### Create an Issue
8
+
9
+ Each pull request should have a corresponding [Chef-Vault GitHub
10
+ issue](https://github.com/moserke/chef-vault/issues?state=open). Search the
11
+ issue list to make sure someone hasn't already submitted a pull request to fix
12
+ your issue. If not, please create a new issue.
13
+
14
+ Later, you'll create a feature branch with this issue number.
15
+
16
+ ### Fork the Repo
17
+
18
+ Fork the Chef-Vault project and check out your copy. See this [GitHub
19
+ guide](https://help.github.com/articles/fork-a-repo) for more info.
20
+
21
+ ```bash
22
+ $ git clone https://github.com/<username>/chef-vault.git
23
+ $ cd chef-vault
24
+ $ git remote add upstream https://github.com/moserke/chef-vault.git
25
+ ```
26
+
27
+ ### Create a Local Feature Branch
28
+
29
+ Create a feature branch and start hacking:
30
+
31
+ ```
32
+ $ git checkout -b my-feature-branch
33
+ ```
34
+
35
+ ### Code
36
+
37
+ Please follow the [Ruby Style
38
+ Guide](https://github.com/bbatsov/ruby-style-guide) when writing Ruby code for
39
+ Chef-Vault.
40
+
41
+ ### Commit
42
+
43
+ Make sure git knows your name and email address:
44
+
45
+ ```bash
46
+ $ git config --global user.name "Jane Doe"
47
+ $ git config --global user.email "jane.doe@example.com"
48
+ ```
49
+
50
+ Writing good commit messages is important. A commit message should describe what
51
+ changed and why. Follow these guidelines when writing one:
52
+
53
+ 1. The first line should be 50 or fewer characters and contain a short
54
+ description of the change.
55
+ If this commit fixes/closes an issue, prefix the commit message
56
+ like this: "Fixes #7: ". Here's a complete example:
57
+ `Fixes #9: Use getters instead of instance vars`
58
+ 2. Keep the second line blank.
59
+ 3. Wrap all other lines at 72 columns.
60
+
61
+ A good commit log looks like this:
62
+
63
+ ```
64
+ Fixes #9: Use getters instead of instance vars
65
+
66
+ Body of commit message is a few lines of text, explaining things
67
+ in more detail, possibly giving some background about the issue
68
+ being fixed, etc etc.
69
+
70
+ The body of the commit message can be several paragraphs, and
71
+ please do proper word-wrap and keep columns shorter than about
72
+ 72 characters or so. That way `git log` will show things
73
+ nicely even when it is indented.
74
+ ```
75
+
76
+ The header line should be meaningful; it is what other people see when they
77
+ run `git shortlog` or `git log --oneline`.
78
+
79
+ ### Rebase
80
+
81
+ Use `git rebase` (not `git merge`) to sync your work from time to time if
82
+ upstream/master has moved ahead of you.
83
+
84
+ ```bash
85
+ $ git fetch upstream
86
+ $ git rebase upstream/master
87
+ ```
88
+
89
+ ### Test
90
+
91
+ Bug fixes and features should come with RSpec tests. Add your tests in the
92
+ `spec` directory. Look at other tests to see how they should be
93
+ structured (license boilerplate, common includes, etc.).
94
+
95
+ Run `bundle && rake` to run the test suite.
96
+
97
+ Make sure all tests pass.
98
+
99
+ ### Push
100
+
101
+ ```bash
102
+ $ git push origin my-feature-branch
103
+ ```
104
+
105
+ ### Create a Pull Request
106
+ Go to https://github.com/<username>/chef-vault and select your feature branch. Click
107
+ the 'Pull Request' button and fill out the form.
108
+
109
+ Pull requests are usually reviewed within a few days. If there are comments
110
+ to address, apply your changes in a separate commit and push that to your
111
+ feature branch. Post a comment in the pull request afterwards; GitHub does
112
+ not send out notifications when you add commits.
113
+
114
+ ### Thank You
115
+ Thank you for reading this far. We look forward to your contribution.
116
+
117
+ Kevin Moser, Doug Ireton
118
+ Nordstrom
@@ -0,0 +1,23 @@
1
+ ## Unreleased
2
+
3
+
4
+ ## v1.2.2 / 2012-04-23
5
+ * Update to create data bag folder if it does not already exist
6
+
7
+ ## v1.2.1 / 2012-04-23
8
+ * Clarify Readme
9
+
10
+ ## v1.0.1 / 2012-04-12
11
+ * Compatibility with Chef 10/11 (Shef vs Chef-Shell)
12
+
13
+ ## v1.0.0 / 2012-04-08
14
+ * Rename from Chef-Keepass to Chef-Vault
15
+
16
+ ## v0.2.1 / 2012-04/05
17
+ * Add Certificate class
18
+
19
+ ## v0.2.0 / 2012-04-05
20
+ * Add encrypt cert
21
+
22
+ ## v0.1.1 / 2012-03-14
23
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org/"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rspec'
7
+ end
@@ -0,0 +1,73 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ bunny (0.7.9)
5
+ chef (10.16.6)
6
+ bunny (>= 0.6.0, < 0.8.0)
7
+ erubis
8
+ highline (>= 1.6.9)
9
+ json (>= 1.4.4, <= 1.6.1)
10
+ mixlib-authentication (>= 1.3.0)
11
+ mixlib-cli (>= 1.1.0)
12
+ mixlib-config (>= 1.1.2)
13
+ mixlib-log (>= 1.3.0)
14
+ mixlib-shellout
15
+ moneta (< 0.7.0)
16
+ net-ssh (~> 2.2.2)
17
+ net-ssh-multi (~> 1.1.0)
18
+ ohai (>= 0.6.0)
19
+ rest-client (>= 1.0.4, < 1.7.0)
20
+ treetop (~> 1.4.9)
21
+ uuidtools
22
+ yajl-ruby (~> 1.1)
23
+ diff-lcs (1.2.4)
24
+ erubis (2.7.0)
25
+ highline (1.6.18)
26
+ ipaddress (0.8.0)
27
+ json (1.6.1)
28
+ mime-types (1.23)
29
+ mixlib-authentication (1.3.0)
30
+ mixlib-log
31
+ mixlib-cli (1.3.0)
32
+ mixlib-config (1.1.2)
33
+ mixlib-log (1.6.0)
34
+ mixlib-shellout (1.1.0)
35
+ moneta (0.6.0)
36
+ net-ssh (2.2.2)
37
+ net-ssh-gateway (1.1.0)
38
+ net-ssh (>= 1.99.1)
39
+ net-ssh-multi (1.1)
40
+ net-ssh (>= 2.1.4)
41
+ net-ssh-gateway (>= 0.99.0)
42
+ ohai (6.16.0)
43
+ ipaddress
44
+ mixlib-cli
45
+ mixlib-config
46
+ mixlib-log
47
+ mixlib-shellout
48
+ systemu
49
+ yajl-ruby
50
+ polyglot (0.3.3)
51
+ rest-client (1.6.7)
52
+ mime-types (>= 1.16)
53
+ rspec (2.13.0)
54
+ rspec-core (~> 2.13.0)
55
+ rspec-expectations (~> 2.13.0)
56
+ rspec-mocks (~> 2.13.0)
57
+ rspec-core (2.13.1)
58
+ rspec-expectations (2.13.0)
59
+ diff-lcs (>= 1.1.3, < 2.0)
60
+ rspec-mocks (2.13.1)
61
+ systemu (2.5.2)
62
+ treetop (1.4.12)
63
+ polyglot
64
+ polyglot (>= 0.3.1)
65
+ uuidtools (2.1.3)
66
+ yajl-ruby (1.1.0)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ chef
73
+ rspec
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task :default => :spec
@@ -1,4 +1,19 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # Chef-Vault Gemspec file
3
+ # Copyright 2013, Nordstrom, Inc.
4
+
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
2
17
  $:.push File.expand_path("../lib", __FILE__)
3
18
  require "chef-vault/version"
4
19
 
@@ -10,11 +25,12 @@ Gem::Specification.new do |s|
10
25
  s.email = ["kevin.moser@nordstrom.com"]
11
26
  s.summary = "Data encryption support for chef using data bags"
12
27
  s.description = s.summary
13
-
28
+ s.license = 'Apache License, v2.0'
29
+
14
30
  s.files = `git ls-files`.split("\n")
15
31
  s.add_dependency "chef", ">= 0.10.10"
16
32
  s.require_paths = ["lib"]
17
-
33
+
18
34
  s.bindir = "bin"
19
35
  s.executables = %w( chef-vault )
20
- end
36
+ end
@@ -37,10 +37,10 @@ class ChefVault
37
37
  end
38
38
 
39
39
  def user(username)
40
- ChefVault::User.new(@data_bag, username, @chef_config_file)
40
+ ChefVault::User.new(data_bag, username, chef_config_file)
41
41
  end
42
42
 
43
43
  def certificate(name)
44
- ChefVault::Certificate.new(@data_bag, name, @chef_config_file)
44
+ ChefVault::Certificate.new(data_bag, name, chef_config_file)
45
45
  end
46
- end
46
+ end
@@ -1,3 +1,18 @@
1
+ # Description: ChefVault::Certificate class
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  class ChefVault
2
17
  class Certificate
3
18
  attr_accessor :name
@@ -34,4 +49,4 @@ class ChefVault
34
49
  certificate["contents"]
35
50
  end
36
51
  end
37
- end
52
+ end
@@ -1,3 +1,18 @@
1
+ # Description: ChefVault::ChefOffline class
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  class ChefVault
2
17
  class ChefOffline
3
18
  attr_accessor :config_file
@@ -1,3 +1,18 @@
1
+ # Description: ChefVault::User class
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  class ChefVault
2
17
  class User
3
18
  attr_accessor :username
@@ -16,7 +31,7 @@ class ChefVault
16
31
  # use the private client_key file to create a decryptor
17
32
  private_key = open(Chef::Config[:client_key]).read
18
33
  private_key = OpenSSL::PKey::RSA.new(private_key)
19
-
34
+
20
35
  begin
21
36
  keys = Chef::DataBagItem.load(@data_bag, "#{username}_keys")
22
37
  rescue
@@ -34,4 +49,4 @@ class ChefVault
34
49
  cred["password"]
35
50
  end
36
51
  end
37
- end
52
+ end
@@ -1,4 +1,19 @@
1
+ # Description: ChefVault VERSION file
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  class ChefVault
2
- VERSION = "1.2.2"
17
+ VERSION = "1.2.3"
3
18
  MAJOR, MINOR, TINY = VERSION.split('.')
4
19
  end
@@ -1,3 +1,18 @@
1
+ # Description: Chef-Vault DecryptCert class
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'chef/knife'
2
17
 
3
18
  class DecryptCert < Chef::Knife
@@ -1,3 +1,18 @@
1
+ # Description: Chef-Vault DecryptPassword class
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'chef/knife'
2
17
 
3
18
  class DecryptPassword < Chef::Knife
@@ -1,3 +1,18 @@
1
+ # Description: Chef-Vault EncryptCert class
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'chef/knife'
2
17
 
3
18
  class EncryptCert < Chef::Knife
@@ -52,6 +67,13 @@ class EncryptCert < Chef::Knife
52
67
  data_bag = "certs"
53
68
  data_bag_path = "./data_bags/#{data_bag}"
54
69
 
70
+ unless ::File.exists?(data_bag_path)
71
+ require 'fileutils'
72
+
73
+ puts("INFO: #{data_bag_path} does not exist, creating...")
74
+ FileUtils.mkdir_p(data_bag_path)
75
+ end
76
+
55
77
  node_search = config[:search]
56
78
  admins = config[:admins]
57
79
  file_to_encrypt = config[:cert]
@@ -1,3 +1,18 @@
1
+ # Description: Chef-Vault EncryptPassword class
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'chef/knife'
2
17
 
3
18
  class EncryptPassword < Chef::Knife
@@ -1,3 +1,18 @@
1
+ # Description: ChefVault::Compat module
2
+ # Copyright 2013, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  # Make a wraper to chef10/11 "shef/shell" changes
2
17
 
3
18
  module ChefVault
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe ChefVault do
4
+
5
+ describe '#new' do
6
+ context 'with only a data bag parameter specified' do
7
+ before(:each) do
8
+ @vault = ChefVault.new('foo')
9
+ end
10
+
11
+ it 'is an instance of ChefVault' do
12
+ expect(@vault).to be_an_instance_of ChefVault
13
+ end
14
+
15
+ it 'correctly assigns the data_bag instance var' do
16
+ expect(@vault.data_bag).to eq 'foo'
17
+ end
18
+
19
+ it 'defaults to nil for the chef_config_file' do
20
+ expect(@vault.chef_config_file).to be_nil
21
+ end
22
+ end
23
+
24
+ context 'with data_bag and chef_config_file parameters specified' do
25
+ before(:each) do
26
+ @vault = ChefVault.new('foo', '~/chef-repo/.chef/knife.rb')
27
+ end
28
+
29
+ it 'correctly assigns the data_bag instance var' do
30
+ expect(@vault.data_bag).to eq 'foo'
31
+ end
32
+
33
+ it 'correctly assigns the chef_config_file var' do
34
+ expect(@vault.chef_config_file).to eq '~/chef-repo/.chef/knife.rb'
35
+ end
36
+ end
37
+ end
38
+
39
+ describe '#version' do
40
+ it 'returns the version number' do
41
+ vault = ChefVault.new('foo')
42
+ expect(vault.version).to eq ChefVault::VERSION
43
+ end
44
+ end
45
+
46
+ describe '#user' do
47
+ before(:each) do
48
+ @vault = ChefVault.new('foo')
49
+ @user = @vault.user('mysql')
50
+ end
51
+
52
+ it 'is an instance of ChefVault::User' do
53
+ expect(@user).to be_an_instance_of ChefVault::User
54
+ end
55
+ end
56
+
57
+ describe '#certificate' do
58
+ before(:each) do
59
+ @vault = ChefVault.new('certs')
60
+ @cert = @vault.certificate('my_ssl_cert')
61
+ end
62
+
63
+ it 'is an instance of ChefVault::Certificate' do
64
+ expect(@cert).to be_an_instance_of ChefVault::Certificate
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../lib/chef-vault'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # Require this file using `require "spec_helper"` to ensure that it is only
6
+ # loaded once.
7
+ #
8
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-24 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -36,7 +36,14 @@ extensions: []
36
36
  extra_rdoc_files: []
37
37
  files:
38
38
  - .gitignore
39
+ - .rspec
40
+ - CONTRIBUTING.md
41
+ - Changelog.md
42
+ - Gemfile
43
+ - Gemfile.lock
44
+ - LICENSE
39
45
  - README.md
46
+ - Rakefile
40
47
  - bin/chef-vault
41
48
  - chef-vault.gemspec
42
49
  - lib/chef-vault.rb
@@ -49,8 +56,11 @@ files:
49
56
  - lib/chef/knife/EncryptCert.rb
50
57
  - lib/chef/knife/EncryptPassword.rb
51
58
  - lib/chef/knife/compat.rb
59
+ - spec/chef-vault_spec.rb
60
+ - spec/spec_helper.rb
52
61
  homepage:
53
- licenses: []
62
+ licenses:
63
+ - Apache License, v2.0
54
64
  post_install_message:
55
65
  rdoc_options: []
56
66
  require_paths: