librarian-puppet-rethinc 3.0.1.1
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 +7 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.md +331 -0
- data/bin/librarian-puppet +7 -0
- data/lib/librarian/puppet/action/install.rb +26 -0
- data/lib/librarian/puppet/action/resolve.rb +26 -0
- data/lib/librarian/puppet/action.rb +2 -0
- data/lib/librarian/puppet/cli.rb +117 -0
- data/lib/librarian/puppet/dependency.rb +26 -0
- data/lib/librarian/puppet/dsl.rb +123 -0
- data/lib/librarian/puppet/environment.rb +66 -0
- data/lib/librarian/puppet/extension.rb +9 -0
- data/lib/librarian/puppet/lockfile.rb +78 -0
- data/lib/librarian/puppet/resolver.rb +21 -0
- data/lib/librarian/puppet/rethinc.rb +1 -0
- data/lib/librarian/puppet/source/forge/repo.rb +158 -0
- data/lib/librarian/puppet/source/forge/repo_v1.rb +92 -0
- data/lib/librarian/puppet/source/forge/repo_v3.rb +100 -0
- data/lib/librarian/puppet/source/forge.rb +180 -0
- data/lib/librarian/puppet/source/git.rb +74 -0
- data/lib/librarian/puppet/source/githubtarball/repo.rb +172 -0
- data/lib/librarian/puppet/source/githubtarball.rb +137 -0
- data/lib/librarian/puppet/source/local.rb +176 -0
- data/lib/librarian/puppet/source/path.rb +12 -0
- data/lib/librarian/puppet/source/repo.rb +46 -0
- data/lib/librarian/puppet/source.rb +4 -0
- data/lib/librarian/puppet/templates/Puppetfile +25 -0
- data/lib/librarian/puppet/util.rb +78 -0
- data/lib/librarian/puppet/version.rb +5 -0
- data/lib/librarian/puppet.rb +25 -0
- metadata +242 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2442dff3152aa22e2f28aff219b0c2013fe719b42465e7403c5efebe0af2e559
|
4
|
+
data.tar.gz: 9192fc1b8379ca0be3310c1c515ba82b9056be737449fefe7ba86fc9f99e5fee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: edd261044f2bb804645bc971346e5cf896c495e542d18df97a1f8b181c5b7ca45a44becfca688015ca68a9acbc362786a5ae07470c23cc52d6ed272558fcfd6b
|
7
|
+
data.tar.gz: 80615bcb701004592faeb5550725bac5ab57d76f1bd520db94246f8f752325a9211cac415741eeb619d414db83ce569be1cf4d90b8505b3c3e74fb4c52ddc5b8
|
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,331 @@
|
|
1
|
+
# Librarian-puppet
|
2
|
+
|
3
|
+
[](https://travis-ci.org/voxpupuli/librarian-puppet)
|
4
|
+
|
5
|
+
## Introduction
|
6
|
+
|
7
|
+
Librarian-puppet is a bundler for your puppet infrastructure. You can use
|
8
|
+
librarian-puppet to manage the puppet modules your infrastructure depends on,
|
9
|
+
whether the modules come from the [Puppet Forge](https://forge.puppet.com/),
|
10
|
+
Git repositories or just a path.
|
11
|
+
|
12
|
+
* Librarian-puppet can reuse the dependencies listed in your `Modulefile` or `metadata.json`
|
13
|
+
* Forge modules can be installed from [Puppetlabs Forge](https://forge.puppet.com/) or an internal Forge such as [Pulp](http://www.pulpproject.org/)
|
14
|
+
* Git modules can be installed from a branch, tag or specific commit, optionally using a path inside the repository
|
15
|
+
* Modules can be installed from GitHub using tarballs, without needing Git installed
|
16
|
+
* Modules can be installed from a filesystem path
|
17
|
+
* Module dependencies are resolved transitively without needing to list all the modules explicitly
|
18
|
+
|
19
|
+
|
20
|
+
Librarian-puppet manages your `modules/` directory for you based on your
|
21
|
+
`Puppetfile`. Your `Puppetfile` becomes the authoritative source for what
|
22
|
+
modules you require and at what version, tag or branch.
|
23
|
+
|
24
|
+
Once using Librarian-puppet you should not modify the contents of your `modules`
|
25
|
+
directory. The individual modules' repos should be updated, tagged with a new
|
26
|
+
release and the version bumped in your Puppetfile.
|
27
|
+
|
28
|
+
It is based on [Librarian](https://github.com/applicationsonline/librarian), a
|
29
|
+
framework for writing bundlers, which are tools that resolve, fetch, install,
|
30
|
+
and isolate a project's dependencies.
|
31
|
+
|
32
|
+
## Versions
|
33
|
+
|
34
|
+
Librarian-Puppet 3.0.0 and newer requires Ruby >= 2.0. Use version 2.2.4 if you need support for Puppet 3.7 or earlier, or Ruby 1.9 or earlier. Note that [Puppet 4.10 and newer require Ruby 2.1](https://puppet.com/docs/puppet/4.10/system_requirements.html#prerequisites) or newer.
|
35
|
+
|
36
|
+
Librarian-Puppet 2.0.0 and newer requires Ruby >= 1.9 and uses Puppet Forge API v3. For Ruby 1.8 use 1.5.0.
|
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
|
+
Note that Librarian-puppet recognizes the [r10k Puppetfile's](https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd) additional
|
134
|
+
options, `:tag`, `:commit`, and `:branch`, but only as aliases for `:ref`.
|
135
|
+
That is, there is no implementation of r10k's optimizations around fetching
|
136
|
+
these different types of git objects.
|
137
|
+
|
138
|
+
The Git source also supports a `:path =>` option. If we use the path option,
|
139
|
+
Librarian-puppet will navigate down into the Git repository and only use the
|
140
|
+
specified subdirectory. Some people have the habit of having a single repository
|
141
|
+
with many modules in it. If we need a module from such a repository, we can
|
142
|
+
use the `:path =>` option here to help Librarian-puppet drill down and find the
|
143
|
+
module subdirectory.
|
144
|
+
|
145
|
+
mod 'puppetlabs-apt',
|
146
|
+
:git => "git://github.com/fake/puppet-modules.git",
|
147
|
+
:path => "modules/apt"
|
148
|
+
|
149
|
+
Our puppet infrastructure repository depends on the `apt` module, which we have
|
150
|
+
stored as a directory under our `puppet-modules` git repos.
|
151
|
+
|
152
|
+
mod 'puppetlabs-apache', '0.6.0',
|
153
|
+
:github_tarball => 'puppetlabs/puppetlabs-apache'
|
154
|
+
|
155
|
+
Our puppet infrastructure repository depends on the `puppetlabs-apache` module,
|
156
|
+
to be downloaded from GitHub tarball.
|
157
|
+
|
158
|
+
mod 'acme-mymodule', :path => './some_folder'
|
159
|
+
|
160
|
+
Our puppet infrastructure repository depends on the `acme-mymodule` module,
|
161
|
+
which is already in the filesystem.
|
162
|
+
|
163
|
+
exclusion 'acme-bad_module'
|
164
|
+
|
165
|
+
Exclude the module `acme-bad_module` from resolution and installation.
|
166
|
+
|
167
|
+
## How to Use
|
168
|
+
|
169
|
+
Install librarian-puppet:
|
170
|
+
|
171
|
+
$ gem install librarian-puppet
|
172
|
+
|
173
|
+
Prepare your puppet infrastructure repository:
|
174
|
+
|
175
|
+
$ cd ~/path/to/puppet-inf-repos
|
176
|
+
$ (git) rm -rf modules
|
177
|
+
$ librarian-puppet init
|
178
|
+
|
179
|
+
Librarian-puppet takes over your `modules/` directory, and will always
|
180
|
+
reinstall (if missing) the modules listed the `Puppetfile.lock` into your
|
181
|
+
`modules/` directory, therefore you do not need your `modules/` directory to be
|
182
|
+
tracked in Git.
|
183
|
+
|
184
|
+
Librarian-puppet uses a `.tmp/` directory for tempfiles and caches. You should
|
185
|
+
not track this directory in Git.
|
186
|
+
|
187
|
+
Running `librarian-puppet init` will create a skeleton Puppetfile for you as
|
188
|
+
well as adding `tmp/` and `modules/` to your `.gitignore`.
|
189
|
+
|
190
|
+
$ librarian-puppet install [--clean] [--verbose]
|
191
|
+
|
192
|
+
This command looks at each `mod` declaration and fetches the module from the
|
193
|
+
source specified. This command writes the complete resolution into
|
194
|
+
`Puppetfile.lock` and then copies all of the fetched modules into your
|
195
|
+
`modules/` directory, overwriting whatever was there before.
|
196
|
+
|
197
|
+
Librarian-puppet support both v1 and v3 of the Puppet Forge API.
|
198
|
+
Specify a specific API version when installing modules:
|
199
|
+
|
200
|
+
$ librarian-puppet install --use-v1-api # this is default; ignored for official Puppet Forge
|
201
|
+
$ librarian-puppet install --no-use-v1-api # use the v3 API; default for official Puppet Forge
|
202
|
+
|
203
|
+
Please note that this does not apply for the official Puppet Forge, where v3 is used by default.
|
204
|
+
|
205
|
+
Get an overview of your `Puppetfile.lock` with:
|
206
|
+
|
207
|
+
$ librarian-puppet show
|
208
|
+
|
209
|
+
Inspect the details of specific resolved dependencies with:
|
210
|
+
|
211
|
+
$ librarian-puppet show NAME1 [NAME2, ...]
|
212
|
+
|
213
|
+
Find out which dependencies are outdated and may be updated:
|
214
|
+
|
215
|
+
$ librarian-puppet outdated [--verbose]
|
216
|
+
|
217
|
+
Update the version of a dependency:
|
218
|
+
|
219
|
+
$ librarian-puppet update apt [--verbose]
|
220
|
+
$ git diff Puppetfile.lock
|
221
|
+
$ git add Puppetfile.lock
|
222
|
+
$ git commit -m "bumped the version of apt up to 0.0.4."
|
223
|
+
|
224
|
+
## Configuration
|
225
|
+
|
226
|
+
Configuration comes from three sources with the following highest-to-lowest
|
227
|
+
precedence:
|
228
|
+
|
229
|
+
* The local config (`./.librarian/puppet/config`)
|
230
|
+
* The environment
|
231
|
+
* The global config (`~/.librarian/puppet/config`)
|
232
|
+
|
233
|
+
You can inspect the final configuration with:
|
234
|
+
|
235
|
+
$ librarian-puppet config
|
236
|
+
|
237
|
+
You can find out where a particular key is set with:
|
238
|
+
|
239
|
+
$ librarian-puppet config KEY
|
240
|
+
|
241
|
+
You can set a key at the global level with:
|
242
|
+
|
243
|
+
$ librarian-puppet config KEY VALUE --global
|
244
|
+
|
245
|
+
And remove it with:
|
246
|
+
|
247
|
+
$ librarian-puppet config KEY --global --delete
|
248
|
+
|
249
|
+
You can set a key at the local level with:
|
250
|
+
|
251
|
+
$ librarian-puppet config KEY VALUE --local
|
252
|
+
|
253
|
+
And remove it with:
|
254
|
+
|
255
|
+
$ librarian-puppet config KEY --local --delete
|
256
|
+
|
257
|
+
You cannot set or delete environment-level config keys with the CLI.
|
258
|
+
|
259
|
+
Configuration set at either the global or local level will affect subsequent
|
260
|
+
invocations of `librarian-puppet`. Configurations set at the environment level are
|
261
|
+
not saved and will not affect subsequent invocations of `librarian-puppet`.
|
262
|
+
|
263
|
+
You can pass a config at the environment level by taking the original config key
|
264
|
+
and transforming it: replace hyphens (`-`) with underscores (`_`) and periods
|
265
|
+
(`.`) with doubled underscores (`__`), uppercase, and finally prefix with
|
266
|
+
`LIBRARIAN_PUPPET_`. For example, to pass a config in the environment for the key
|
267
|
+
`part-one.part-two`, set the environment variable
|
268
|
+
`LIBRARIAN_PUPPET_PART_ONE__PART_TWO`.
|
269
|
+
|
270
|
+
Configuration affects how various commands operate.
|
271
|
+
|
272
|
+
* The `path` config sets the directory to install to. If a relative
|
273
|
+
path, it is relative to the directory containing the `Puppetfile`. The
|
274
|
+
equivalent environment variable is `LIBRARIAN_PUPPET_PATH`.
|
275
|
+
|
276
|
+
* The `tmp` config sets the cache directory for librarian. If a relative
|
277
|
+
path, it is relative to the directory containing the `Puppetfile`. The
|
278
|
+
equivalent environment variable is `LIBRARIAN_PUPPET_TMP`.
|
279
|
+
|
280
|
+
Configuration can be set by passing specific options to other commands.
|
281
|
+
|
282
|
+
* The `path` config can be set at the local level by passing the `--path` option
|
283
|
+
to the `install` command. It can be unset at the local level by passing the
|
284
|
+
`--no-path` option to the `install` command. Note that if this is set at the
|
285
|
+
environment or global level then, even if `--no-path` is given as an option,
|
286
|
+
the environment or global config will be used.
|
287
|
+
|
288
|
+
|
289
|
+
## Rsync Option
|
290
|
+
|
291
|
+
The default convergence strategy between the cache and the module directory is
|
292
|
+
to execute an `rm -r` on the module directory and just `cp -r` from the cache.
|
293
|
+
This causes the module to be removed from the module path every time librarian
|
294
|
+
puppet updates, regardless of whether the content has changed. This can cause
|
295
|
+
some problems in environments with lots of change. The problem arises when the
|
296
|
+
module directory gets removed while Puppet is trying to read files inside it.
|
297
|
+
The `puppet master` process will lose its CWD and the catalog will fail to
|
298
|
+
compile. To avoid this, you can use `rsync` to implement a more conservative
|
299
|
+
convergence strategy. This will use `rsync` with the `-avz` and `--delete`
|
300
|
+
flags instead of a `rm -r` and `cp -r`. To use this feature, just set the
|
301
|
+
`rsync` configuration setting to `true`.
|
302
|
+
|
303
|
+
$ librarian-puppet config rsync true --global
|
304
|
+
|
305
|
+
Alternatively, using an environment variable:
|
306
|
+
|
307
|
+
LIBRARIAN_PUPPET_RSYNC='true'
|
308
|
+
|
309
|
+
Note that the directories will still be purged if you run librarian-puppet with
|
310
|
+
the --clean or --destructive flags.
|
311
|
+
|
312
|
+
## How to Contribute
|
313
|
+
|
314
|
+
* Pull requests please.
|
315
|
+
* Bonus points for feature branches.
|
316
|
+
|
317
|
+
## Reporting Issues
|
318
|
+
|
319
|
+
Bug reports to the github issue tracker please.
|
320
|
+
Please include:
|
321
|
+
|
322
|
+
* Relevant `Puppetfile` and `Puppetfile.lock` files
|
323
|
+
* Version of ruby, librarian-puppet, and puppet
|
324
|
+
* What distro
|
325
|
+
* Please run the `librarian-puppet` commands in verbose mode by using the
|
326
|
+
`--verbose` flag, and include the verbose output in the bug report as well.
|
327
|
+
|
328
|
+
|
329
|
+
## License
|
330
|
+
Please see the [LICENSE](https://github.com/voxpupuli/librarian-puppet/blob/master/LICENSE)
|
331
|
+
file.
|
@@ -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
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'librarian/action/resolve'
|
2
|
+
require 'librarian/puppet/resolver'
|
3
|
+
|
4
|
+
module Librarian
|
5
|
+
module Puppet
|
6
|
+
module Action
|
7
|
+
class Resolve < Librarian::Action::Resolve
|
8
|
+
include Librarian::Puppet::Util
|
9
|
+
|
10
|
+
def run
|
11
|
+
super
|
12
|
+
manifests = environment.lock.manifests.select{ |m| m.name }
|
13
|
+
dupes = manifests.group_by{ |m| module_name(m.name) }.select { |k, v| v.size > 1 }
|
14
|
+
dupes.each do |k,v|
|
15
|
+
warn("Dependency on module '#{k}' is fullfilled by multiple modules and only one will be used: #{v.map{|m|m.name}}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def resolver
|
20
|
+
Resolver.new(environment)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'librarian/helpers'
|
2
|
+
|
3
|
+
require 'librarian/cli'
|
4
|
+
require 'librarian/puppet'
|
5
|
+
require 'librarian/puppet/action'
|
6
|
+
|
7
|
+
module Librarian
|
8
|
+
module Puppet
|
9
|
+
class Cli < Librarian::Cli
|
10
|
+
include Librarian::Puppet::Util
|
11
|
+
|
12
|
+
module Particularity
|
13
|
+
def root_module
|
14
|
+
Puppet
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
include Particularity
|
19
|
+
extend Particularity
|
20
|
+
|
21
|
+
source_root Pathname.new(__FILE__).dirname.join("templates")
|
22
|
+
|
23
|
+
def init
|
24
|
+
copy_file environment.specfile_name
|
25
|
+
|
26
|
+
if File.exists? ".gitignore"
|
27
|
+
gitignore = File.read('.gitignore').split("\n")
|
28
|
+
else
|
29
|
+
gitignore = []
|
30
|
+
end
|
31
|
+
|
32
|
+
gitignore << ".tmp/" unless gitignore.include? ".tmp/"
|
33
|
+
gitignore << "modules/" unless gitignore.include? "modules/"
|
34
|
+
|
35
|
+
File.open(".gitignore", 'w') do |f|
|
36
|
+
f.puts gitignore.join("\n")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "install", "Resolves and installs all of the dependencies you specify."
|
41
|
+
option "quiet", :type => :boolean, :default => false
|
42
|
+
option "verbose", :type => :boolean, :default => false
|
43
|
+
option "line-numbers", :type => :boolean, :default => false
|
44
|
+
option "clean", :type => :boolean, :default => false
|
45
|
+
option "strip-dot-git", :type => :boolean
|
46
|
+
option "path", :type => :string
|
47
|
+
option "destructive", :type => :boolean, :default => false
|
48
|
+
option "local", :type => :boolean, :default => false
|
49
|
+
option "use-v1-api", :type => :boolean, :default => true
|
50
|
+
option "use-short-cache-path", :type => :boolean, :default => false
|
51
|
+
def install
|
52
|
+
|
53
|
+
ensure!
|
54
|
+
clean! if options["clean"]
|
55
|
+
unless options["destructive"].nil?
|
56
|
+
environment.config_db.local['destructive'] = options['destructive'].to_s
|
57
|
+
end
|
58
|
+
if options.include?("strip-dot-git")
|
59
|
+
strip_dot_git_val = options["strip-dot-git"] ? "1" : nil
|
60
|
+
environment.config_db.local["install.strip-dot-git"] = strip_dot_git_val
|
61
|
+
end
|
62
|
+
if options.include?("path")
|
63
|
+
environment.config_db.local["path"] = options["path"]
|
64
|
+
end
|
65
|
+
|
66
|
+
environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
|
67
|
+
environment.config_db.local['mode'] = options['local'] ? 'local' : nil
|
68
|
+
environment.config_db.local['use-short-cache-path'] = options['use-short-cache-path'] ? '1' : nil
|
69
|
+
|
70
|
+
resolve!
|
71
|
+
debug { "Install: dependencies resolved"}
|
72
|
+
install!
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "update", "Updates and installs the dependencies you specify."
|
76
|
+
option "verbose", :type => :boolean, :default => false
|
77
|
+
option "line-numbers", :type => :boolean, :default => false
|
78
|
+
option "use-v1-api", :type => :boolean, :default => true
|
79
|
+
def update(*names)
|
80
|
+
|
81
|
+
environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
|
82
|
+
|
83
|
+
warn("Usage of module/name is deprecated, use module-name") if names.any? {|n| n.include?("/")}
|
84
|
+
# replace / to - in the module names
|
85
|
+
super(*names.map{|n| normalize_name(n)})
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "package", "Cache the puppet modules in vendor/puppet/cache."
|
89
|
+
option "quiet", :type => :boolean, :default => false
|
90
|
+
option "verbose", :type => :boolean, :default => false
|
91
|
+
option "line-numbers", :type => :boolean, :default => false
|
92
|
+
option "clean", :type => :boolean, :default => false
|
93
|
+
option "strip-dot-git", :type => :boolean
|
94
|
+
option "path", :type => :string
|
95
|
+
option "destructive", :type => :boolean, :default => false
|
96
|
+
def package
|
97
|
+
environment.vendor!
|
98
|
+
install
|
99
|
+
end
|
100
|
+
|
101
|
+
def version
|
102
|
+
say "librarian-puppet v#{Librarian::Puppet::VERSION}"
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
# override the actions to use our own
|
108
|
+
|
109
|
+
def install!(options = { })
|
110
|
+
Action::Install.new(environment, options).run
|
111
|
+
end
|
112
|
+
def resolve!(options = { })
|
113
|
+
Action::Resolve.new(environment, options).run
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Librarian
|
2
|
+
module Puppet
|
3
|
+
|
4
|
+
class Dependency < Librarian::Dependency
|
5
|
+
|
6
|
+
include Librarian::Puppet::Util
|
7
|
+
|
8
|
+
attr_accessor :parent
|
9
|
+
private :parent=
|
10
|
+
|
11
|
+
def initialize(name, requirement, source, parent = nil)
|
12
|
+
# Issue #235 fail if forge source is not defined
|
13
|
+
raise Error, "forge entry is not defined in Puppetfile" if source.instance_of?(Array) && source.empty?
|
14
|
+
|
15
|
+
self.parent = parent
|
16
|
+
super(normalize_name(name), requirement, source)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"#{name} (#{requirement}) <#{source}> (from #{parent.nil? ? '<nil>' : parent})"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|