librarian-puppet-pr328 2.2.1pr328

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGU2MTAzNTdhYzYyMTZiYWQ2NWI1ZmY4NmNhZmZmOTIzODg2YTg0MA==
5
+ data.tar.gz: !binary |-
6
+ Y2ZjNDRhODZhY2IwMjI1NmVjMWMwMGRlN2YzMDQ2ZGQ4MDE2YzA4Zg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MGUwMWVkYTE3MDNkM2M1M2VlZWVjNGVmNTA1NDFhMmEwMjkyYmY1MmUyZjkz
10
+ NDE1MjEyNTEwMDhhMWE0YzEwNmJkM2VjNGI2MzI2ZDc1NDQzMmQzOWIwMGI2
11
+ ZGJiYjIxOGZlODZiMDExYzg0NDdkOTFkY2E1OGJmYWY5MzA3Y2Q=
12
+ data.tar.gz: !binary |-
13
+ MDE5MGExYTc0MTFkOGFhM2ZjNDE1ZDg2OWVhOGJkMGE2ZTFkMzYyMmRhYjhl
14
+ NDc3ZjBmYTlmMGQ5NzVkZTczMWQ4MmM5NzdhYjI3NTdiYzA5YzM4MzQ3N2U2
15
+ M2VlMDEzMzg3YmM4ZTA2ZTljODRjODVlM2JhMzljMDEwNjAzNGM=
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/
2
+ Gemfile.lock
3
+ tmp/
4
+ coverage/
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012-2014 Tim Sharpe, Carlos Sanchez and others
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.
data/README.md ADDED
@@ -0,0 +1,326 @@
1
+ # Librarian-puppet-pr328
2
+
3
+ # NOTE: This is a temporary gem.
4
+ This gem is a workaround until rodjek/librarian-puppet#325 (PR 328) is merged.
5
+
6
+ ## Introduction
7
+
8
+ Librarian-puppet is a bundler for your puppet infrastructure. You can use
9
+ librarian-puppet to manage the puppet modules your infrastructure depends on,
10
+ whether the modules come from the [Puppet Forge](https://forge.puppetlabs.com/),
11
+ Git repositories or just a path.
12
+
13
+ * Librarian-puppet can reuse the dependencies listed in your `Modulefile` or `metadata.json`
14
+ * Forge modules can be installed from [Puppetlabs Forge](https://forge.puppetlabs.com/) or an internal Forge such as [Pulp](http://www.pulpproject.org/)
15
+ * Git modules can be installed from a branch, tag or specific commit, optionally using a path inside the repository
16
+ * Modules can be installed from GitHub using tarballs, without needing Git installed
17
+ * Modules can be installed from a filesystem path
18
+ * Module dependencies are resolved transitively without needing to list all the modules explicitly
19
+
20
+
21
+ Librarian-puppet manages your `modules/` directory for you based on your
22
+ `Puppetfile`. Your `Puppetfile` becomes the authoritative source for what
23
+ modules you require and at what version, tag or branch.
24
+
25
+ Once using Librarian-puppet you should not modify the contents of your `modules`
26
+ directory. The individual modules' repos should be updated, tagged with a new
27
+ release and the version bumped in your Puppetfile.
28
+
29
+ It is based on [Librarian](https://github.com/applicationsonline/librarian), a
30
+ framework for writing bundlers, which are tools that resolve, fetch, install,
31
+ and isolate a project's dependencies.
32
+
33
+ ## Versions
34
+
35
+ Librarian-puppet >= 2.0 (as well as 1.1, 1.2 and 1.3) requires Ruby 1.9 and uses the Puppet Forge API v3.
36
+ Versions < 2.0 work on Ruby 1.8.
37
+
38
+ See the [Changelog](Changelog.md) for more details.
39
+
40
+ ## The Puppetfile
41
+
42
+ Every Puppet repository that uses Librarian-puppet may have a file named
43
+ `Puppetfile`, `metadata.json` or `Modulefile` in the root directory of that repository.
44
+ The full specification
45
+ for which modules your puppet infrastructure repository depends goes in here.
46
+
47
+ ### Simple usage
48
+
49
+ If no Puppetfile is present, `librarian-puppet` will download all the dependencies
50
+ listed in your `metadata.json` or `Modulefile` from the Puppet Forge,
51
+ as if the Puppetfile contained
52
+
53
+ forge "https://forgeapi.puppetlabs.com"
54
+
55
+ metadata
56
+
57
+
58
+ ### Example Puppetfile
59
+
60
+ forge "https://forgeapi.puppetlabs.com"
61
+
62
+ mod 'puppetlabs-razor'
63
+ mod 'puppetlabs-ntp', "0.0.3"
64
+
65
+ mod 'puppetlabs-apt',
66
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git"
67
+
68
+ mod 'puppetlabs-stdlib',
69
+ :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git"
70
+
71
+ mod 'puppetlabs-apache', '0.6.0',
72
+ :github_tarball => 'puppetlabs/puppetlabs-apache'
73
+
74
+ mod 'acme-mymodule', :path => './some_folder'
75
+
76
+ exclusion 'acme-bad_module'
77
+
78
+
79
+ ### Recursive module dependency resolution
80
+
81
+ When fetching a module all dependencies specified in its
82
+ `Modulefile`, `metadata.json` and `Puppetfile` will be resolved and installed.
83
+
84
+ ### Puppetfile Breakdown
85
+
86
+ forge "https://forgeapi.puppetlabs.com"
87
+
88
+ This declares that we want to use the official Puppet Labs Forge as our default
89
+ source when pulling down modules. If you run your own local forge, you may
90
+ want to change this.
91
+
92
+ metadata
93
+
94
+ Download all the dependencies listed in your `metadata.json` or `Modulefile` from the Puppet Forge.
95
+
96
+ mod 'puppetlabs-razor'
97
+
98
+ Pull in the latest version of the Puppet Labs Razor module from the default
99
+ source.
100
+
101
+ mod 'puppetlabs-ntp', "0.0.3"
102
+
103
+ Pull in version 0.0.3 of the Puppet Labs NTP module from the default source.
104
+
105
+ mod 'puppetlabs-apt',
106
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git"
107
+
108
+ Our puppet infrastructure repository depends on the `apt` module from the
109
+ Puppet Labs GitHub repos and checks out the `master` branch.
110
+
111
+ mod 'puppetlabs-apt',
112
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git",
113
+ :ref => '0.0.3'
114
+
115
+ Our puppet infrastructure repository depends on the `apt` module from the
116
+ Puppet Labs GitHub repos and checks out a tag of `0.0.3`.
117
+
118
+ mod 'puppetlabs-apt',
119
+ :git => "git://github.com/puppetlabs/puppetlabs-apt.git",
120
+ :ref => 'feature/master/dans_refactor'
121
+
122
+ Our puppet infrastructure repository depends on the `apt` module from the
123
+ Puppet Labs GitHub repos and checks out the `dans_refactor` branch.
124
+
125
+ When using a Git source, we do not have to use a `:ref =>`.
126
+ If we do not, then librarian-puppet will assume we meant the `master` branch.
127
+
128
+ If we use a `:ref =>`, we can use anything that Git will recognize as a ref.
129
+ This includes any branch name, tag name, SHA, or SHA unique prefix. If we use a
130
+ branch, we can later ask Librarian-puppet to update the module by fetching the
131
+ most recent version of the module from that same branch.
132
+
133
+ The Git source also supports a `:path =>` option. If we use the path option,
134
+ Librarian-puppet will navigate down into the Git repository and only use the
135
+ specified subdirectory. Some people have the habit of having a single repository
136
+ with many modules in it. If we need a module from such a repository, we can
137
+ use the `:path =>` option here to help Librarian-puppet drill down and find the
138
+ module subdirectory.
139
+
140
+ mod 'puppetlabs-apt',
141
+ :git => "git://github.com/fake/puppet-modules.git",
142
+ :path => "modules/apt"
143
+
144
+ Our puppet infrastructure repository depends on the `apt` module, which we have
145
+ stored as a directory under our `puppet-modules` git repos.
146
+
147
+ mod 'puppetlabs-apache', '0.6.0',
148
+ :github_tarball => 'puppetlabs/puppetlabs-apache'
149
+
150
+ Our puppet infrastructure repository depends on the `puppetlabs-apache` module,
151
+ to be downloaded from GitHub tarball.
152
+
153
+ mod 'acme-mymodule', :path => './some_folder'
154
+
155
+ Our puppet infrastructure repository depends on the `acme-mymodule` module,
156
+ which is already in the filesystem.
157
+
158
+ exclusion 'acme-bad_module'
159
+
160
+ Exclude the module `acme-bad_module` from resolution and installation.
161
+
162
+ ## How to Use
163
+
164
+ Install librarian-puppet:
165
+
166
+ $ gem install librarian-puppet
167
+
168
+ Prepare your puppet infrastructure repository:
169
+
170
+ $ cd ~/path/to/puppet-inf-repos
171
+ $ (git) rm -rf modules
172
+ $ librarian-puppet init
173
+
174
+ Librarian-puppet takes over your `modules/` directory, and will always
175
+ reinstall (if missing) the modules listed the `Puppetfile.lock` into your
176
+ `modules/` directory, therefore you do not need your `modules/` directory to be
177
+ tracked in Git.
178
+
179
+ Librarian-puppet uses a `.tmp/` directory for tempfiles and caches. You should
180
+ not track this directory in Git.
181
+
182
+ Running `librarian-puppet init` will create a skeleton Puppetfile for you as
183
+ well as adding `tmp/` and `modules/` to your `.gitignore`.
184
+
185
+ $ librarian-puppet install [--clean] [--verbose]
186
+
187
+ This command looks at each `mod` declaration and fetches the module from the
188
+ source specified. This command writes the complete resolution into
189
+ `Puppetfile.lock` and then copies all of the fetched modules into your
190
+ `modules/` directory, overwriting whatever was there before.
191
+
192
+ Librarian-puppet support both v1 and v3 of the Puppet Forge API.
193
+ Specify a specific API version when installing modules:
194
+
195
+ $ librarian-puppet install --use-v1-api # this is default; ignored for official Puppet Forge
196
+ $ librarian-puppet install --no-use-v1-api # use the v3 API; default for official Puppet Forge
197
+
198
+ Please note that this does not apply for the official Puppet Forge, where v3 is used by default.
199
+
200
+ Get an overview of your `Puppetfile.lock` with:
201
+
202
+ $ librarian-puppet show
203
+
204
+ Inspect the details of specific resolved dependencies with:
205
+
206
+ $ librarian-puppet show NAME1 [NAME2, ...]
207
+
208
+ Find out which dependencies are outdated and may be updated:
209
+
210
+ $ librarian-puppet outdated [--verbose]
211
+
212
+ Update the version of a dependency:
213
+
214
+ $ librarian-puppet update apt [--verbose]
215
+ $ git diff Puppetfile.lock
216
+ $ git add Puppetfile.lock
217
+ $ git commit -m "bumped the version of apt up to 0.0.4."
218
+
219
+ ## Configuration
220
+
221
+ Configuration comes from three sources with the following highest-to-lowest
222
+ precedence:
223
+
224
+ * The local config (`./.librarian/puppet/config`)
225
+ * The environment
226
+ * The global config (`~/.librarian/puppet/config`)
227
+
228
+ You can inspect the final configuration with:
229
+
230
+ $ librarian-puppet config
231
+
232
+ You can find out where a particular key is set with:
233
+
234
+ $ librarian-puppet config KEY
235
+
236
+ You can set a key at the global level with:
237
+
238
+ $ librarian-puppet config KEY VALUE --global
239
+
240
+ And remove it with:
241
+
242
+ $ librarian-puppet config KEY --global --delete
243
+
244
+ You can set a key at the local level with:
245
+
246
+ $ librarian-puppet config KEY VALUE --local
247
+
248
+ And remove it with:
249
+
250
+ $ librarian-puppet config KEY --local --delete
251
+
252
+ You cannot set or delete environment-level config keys with the CLI.
253
+
254
+ Configuration set at either the global or local level will affect subsequent
255
+ invocations of `librarian-puppet`. Configurations set at the environment level are
256
+ not saved and will not affect subsequent invocations of `librarian-puppet`.
257
+
258
+ You can pass a config at the environment level by taking the original config key
259
+ and transforming it: replace hyphens (`-`) with underscores (`_`) and periods
260
+ (`.`) with doubled underscores (`__`), uppercase, and finally prefix with
261
+ `LIBRARIAN_PUPPET_`. For example, to pass a config in the environment for the key
262
+ `part-one.part-two`, set the environment variable
263
+ `LIBRARIAN_PUPPET_PART_ONE__PART_TWO`.
264
+
265
+ Configuration affects how various commands operate.
266
+
267
+ * The `path` config sets the directory to install to. If a relative
268
+ path, it is relative to the directory containing the `Puppetfile`. The
269
+ equivalent environment variable is `LIBRARIAN_PUPPET_PATH`.
270
+
271
+ * The `tmp` config sets the cache directory for librarian. If a relative
272
+ path, it is relative to the directory containing the `Puppetfile`. The
273
+ equivalent environment variable is `LIBRARIAN_PUPPET_TMP`.
274
+
275
+ Configuration can be set by passing specific options to other commands.
276
+
277
+ * The `path` config can be set at the local level by passing the `--path` option
278
+ to the `install` command. It can be unset at the local level by passing the
279
+ `--no-path` option to the `install` command. Note that if this is set at the
280
+ environment or global level then, even if `--no-path` is given as an option,
281
+ the environment or global config will be used.
282
+
283
+
284
+ ## Rsync Option
285
+
286
+ The default convergence strategy between the cache and the module directory is
287
+ to execute an `rm -r` on the module directory and just `cp -r` from the cache.
288
+ This causes the module to be removed from the module path every time librarian
289
+ puppet updates, regardless of whether the content has changed. This can cause
290
+ some problems in environments with lots of change. The problem arises when the
291
+ module directory gets removed while Puppet is trying to read files inside it.
292
+ The `puppet master` process will lose its CWD and the catalog will fail to
293
+ compile. To avoid this, you can use `rsync` to implement a more conservative
294
+ convergence strategy. This will use `rsync` with the `-avz` and `--delete`
295
+ flags instead of a `rm -r` and `cp -r`. To use this feature, just set the
296
+ `rsync` configuration setting to `true`.
297
+
298
+ $ librarian-puppet config rsync true --global
299
+
300
+ Alternatively, using an environment variable:
301
+
302
+ LIBRARIAN_PUPPET_RSYNC='true'
303
+
304
+ Note that the directories will still be purged if you run librarian-puppet with
305
+ the --clean or --destructive flags.
306
+
307
+ ## How to Contribute
308
+
309
+ * Pull requests please.
310
+ * Bonus points for feature branches.
311
+
312
+ ## Reporting Issues
313
+
314
+ Bug reports to the github issue tracker please.
315
+ Please include:
316
+
317
+ * Relevant `Puppetfile` and `Puppetfile.lock` files
318
+ * Version of ruby, librarian-puppet, and puppet
319
+ * What distro
320
+ * Please run the `librarian-puppet` commands in verbose mode by using the
321
+ `--verbose` flag, and include the verbose output in the bug report as well.
322
+
323
+
324
+ ## License
325
+ Please see the [LICENSE](https://github.com/rodjek/librarian-puppet/blob/master/LICENSE)
326
+ file.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $:.unshift(lib) unless $:.include?(lib)
5
+
6
+ require 'librarian/puppet/cli'
7
+ Librarian::Puppet::Cli.bin!
@@ -0,0 +1,36 @@
1
+ require 'librarian'
2
+ require 'fileutils'
3
+
4
+ require 'librarian/puppet/extension'
5
+ require 'librarian/puppet/version'
6
+
7
+ require 'librarian/action/install'
8
+
9
+ module Librarian
10
+ module Puppet
11
+ @@puppet_version = nil
12
+
13
+ # Output of puppet --version, typically x.y.z
14
+ # For Puppet Enterprise it contains the PE version too, ie. 3.4.3 (Puppet Enterprise 3.2.1)
15
+ def puppet_version
16
+ return @@puppet_version unless @@puppet_version.nil?
17
+
18
+ begin
19
+ @@puppet_version = Librarian::Posix.run!(%W{puppet --version}).strip
20
+ rescue Errno::ENOENT, Librarian::Posix::CommandFailure => error
21
+ msg = "Unable to load puppet. Please install it using native packages for your platform (eg .deb, .rpm, .dmg, etc)."
22
+ msg += "\npuppet --version returned #{error.status}" if error.respond_to? :status
23
+ msg += "\n#{error.message}" unless error.message.nil?
24
+ $stderr.puts msg
25
+ exit 1
26
+ end
27
+ return @@puppet_version
28
+ end
29
+
30
+ # Puppet version x.y.z translated as a Gem version
31
+ def puppet_gem_version
32
+ Gem::Version.create(puppet_version.split(' ').first.strip.gsub('-', '.'))
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,2 @@
1
+ require "librarian/puppet/action/install"
2
+ require "librarian/puppet/action/resolve"
@@ -0,0 +1,26 @@
1
+ require 'librarian/action/install'
2
+
3
+ module Librarian
4
+ module Puppet
5
+ module Action
6
+ class Install < Librarian::Action::Install
7
+
8
+ private
9
+
10
+ def create_install_path
11
+ install_path.rmtree if install_path.exist? && destructive?
12
+ install_path.mkpath
13
+ end
14
+
15
+ def destructive?
16
+ environment.config_db.local['destructive'] == 'true'
17
+ end
18
+
19
+ def check_specfile
20
+ # don't fail if Puppetfile doesn't exist as we'll use the Modulefile or metadata.json
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end