librarian-puppet-maestrodev 0.9.7
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/.gitignore +3 -0
- data/LICENSE +20 -0
- data/README.md +187 -0
- data/bin/librarian-puppet +9 -0
- data/lib/librarian/puppet.rb +13 -0
- data/lib/librarian/puppet/cli.rb +85 -0
- data/lib/librarian/puppet/dsl.rb +16 -0
- data/lib/librarian/puppet/environment.rb +54 -0
- data/lib/librarian/puppet/extension.rb +41 -0
- data/lib/librarian/puppet/lockfile/parser.rb +53 -0
- data/lib/librarian/puppet/source.rb +4 -0
- data/lib/librarian/puppet/source/forge.rb +279 -0
- data/lib/librarian/puppet/source/git.rb +114 -0
- data/lib/librarian/puppet/source/githubtarball.rb +234 -0
- data/lib/librarian/puppet/source/local.rb +57 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/templates/Puppetfile +10 -0
- data/lib/librarian/puppet/version.rb +5 -0
- data/vendor/librarian/CHANGELOG.md +185 -0
- data/vendor/librarian/Gemfile +6 -0
- data/vendor/librarian/MIT-LICENSE +20 -0
- data/vendor/librarian/README.md +403 -0
- data/vendor/librarian/Rakefile +34 -0
- data/vendor/librarian/bin/librarian-chef +7 -0
- data/vendor/librarian/bin/librarian-mock +7 -0
- data/vendor/librarian/config/cucumber.yaml +1 -0
- data/vendor/librarian/features/chef/cli/init.feature +11 -0
- data/vendor/librarian/features/chef/cli/install.feature +64 -0
- data/vendor/librarian/features/chef/cli/show.feature +77 -0
- data/vendor/librarian/features/chef/cli/version.feature +11 -0
- data/vendor/librarian/features/support/env.rb +9 -0
- data/vendor/librarian/lib/librarian.rb +19 -0
- data/vendor/librarian/lib/librarian/action.rb +5 -0
- data/vendor/librarian/lib/librarian/action/base.rb +24 -0
- data/vendor/librarian/lib/librarian/action/clean.rb +44 -0
- data/vendor/librarian/lib/librarian/action/ensure.rb +24 -0
- data/vendor/librarian/lib/librarian/action/install.rb +99 -0
- data/vendor/librarian/lib/librarian/action/resolve.rb +81 -0
- data/vendor/librarian/lib/librarian/action/update.rb +78 -0
- data/vendor/librarian/lib/librarian/chef.rb +1 -0
- data/vendor/librarian/lib/librarian/chef/cli.rb +48 -0
- data/vendor/librarian/lib/librarian/chef/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/chef/environment.rb +27 -0
- data/vendor/librarian/lib/librarian/chef/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/chef/integration/knife.rb +42 -0
- data/vendor/librarian/lib/librarian/chef/manifest_reader.rb +59 -0
- data/vendor/librarian/lib/librarian/chef/source.rb +3 -0
- data/vendor/librarian/lib/librarian/chef/source/git.rb +25 -0
- data/vendor/librarian/lib/librarian/chef/source/local.rb +69 -0
- data/vendor/librarian/lib/librarian/chef/source/path.rb +12 -0
- data/vendor/librarian/lib/librarian/chef/source/site.rb +446 -0
- data/vendor/librarian/lib/librarian/chef/templates/Cheffile +15 -0
- data/vendor/librarian/lib/librarian/cli.rb +205 -0
- data/vendor/librarian/lib/librarian/cli/manifest_presenter.rb +79 -0
- data/vendor/librarian/lib/librarian/config.rb +7 -0
- data/vendor/librarian/lib/librarian/config/database.rb +205 -0
- data/vendor/librarian/lib/librarian/config/file_source.rb +47 -0
- data/vendor/librarian/lib/librarian/config/hash_source.rb +33 -0
- data/vendor/librarian/lib/librarian/config/source.rb +149 -0
- data/vendor/librarian/lib/librarian/dependency.rb +91 -0
- data/vendor/librarian/lib/librarian/dsl.rb +108 -0
- data/vendor/librarian/lib/librarian/dsl/receiver.rb +48 -0
- data/vendor/librarian/lib/librarian/dsl/target.rb +172 -0
- data/vendor/librarian/lib/librarian/environment.rb +134 -0
- data/vendor/librarian/lib/librarian/error.rb +4 -0
- data/vendor/librarian/lib/librarian/helpers.rb +13 -0
- data/vendor/librarian/lib/librarian/lockfile.rb +29 -0
- data/vendor/librarian/lib/librarian/lockfile/compiler.rb +66 -0
- data/vendor/librarian/lib/librarian/lockfile/parser.rb +100 -0
- data/vendor/librarian/lib/librarian/logger.rb +46 -0
- data/vendor/librarian/lib/librarian/manifest.rb +132 -0
- data/vendor/librarian/lib/librarian/manifest_set.rb +153 -0
- data/vendor/librarian/lib/librarian/mock.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/cli.rb +19 -0
- data/vendor/librarian/lib/librarian/mock/dsl.rb +15 -0
- data/vendor/librarian/lib/librarian/mock/environment.rb +24 -0
- data/vendor/librarian/lib/librarian/mock/extension.rb +9 -0
- data/vendor/librarian/lib/librarian/mock/source.rb +1 -0
- data/vendor/librarian/lib/librarian/mock/source/mock.rb +97 -0
- data/vendor/librarian/lib/librarian/mock/source/mock/registry.rb +83 -0
- data/vendor/librarian/lib/librarian/resolution.rb +44 -0
- data/vendor/librarian/lib/librarian/resolver.rb +78 -0
- data/vendor/librarian/lib/librarian/resolver/implementation.rb +118 -0
- data/vendor/librarian/lib/librarian/source.rb +2 -0
- data/vendor/librarian/lib/librarian/source/git.rb +150 -0
- data/vendor/librarian/lib/librarian/source/git/repository.rb +217 -0
- data/vendor/librarian/lib/librarian/source/local.rb +61 -0
- data/vendor/librarian/lib/librarian/source/path.rb +74 -0
- data/vendor/librarian/lib/librarian/spec.rb +13 -0
- data/vendor/librarian/lib/librarian/spec_change_set.rb +173 -0
- data/vendor/librarian/lib/librarian/specfile.rb +18 -0
- data/vendor/librarian/lib/librarian/support/abstract_method.rb +21 -0
- data/vendor/librarian/lib/librarian/ui.rb +64 -0
- data/vendor/librarian/lib/librarian/version.rb +3 -0
- data/vendor/librarian/librarian.gemspec +34 -0
- data/vendor/librarian/spec/functional/chef/source/git_spec.rb +432 -0
- data/vendor/librarian/spec/functional/chef/source/site_spec.rb +215 -0
- data/vendor/librarian/spec/functional/source/git/repository_spec.rb +149 -0
- data/vendor/librarian/spec/unit/action/base_spec.rb +18 -0
- data/vendor/librarian/spec/unit/action/clean_spec.rb +102 -0
- data/vendor/librarian/spec/unit/action/ensure_spec.rb +37 -0
- data/vendor/librarian/spec/unit/action/install_spec.rb +111 -0
- data/vendor/librarian/spec/unit/config/database_spec.rb +319 -0
- data/vendor/librarian/spec/unit/dependency_spec.rb +36 -0
- data/vendor/librarian/spec/unit/dsl_spec.rb +194 -0
- data/vendor/librarian/spec/unit/environment_spec.rb +9 -0
- data/vendor/librarian/spec/unit/lockfile/parser_spec.rb +162 -0
- data/vendor/librarian/spec/unit/lockfile_spec.rb +65 -0
- data/vendor/librarian/spec/unit/manifest_set_spec.rb +202 -0
- data/vendor/librarian/spec/unit/manifest_spec.rb +36 -0
- data/vendor/librarian/spec/unit/mock/source/mock_spec.rb +22 -0
- data/vendor/librarian/spec/unit/resolver_spec.rb +192 -0
- data/vendor/librarian/spec/unit/source/git_spec.rb +29 -0
- data/vendor/librarian/spec/unit/spec_change_set_spec.rb +169 -0
- metadata +227 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Librarian
|
|
2
|
+
module Puppet
|
|
3
|
+
module Source
|
|
4
|
+
module Local
|
|
5
|
+
|
|
6
|
+
def install!(manifest)
|
|
7
|
+
manifest.source == self or raise ArgumentError
|
|
8
|
+
|
|
9
|
+
debug { "Installing #{manifest}" }
|
|
10
|
+
|
|
11
|
+
name, version = manifest.name, manifest.version
|
|
12
|
+
found_path = found_path(name)
|
|
13
|
+
raise Error, "Path for #{name} doesn't contain a puppet module" if found_path.nil?
|
|
14
|
+
|
|
15
|
+
if name.include? '/'
|
|
16
|
+
new_name = name.split('/').last
|
|
17
|
+
debug { "Invalid module name '#{name}', guessing you meant '#{new_name}'" }
|
|
18
|
+
name = new_name
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
install_path = environment.install_path.join(name)
|
|
22
|
+
if install_path.exist?
|
|
23
|
+
debug { "Deleting #{relative_path_to(install_path)}" }
|
|
24
|
+
install_path.rmtree
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
install_perform_step_copy!(found_path, install_path)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def fetch_version(name, extra)
|
|
31
|
+
cache!
|
|
32
|
+
found_path = found_path(name)
|
|
33
|
+
'0.0.1'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def fetch_dependencies(name, version, extra)
|
|
37
|
+
{}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def install_perform_step_copy!(found_path, install_path)
|
|
43
|
+
debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" }
|
|
44
|
+
FileUtils.cp_r(found_path, install_path)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def manifest?(name, path)
|
|
48
|
+
return true if path.join('manifests').exist?
|
|
49
|
+
return true if path.join('lib').join('puppet').exist?
|
|
50
|
+
return true if path.join('lib').join('facter').exist?
|
|
51
|
+
debug { "Could not find manifests, lib/puppet or lib/facter under #{path}, assuming is not a puppet module" }
|
|
52
|
+
false
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
forge "http://forge.puppetlabs.com"
|
|
2
|
+
|
|
3
|
+
# mod 'puppetlabs/stdlib'
|
|
4
|
+
|
|
5
|
+
# mod 'ntp',
|
|
6
|
+
# :git => 'git://github.com/puppetlabs/puppetlabs-ntp.git'
|
|
7
|
+
|
|
8
|
+
# mod 'apt',
|
|
9
|
+
# :git => 'https://github.com/puppetlabs/puppetlabs-apt.git',
|
|
10
|
+
# :ref => 'feature/master/dans_refactor'
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## 0.0.24
|
|
4
|
+
|
|
5
|
+
* \#15. A remembered configuration system.
|
|
6
|
+
|
|
7
|
+
* \#16. Configure, and remember configuration for, chef install paths.
|
|
8
|
+
|
|
9
|
+
* \#38. Configure, and remember configuration for, stripping out `.git`
|
|
10
|
+
directories from git-sources chef dependencies.
|
|
11
|
+
|
|
12
|
+
* \#76. Support git annotated tags.
|
|
13
|
+
|
|
14
|
+
* \#80. Ignore directories in the `PATH` named `git` when looking for the `git`
|
|
15
|
+
bin.
|
|
16
|
+
|
|
17
|
+
* \#85. Provide a helpful message when running the `show` command without a
|
|
18
|
+
lockfile present.
|
|
19
|
+
|
|
20
|
+
## 0.0.23
|
|
21
|
+
|
|
22
|
+
* \#41. Build gems with a built gemspec.
|
|
23
|
+
|
|
24
|
+
* \#67. Cache remote objects at the latest possible moments, and only when they
|
|
25
|
+
are needed.
|
|
26
|
+
|
|
27
|
+
* \#68. Fix unpacking chef site-sourced packages on Windows by pivoting from a
|
|
28
|
+
Librarian-managed scratch space, rather than pivoting from Windows' temp
|
|
29
|
+
directory. There were unexplained problems with using the Windows temp
|
|
30
|
+
directory in certain cases, possibly related to the temp directory and the
|
|
31
|
+
Librarian cache directory being on different volumes.
|
|
32
|
+
|
|
33
|
+
* \#69. Fix invoking Librarian with git-sourced dependencies from git hooks by
|
|
34
|
+
unsetting `GIT_DIR` around shelling out to git.
|
|
35
|
+
|
|
36
|
+
* Print general environment information when running with `--verbose`.
|
|
37
|
+
|
|
38
|
+
## 0.0.22
|
|
39
|
+
|
|
40
|
+
* Fix the `outdated` CLI command.
|
|
41
|
+
|
|
42
|
+
## 0.0.21
|
|
43
|
+
|
|
44
|
+
* \#64. Sources now raise when given unrecognized options in the specfile.
|
|
45
|
+
|
|
46
|
+
* A new `show` CLI command.
|
|
47
|
+
|
|
48
|
+
* Changed the `clean` CLI command no longer to delete the lockfile.
|
|
49
|
+
|
|
50
|
+
* Simplify the architecture of `Librarian::Manifest` vis-a-vis sources. It is no
|
|
51
|
+
longer a base class for adapters to inherit. Now, sources expose a small
|
|
52
|
+
interface, which `Librarian::Manifest` can call, for delay-loading attributes.
|
|
53
|
+
|
|
54
|
+
* The git source now resolves the `git` binary before `chdir`ing.
|
|
55
|
+
|
|
56
|
+
* Test on Rubinius.
|
|
57
|
+
|
|
58
|
+
## 0.0.20
|
|
59
|
+
|
|
60
|
+
* A command to print outdated dependencies.
|
|
61
|
+
|
|
62
|
+
## 0.0.19
|
|
63
|
+
|
|
64
|
+
* Fix breakage on 1.8.
|
|
65
|
+
|
|
66
|
+
## 0.0.18
|
|
67
|
+
|
|
68
|
+
* \#57. Include existing manifests' dependencies in resolution.
|
|
69
|
+
|
|
70
|
+
* Permit the update action even with a changed specfile.
|
|
71
|
+
|
|
72
|
+
## 0.0.17
|
|
73
|
+
|
|
74
|
+
* Use a pure-Ruby implementation of tar/gz. Helps with Windows support, since
|
|
75
|
+
Windows boxes are less likely than *NIX boxes to have the `tar` executable.
|
|
76
|
+
|
|
77
|
+
* Fix an issue where the chef site source considers uncached manifests to be
|
|
78
|
+
cached, and skips caching them, causing the install action to fail.
|
|
79
|
+
|
|
80
|
+
* Fail fast if the resolver produces an inconsistent resolution. It is a known
|
|
81
|
+
issue that the resolver will sometimes (deterministically, not randomly)
|
|
82
|
+
produce an inconsistent resolution when performing an update action (#57).
|
|
83
|
+
Start debugging this by failing fast at this point and spitting out gobs of
|
|
84
|
+
debug-level log details.
|
|
85
|
+
|
|
86
|
+
## 0.0.16
|
|
87
|
+
|
|
88
|
+
* Recache site-sourced dependency metadata per each run.
|
|
89
|
+
|
|
90
|
+
* \#46. Always install.
|
|
91
|
+
|
|
92
|
+
* \#53. Abstract versions & requirements from rubygems.
|
|
93
|
+
|
|
94
|
+
* Own the install path. Recreate it on each install.
|
|
95
|
+
WARNING: If you have your own content in the install path, it will be deleted without mercy.
|
|
96
|
+
|
|
97
|
+
## 0.0.15
|
|
98
|
+
|
|
99
|
+
* Rewrite the README.
|
|
100
|
+
|
|
101
|
+
* \#44, \#49. Better updating of cached git sources without using local merges.
|
|
102
|
+
|
|
103
|
+
## 0.0.14
|
|
104
|
+
|
|
105
|
+
* \#39 Fixes a regression induced by using `git reset --hard SHA`.
|
|
106
|
+
|
|
107
|
+
## 0.0.13
|
|
108
|
+
|
|
109
|
+
* \#36 Fixes an issue where, if a dependency has a git source (the upstream), and the upstream is updated,
|
|
110
|
+
then attempting to update that dependency in the local resolution would not update that dependency so
|
|
111
|
+
long as that git source were cached (@databus23).
|
|
112
|
+
|
|
113
|
+
* More immediate detection of, and better error messages for, cases of blank dependency or manifest names
|
|
114
|
+
or cases of names that are otherwise insensible, such as names that are untrimmed.
|
|
115
|
+
|
|
116
|
+
## 0.0.12
|
|
117
|
+
|
|
118
|
+
* Fixes an issue where, if a dependency has a git source with a ref, re-resolving may fail.
|
|
119
|
+
|
|
120
|
+
## 0.0.11
|
|
121
|
+
|
|
122
|
+
* Fix a regression where the cli command "version" failed.
|
|
123
|
+
|
|
124
|
+
## 0.0.10
|
|
125
|
+
|
|
126
|
+
This release focuses on refactoring some of the internals. There are no functional changes.
|
|
127
|
+
|
|
128
|
+
## 0.0.9
|
|
129
|
+
|
|
130
|
+
* \#11 Fixes a problem where, if the repo is in a path where a component has a space, attempting to resolve a
|
|
131
|
+
site-sourced dependency fails.
|
|
132
|
+
|
|
133
|
+
## 0.0.8
|
|
134
|
+
|
|
135
|
+
* A `version` task.
|
|
136
|
+
|
|
137
|
+
* A change log.
|
|
138
|
+
|
|
139
|
+
* \#10 Fixes the problem with bouncing the lockfile when updating, when using a git source with the default ref.
|
|
140
|
+
|
|
141
|
+
## 0.0.7
|
|
142
|
+
|
|
143
|
+
* \#8 Add highline temporarily as a runtime dependency of `librarian` (@fnichol).
|
|
144
|
+
When the project is split into `librarian` and `librarian-chef`, the `chef` runtime dependency will
|
|
145
|
+
be moved to `librarian-chef`. If the project is further split into a knife plugin, the dependency
|
|
146
|
+
will be moved there.
|
|
147
|
+
|
|
148
|
+
## 0.0.6
|
|
149
|
+
|
|
150
|
+
* \#7 Show a better error message when a cookbook is missing the required metadata file.
|
|
151
|
+
|
|
152
|
+
* Miscellaneous bugfixes.
|
|
153
|
+
|
|
154
|
+
## 0.0.5
|
|
155
|
+
|
|
156
|
+
* \#4 An `init` task for `librarian-chef`.
|
|
157
|
+
This task creates a nearly-blank `Cheffile` with just the default Opscode Community Site source.
|
|
158
|
+
|
|
159
|
+
* Automatically create the `cookbooks` directory, if it's missing, when running the `install` task.
|
|
160
|
+
|
|
161
|
+
* \#3 Add `chef` temporarily as a runtime dependency of `librarian` (@fnichol).
|
|
162
|
+
When the project is split into `librarian` and `librarian-chef`, the `chef` runtime dependency will
|
|
163
|
+
be moved to `librarian-chef`.
|
|
164
|
+
|
|
165
|
+
## 0.0.4
|
|
166
|
+
|
|
167
|
+
* A simple knife integration.
|
|
168
|
+
This integration allows you to specify a `librarian-chef`-managed tempdir as a `cookbook_path`.
|
|
169
|
+
This is useful to force knife only to upload the exact cookbooks that `librarian-chef` knows
|
|
170
|
+
about, rather than whatever happens to be found in the `cookbooks` directory.
|
|
171
|
+
|
|
172
|
+
## 0.0.3
|
|
173
|
+
|
|
174
|
+
* Miscellaneous bugfixes.
|
|
175
|
+
|
|
176
|
+
## 0.0.2
|
|
177
|
+
|
|
178
|
+
* An optional `:path` attribute for `:git` sources.
|
|
179
|
+
This allows you to specify exactly where within a git repository a given cookbook is to be found.
|
|
180
|
+
|
|
181
|
+
* A full example of a Cheffile and its usage in the readme.
|
|
182
|
+
|
|
183
|
+
## 0.0.1
|
|
184
|
+
|
|
185
|
+
* Initial release.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 ApplicationsOnline, LLC.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
Librarian [](http://travis-ci.org/applicationsonline/librarian)
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Librarian is a framework for writing bundlers, which are tools that resolve,
|
|
5
|
+
fetch, install, and isolate a project's dependencies, in Ruby.
|
|
6
|
+
|
|
7
|
+
Librarian ships with Librarian-Chef, which is a bundler for your Chef-based
|
|
8
|
+
infrastructure repositories. In the future, Librarian-Chef will be a separate
|
|
9
|
+
project.
|
|
10
|
+
|
|
11
|
+
A bundler written with Librarian will expect you to provide a specfile listing
|
|
12
|
+
your project's declared dependencies, including any version constraints and
|
|
13
|
+
including the upstream sources for finding them. Librarian can resolve the spec,
|
|
14
|
+
write a lockfile listing the full resolution, fetch the resolved dependencies,
|
|
15
|
+
install them, and isolate them in your project.
|
|
16
|
+
|
|
17
|
+
A bundler written with Librarian will be similar in kind to [Bundler](http://gembundler.com),
|
|
18
|
+
the bundler for Ruby gems that many modern Rails applications use.
|
|
19
|
+
|
|
20
|
+
Librarian-Chef
|
|
21
|
+
---------------
|
|
22
|
+
|
|
23
|
+
Librarian-Chef is a tool that helps you manage the cookbooks that your chef-repo
|
|
24
|
+
depends on. Here are some more details.
|
|
25
|
+
|
|
26
|
+
Librarian-Chef is a bundler for infrastructure repositories using Chef. You can
|
|
27
|
+
use Librarian-Chef to resolve your infrastructure's cookbook dependencies, fetch
|
|
28
|
+
them, and install them into your infrastructure repository.
|
|
29
|
+
|
|
30
|
+
Librarian-Chef can resolve and fetch third-party, publicly-released cookbooks,
|
|
31
|
+
and install them into your infrastructure repository. It can also source
|
|
32
|
+
cookbooks directly from their own source control repositories.
|
|
33
|
+
|
|
34
|
+
Librarian-Chef can also deal with cookbooks you may actively be working on
|
|
35
|
+
outside your infrastructure repository. For example, it can deal with cookbooks
|
|
36
|
+
directly from their own private source control repositories, whether they are
|
|
37
|
+
remote or local to your machine, and it can deal with cookbooks released to and
|
|
38
|
+
hosted on a private cookbooks server.
|
|
39
|
+
|
|
40
|
+
Librarian-Chef is not primarily intended for dealing with the cookbooks you are
|
|
41
|
+
actively working on *within* your infrastructure repository. In such a case, you
|
|
42
|
+
can still use Librarian-Chef, but it is likely unnecessary.
|
|
43
|
+
|
|
44
|
+
Librarian-Chef *takes over* your `cookbooks/` directory and manages it for you
|
|
45
|
+
based on your `Cheffile`. Your `Cheffile` becomes the authoritative source for
|
|
46
|
+
the cookbooks your infrastructure repository depends on. You should not modify
|
|
47
|
+
the contents of your `cookbooks/` directory when using Librarian-Chef. If you
|
|
48
|
+
have cookbooks which are, rather than being separate projects, inherently part
|
|
49
|
+
of your infrastructure repository, then they should go in a separate directory,
|
|
50
|
+
like your `site-cookbooks/` directory, and you do not need to use Librarian-Chef
|
|
51
|
+
to manage them.
|
|
52
|
+
|
|
53
|
+
### The Cheffile
|
|
54
|
+
|
|
55
|
+
Every infrastruture repository that uses Librarian-Chef will have a file named
|
|
56
|
+
`Cheffile` in the root directory of that repository. The full specification for
|
|
57
|
+
which third-party, publicly-released cookbooks your infrastructure repository
|
|
58
|
+
depends will go here.
|
|
59
|
+
|
|
60
|
+
Here's an example `Cheffile`:
|
|
61
|
+
|
|
62
|
+
site "http://community.opscode.com/api/v1"
|
|
63
|
+
|
|
64
|
+
cookbook "ntp"
|
|
65
|
+
cookbook "timezone", "0.0.1"
|
|
66
|
+
|
|
67
|
+
cookbook "rvm",
|
|
68
|
+
:git => "https://github.com/fnichol/chef-rvm",
|
|
69
|
+
:ref => "v0.7.1"
|
|
70
|
+
|
|
71
|
+
cookbook "cloudera",
|
|
72
|
+
:path => "vendor/cookbooks/cloudera-cookbook"
|
|
73
|
+
|
|
74
|
+
Here's how it works:
|
|
75
|
+
|
|
76
|
+
We start off by declaring the *default source* for this `Cheffile`.
|
|
77
|
+
|
|
78
|
+
site "http://community.opscode.com/api/v1"
|
|
79
|
+
|
|
80
|
+
This default source in this example is the Opscode Community Site API. This is
|
|
81
|
+
most likely what you will want for your default source. However, you can
|
|
82
|
+
certainly set up your own API-compatible HTTP endpoint if you want more control.
|
|
83
|
+
|
|
84
|
+
Any time we declare a cookbook dependency without also declaring a source for
|
|
85
|
+
that cookbook dependency, Librarian-Chef assumes we want it to look for that
|
|
86
|
+
cookbook in the default source.
|
|
87
|
+
|
|
88
|
+
Any time we declare a cookbook dependency that has subsidiary cookbook
|
|
89
|
+
dependencies of its own, Librarian-Chef assumes we want it to look for the
|
|
90
|
+
subsidiary cookbook dependencies in the default source.
|
|
91
|
+
|
|
92
|
+
cookbook "ntp"
|
|
93
|
+
|
|
94
|
+
Our infrastructure repository depends on the `ntp` cookbook from the default
|
|
95
|
+
source. Any version of the `ntp` cookbook will fulfill our requirements.
|
|
96
|
+
|
|
97
|
+
cookbook "timezone", "0.0.1"
|
|
98
|
+
|
|
99
|
+
Our infrastructure repository depends on the `timezone` cookbook from the
|
|
100
|
+
default source. But only version `0.0.1` of that cookbook will do.
|
|
101
|
+
|
|
102
|
+
cookbook "rvm",
|
|
103
|
+
:git => "https://github.com/fnichol/chef-rvm",
|
|
104
|
+
:ref => "v0.7.1"
|
|
105
|
+
|
|
106
|
+
Our infrastructure repository depends on the `rvm` cookbook, but not the one
|
|
107
|
+
from the default source. Instead, the cookbook is to be fetched from the
|
|
108
|
+
specified Git repository and from the specified Git tag only.
|
|
109
|
+
|
|
110
|
+
When using a Git source, we do not have to use a `:ref =>`. If we do not,
|
|
111
|
+
then Librarian-Chef will assume we meant the `master` branch. (In the future,
|
|
112
|
+
this will be changed to whatever branch is the default branch according to
|
|
113
|
+
the Git remote, which may not be `master`.)
|
|
114
|
+
|
|
115
|
+
If we use a `:ref =>`, we can use anything that Git will recognize as a ref.
|
|
116
|
+
This includes any branch name, tag name, SHA, or SHA unique prefix. If we use a
|
|
117
|
+
branch, we can later ask Librarian-Chef to update the cookbook by fetching the
|
|
118
|
+
most recent version of the cookbook from that same branch.
|
|
119
|
+
|
|
120
|
+
The Git source also supports a `:path =>` option. If we use the path option,
|
|
121
|
+
Librarian-Chef will navigate down into the Git repository and only use the
|
|
122
|
+
specified subdirectory. Many people have the habit of having a single repository
|
|
123
|
+
with many cookbooks in it. If we need a cookbook from such a repository, we can
|
|
124
|
+
use the `:path =>` option here to help Librarian-Chef drill down and find the
|
|
125
|
+
cookbook subdirectory.
|
|
126
|
+
|
|
127
|
+
cookbook "cloudera",
|
|
128
|
+
:path => "vendor/cookbooks/cloudera-cookbook"
|
|
129
|
+
|
|
130
|
+
Our infrastructure repository depends on the `cloudera` cookbook, which we have
|
|
131
|
+
downloaded and copied into our repository. In this example, `vendor/cookbooks/`
|
|
132
|
+
is only for use with Librarian-Chef. This directory should not appear in the
|
|
133
|
+
`.chef/knife.rb`. Librarian-Chef will, instead, copy this cookbook from where
|
|
134
|
+
we vendored it in our repository into the `cookbooks/` directory for us.
|
|
135
|
+
|
|
136
|
+
The `:path =>` source won't be confused with the `:git =>` source's `:path =>`
|
|
137
|
+
option.
|
|
138
|
+
|
|
139
|
+
### How to Use
|
|
140
|
+
|
|
141
|
+
Install Librarian-Chef:
|
|
142
|
+
|
|
143
|
+
$ gem install librarian
|
|
144
|
+
|
|
145
|
+
Prepare your infrastructure repository:
|
|
146
|
+
|
|
147
|
+
$ cd ~/path/to/chef-repo
|
|
148
|
+
$ git rm -r cookbooks
|
|
149
|
+
$ echo /cookbooks >> .gitignore
|
|
150
|
+
$ echo /tmp >> .gitignore
|
|
151
|
+
|
|
152
|
+
Librarian-Chef takes over your `cookbooks/` directory, and will always reinstall
|
|
153
|
+
the cookbooks listed the `Cheffile.lock` into your `cookbooks/` directory. Hence
|
|
154
|
+
you do not need your `cookbooks/` directory to be tracked in Git. If you
|
|
155
|
+
nevertheless want your `cookbooks/` directory to be tracked in Git, simple don't
|
|
156
|
+
`.gitignore` the directory.
|
|
157
|
+
|
|
158
|
+
If you are manually tracking/vendoring outside cookbooks within the repository,
|
|
159
|
+
put them in another directory such as `vendor/cookbooks/` and use the `:path =>`
|
|
160
|
+
source when declaring these cookbooks in your `Cheffile`. Most people will
|
|
161
|
+
typically not be manually tracking/vendoring outside cookbooks.
|
|
162
|
+
|
|
163
|
+
Librarian-Chef uses your `tmp/` directory for tempfiles and caches. You do not
|
|
164
|
+
need to track this directory in Git.
|
|
165
|
+
|
|
166
|
+
Make a Cheffile:
|
|
167
|
+
|
|
168
|
+
$ librarian-chef init
|
|
169
|
+
|
|
170
|
+
This creates an empty `Cheffile` with the Opscode Community Site API as the
|
|
171
|
+
default source.
|
|
172
|
+
|
|
173
|
+
Add dependencies and their sources to the `Cheffile`:
|
|
174
|
+
|
|
175
|
+
$ cat Cheffile
|
|
176
|
+
site 'http://community.opscode.com/api/v1'
|
|
177
|
+
cookbook 'ntp'
|
|
178
|
+
cookbook 'timezone', '0.0.1'
|
|
179
|
+
cookbook 'rvm',
|
|
180
|
+
:git => 'https://github.com/fnichol/chef-rvm',
|
|
181
|
+
:ref => 'v0.7.1'
|
|
182
|
+
cookbook 'cloudera',
|
|
183
|
+
:path => 'vendor/cookbooks/cloudera-cookbook'
|
|
184
|
+
|
|
185
|
+
This is the same `Cheffile` we saw above.
|
|
186
|
+
|
|
187
|
+
$ librarian-chef install [--clean] [--verbose]
|
|
188
|
+
|
|
189
|
+
This command looks at each `cookbook` declaration and fetches the cookbook from
|
|
190
|
+
the source specified, or from the default source if none is provided.
|
|
191
|
+
|
|
192
|
+
Each cookbook is inspected, its dependencies are determined, and each dependency
|
|
193
|
+
is also fetched. For example, if you declare `cookbook 'nagios'`, which
|
|
194
|
+
depends on other cookbooks such as `'php'`, then those other cookbooks
|
|
195
|
+
including `'php'` will be fetched. This goes all the way down the chain of
|
|
196
|
+
dependencies.
|
|
197
|
+
|
|
198
|
+
This command writes the complete resolution into `Cheffile.lock`.
|
|
199
|
+
|
|
200
|
+
This command then copies all of the fetched cookbooks into your `cookbooks/`
|
|
201
|
+
directory, overwriting whatever was there before. You can then use `knife
|
|
202
|
+
cookbook upload -all` to upload the cookbooks to your chef-server, if you are
|
|
203
|
+
using the client-server model.
|
|
204
|
+
|
|
205
|
+
Check your `Cheffile` and `Cheffile.lock` into version control:
|
|
206
|
+
|
|
207
|
+
$ git add Cheffile
|
|
208
|
+
$ git add Cheffile.lock
|
|
209
|
+
$ git commit -m "I want these particular versions of these particular cookbooks from these particular."
|
|
210
|
+
|
|
211
|
+
Make sure you check your `Cheffile.lock` into version control. This will ensure
|
|
212
|
+
dependencies do not need to be resolved every run, greatly reducing dependency
|
|
213
|
+
resolution time.
|
|
214
|
+
|
|
215
|
+
Get an overview of your `Cheffile.lock` with:
|
|
216
|
+
|
|
217
|
+
$ librarian-chef show
|
|
218
|
+
|
|
219
|
+
Inspect the details of specific resolved dependencies with:
|
|
220
|
+
|
|
221
|
+
$ librarian-chef show NAME1 [NAME2, ...]
|
|
222
|
+
|
|
223
|
+
Update your `Cheffile` with new/changed/removed constraints/sources/dependencies:
|
|
224
|
+
|
|
225
|
+
$ cat Cheffile
|
|
226
|
+
site 'http://community.opscode.com/api/v1'
|
|
227
|
+
cookbook 'ntp'
|
|
228
|
+
cookbook 'timezone', '0.0.1'
|
|
229
|
+
cookbook 'rvm',
|
|
230
|
+
:git => 'https://github.com/fnichol/chef-rvm',
|
|
231
|
+
:ref => 'v0.7.1'
|
|
232
|
+
cookbook 'monit' # new!
|
|
233
|
+
$ git diff Cheffile
|
|
234
|
+
$ librarian-chef install [--verbose]
|
|
235
|
+
$ git diff Cheffile.lock
|
|
236
|
+
$ git add Cheffile
|
|
237
|
+
$ git add Cheffile.lock
|
|
238
|
+
$ git commit -m "I also want these additional cookbooks."
|
|
239
|
+
|
|
240
|
+
Find out which dependencies are outdated and may be updated:
|
|
241
|
+
|
|
242
|
+
$ librarian-chef outdated [--verbose]
|
|
243
|
+
|
|
244
|
+
Update the version of a dependency:
|
|
245
|
+
|
|
246
|
+
$ librarian-chef update ntp timezone monit [--verbose]
|
|
247
|
+
$ git diff Cheffile.lock
|
|
248
|
+
$ git add Cheffile.lock
|
|
249
|
+
$ git commit -m "I want updated versions of these cookbooks."
|
|
250
|
+
|
|
251
|
+
Push your changes to the git repository:
|
|
252
|
+
|
|
253
|
+
$ git push origin master
|
|
254
|
+
|
|
255
|
+
Upload the cookbooks to your chef-server:
|
|
256
|
+
|
|
257
|
+
$ knife cookbook upload --all
|
|
258
|
+
|
|
259
|
+
### Configuration
|
|
260
|
+
|
|
261
|
+
Configuration comes from three sources with the following highest-to-lowest
|
|
262
|
+
precedence:
|
|
263
|
+
|
|
264
|
+
* The local config (`./.librarian/chef/config`)
|
|
265
|
+
* The environment
|
|
266
|
+
* The global config (`~/.librarian/chef/config`)
|
|
267
|
+
|
|
268
|
+
You can inspect the final configuration with:
|
|
269
|
+
|
|
270
|
+
$ librarian-chef config
|
|
271
|
+
|
|
272
|
+
You can find out where a particular key is set with:
|
|
273
|
+
|
|
274
|
+
$ librarian-chef config KEY
|
|
275
|
+
|
|
276
|
+
You can set a key at the global level with:
|
|
277
|
+
|
|
278
|
+
$ librarian-chef config KEY VALUE --global
|
|
279
|
+
|
|
280
|
+
And remove it with:
|
|
281
|
+
|
|
282
|
+
$ librarian-chef config KEY --global --delete
|
|
283
|
+
|
|
284
|
+
You can set a key at the local level with:
|
|
285
|
+
|
|
286
|
+
$ librarian-chef config KEY VALUE --local
|
|
287
|
+
|
|
288
|
+
And remove it with:
|
|
289
|
+
|
|
290
|
+
$ librarian-chef config KEY --local --delete
|
|
291
|
+
|
|
292
|
+
You cannot set or delete environment-level config keys with the CLI.
|
|
293
|
+
|
|
294
|
+
Configuration set at either the global or local level will affect subsequent
|
|
295
|
+
invocations of `librarian-chef`. Configurations set at the environment level are
|
|
296
|
+
not saved and will not affect subsequent invocations of `librarian-chef`.
|
|
297
|
+
|
|
298
|
+
You can pass a config at the environment level by taking the original config key
|
|
299
|
+
and transforming it: replace hyphens (`-`) with underscores (`_`) and periods
|
|
300
|
+
(`.`) with doubled underscores (`__`), uppercase, and finally prefix with
|
|
301
|
+
`LIBRARIAN_CHEF_`. For example, to pass a config in the environment for the key
|
|
302
|
+
`part-one.part-two`, set the environment variable
|
|
303
|
+
`LIBRARIAN_CHEF_PART_ONE__PART_TWO`.
|
|
304
|
+
|
|
305
|
+
Configuration affects how various commands operate.
|
|
306
|
+
|
|
307
|
+
* The `path` config sets the cookbooks directory to install to. If a relative
|
|
308
|
+
path, it is relative to the directory containing the `Cheffile`. The
|
|
309
|
+
equivalent environment variable is `LIBRARIAN_CHEF_PATH`.
|
|
310
|
+
|
|
311
|
+
* The `install.strip-dot-git` config causes the `.git/` directory to be stripped
|
|
312
|
+
out when installing cookbooks from a git source. This must be set to exactly
|
|
313
|
+
"1" to cause this behavior. The equivalent environment variable is
|
|
314
|
+
`LIBRARIAN_CHEF_INSTALL__STRIP_DOT_GIT`.
|
|
315
|
+
|
|
316
|
+
Configuration can be set by passing specific options to other commands.
|
|
317
|
+
|
|
318
|
+
* The `path` config can be set at the local level by passing the `--path` option
|
|
319
|
+
to the `install` command. It can be unset at the local level by passing the
|
|
320
|
+
`--no-path` option to the `install` command. Note that if this is set at the
|
|
321
|
+
environment or global level then, even if `--no-path` is given as an option,
|
|
322
|
+
the environment or global config will be used.
|
|
323
|
+
|
|
324
|
+
* The `install.strip-dot-git` config can be set at the local level by passing
|
|
325
|
+
the `--strip-dot-git` option to the `install` command. It can be unset at the
|
|
326
|
+
local level by passing the `--no-strip-dot-git` option.
|
|
327
|
+
|
|
328
|
+
### Knife Integration
|
|
329
|
+
|
|
330
|
+
You can integrate your `knife.rb` with Librarian-Chef.
|
|
331
|
+
|
|
332
|
+
Stick the following in your `knife.rb`:
|
|
333
|
+
|
|
334
|
+
require 'librarian/chef/integration/knife'
|
|
335
|
+
cookbook_path Librarian::Chef.install_path,
|
|
336
|
+
"/path/to/chef-repo/site-cookbooks"
|
|
337
|
+
|
|
338
|
+
In the above, do *not* to include the path to your `cookbooks/` directory. If
|
|
339
|
+
you have additional cookbooks directories in your chef-repo that you use for
|
|
340
|
+
vendored cookbooks (where you use the `:path =>` source in your `Cheffile`),
|
|
341
|
+
make sure *not* to include the paths to those additional cookbooks directories
|
|
342
|
+
either.
|
|
343
|
+
|
|
344
|
+
You still need to include your `site-cookbooks/` directory in the above list.
|
|
345
|
+
|
|
346
|
+
What this integration does is whenever you use any `knife` command, it will:
|
|
347
|
+
|
|
348
|
+
* Enforce that your `Cheffile` and `Cheffile.lock` are in sync
|
|
349
|
+
* Install the resolved cookbooks to a temporary directory
|
|
350
|
+
* Configure Knife to look in the temporary directory for the installed cookbooks
|
|
351
|
+
and not in the normal `cookbooks/` directory.
|
|
352
|
+
|
|
353
|
+
When you use this integration, any changes you make to anything in the
|
|
354
|
+
`cookbooks/` directory will be ignored by Knife, because Knife won't look in
|
|
355
|
+
that directory for your cookbooks.
|
|
356
|
+
|
|
357
|
+
How to Contribute
|
|
358
|
+
-----------------
|
|
359
|
+
|
|
360
|
+
### Running the tests
|
|
361
|
+
|
|
362
|
+
# Either
|
|
363
|
+
$ rspec spec
|
|
364
|
+
$ cucumber
|
|
365
|
+
|
|
366
|
+
# Or
|
|
367
|
+
$ rake
|
|
368
|
+
|
|
369
|
+
You will probably need some way to isolate gems. Librarian provides a `Gemfile`,
|
|
370
|
+
so if you want to use bundler, you can prepare the directory with the usual
|
|
371
|
+
`bundle install` and run each command prefixed with the usual `bundle exec`, as:
|
|
372
|
+
|
|
373
|
+
$ bundle install
|
|
374
|
+
$ bundle exec rspec spec
|
|
375
|
+
$ bundle exec cucumber
|
|
376
|
+
$ bundle exec rake
|
|
377
|
+
|
|
378
|
+
### Installing locally
|
|
379
|
+
|
|
380
|
+
$ rake install
|
|
381
|
+
|
|
382
|
+
You should typically not need to install locally, if you are simply trying to
|
|
383
|
+
patch a bug and test the result on a test case. Instead of installing locally,
|
|
384
|
+
you are probably better served by:
|
|
385
|
+
|
|
386
|
+
$ cd $PATH_TO_INFRASTRUCTURE_REPO
|
|
387
|
+
$ $PATH_TO_LIBRARIAN_CHECKOUT/bin/librarian-chef install [--verbose]
|
|
388
|
+
|
|
389
|
+
### Reporting Issues
|
|
390
|
+
|
|
391
|
+
Please include relevant `Cheffile` and `Cheffile.lock` files. Please run the
|
|
392
|
+
`librarian-chef` commands in verbose mode by using the `--verbose` flag, and
|
|
393
|
+
include the verbose output in the bug report as well.
|
|
394
|
+
|
|
395
|
+
License
|
|
396
|
+
-------
|
|
397
|
+
|
|
398
|
+
Written by Jay Feldblum.
|
|
399
|
+
|
|
400
|
+
Copyright (c) 2011-2012 ApplicationsOnline, LLC.
|
|
401
|
+
|
|
402
|
+
Released under the terms of the MIT License. For further information, please see
|
|
403
|
+
the file `MIT-LICENSE`.
|