r10k 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.mkd +210 -0
  4. data/CONTRIBUTING.mkd +105 -0
  5. data/Gemfile +2 -6
  6. data/README.mkd +97 -0
  7. data/doc/common-patterns.mkd +44 -0
  8. data/doc/dynamic-environments.mkd +12 -5
  9. data/doc/dynamic-environments/configuration.mkd +16 -1
  10. data/doc/dynamic-environments/{git-environments.markdown → git-environments.mkd} +13 -9
  11. data/doc/dynamic-environments/introduction.mkd +1 -2
  12. data/doc/dynamic-environments/master-configuration.mkd +70 -0
  13. data/doc/dynamic-environments/quickstart.mkd +241 -0
  14. data/doc/dynamic-environments/svn-environments.mkd +45 -0
  15. data/doc/dynamic-environments/usage.mkd +44 -5
  16. data/doc/dynamic-environments/workflow-guide.mkd +247 -0
  17. data/doc/faq.mkd +52 -0
  18. data/doc/puppetfile.mkd +203 -0
  19. data/lib/r10k/action/cri_runner.rb +75 -0
  20. data/lib/r10k/action/deploy.rb +9 -0
  21. data/lib/r10k/action/deploy/display.rb +104 -0
  22. data/lib/r10k/action/deploy/environment.rb +92 -0
  23. data/lib/r10k/action/deploy/module.rb +70 -0
  24. data/lib/r10k/action/puppetfile.rb +10 -0
  25. data/lib/r10k/action/puppetfile/check.rb +41 -0
  26. data/lib/r10k/action/puppetfile/cri_runner.rb +32 -0
  27. data/lib/r10k/action/puppetfile/install.rb +53 -0
  28. data/lib/r10k/action/puppetfile/purge.rb +37 -0
  29. data/lib/r10k/action/runner.rb +36 -0
  30. data/lib/r10k/action/visitor.rb +31 -0
  31. data/lib/r10k/cli/deploy.rb +14 -45
  32. data/lib/r10k/cli/puppetfile.rb +15 -53
  33. data/lib/r10k/deployment.rb +113 -58
  34. data/lib/r10k/deployment/basedir.rb +3 -38
  35. data/lib/r10k/deployment/config.rb +2 -1
  36. data/lib/r10k/deployment/source.rb +2 -0
  37. data/lib/r10k/environment/base.rb +40 -0
  38. data/lib/r10k/environment/git.rb +14 -17
  39. data/lib/r10k/environment/svn.rb +31 -15
  40. data/lib/r10k/errors.rb +33 -22
  41. data/lib/r10k/errors/formatting.rb +28 -0
  42. data/lib/r10k/execution.rb +2 -0
  43. data/lib/r10k/git/cache.rb +1 -6
  44. data/lib/r10k/git/errors.rb +1 -2
  45. data/lib/r10k/git/ref.rb +1 -1
  46. data/lib/r10k/module.rb +1 -1
  47. data/lib/r10k/module/base.rb +94 -2
  48. data/lib/r10k/module/forge.rb +33 -30
  49. data/lib/r10k/module/git.rb +13 -9
  50. data/lib/r10k/module/svn.rb +41 -28
  51. data/lib/r10k/puppetfile.rb +17 -1
  52. data/lib/r10k/semver.rb +2 -0
  53. data/lib/r10k/source/base.rb +8 -0
  54. data/lib/r10k/source/git.rb +1 -1
  55. data/lib/r10k/source/svn.rb +23 -5
  56. data/lib/r10k/svn/remote.rb +23 -3
  57. data/lib/r10k/svn/working_dir.rb +60 -9
  58. data/lib/r10k/task.rb +1 -0
  59. data/lib/r10k/task/deployment.rb +9 -1
  60. data/lib/r10k/task/environment.rb +2 -0
  61. data/lib/r10k/task/module.rb +1 -0
  62. data/lib/r10k/task/puppetfile.rb +3 -0
  63. data/lib/r10k/task_runner.rb +1 -0
  64. data/lib/r10k/util/attempt.rb +84 -0
  65. data/lib/r10k/util/basedir.rb +65 -0
  66. data/lib/r10k/util/purgeable.rb +55 -45
  67. data/lib/r10k/util/setopts.rb +53 -0
  68. data/lib/r10k/util/subprocess.rb +6 -30
  69. data/lib/r10k/util/subprocess/posix/runner.rb +29 -2
  70. data/lib/r10k/util/subprocess/result.rb +17 -4
  71. data/lib/r10k/util/subprocess/subprocess_error.rb +24 -0
  72. data/lib/r10k/version.rb +1 -1
  73. data/r10k.gemspec +7 -29
  74. data/spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile +1 -0
  75. data/spec/fixtures/unit/puppetfile/load-error/Puppetfile +1 -0
  76. data/spec/matchers/exit_with.rb +28 -0
  77. data/spec/r10k-mocks.rb +3 -0
  78. data/spec/r10k-mocks/mock_config.rb +28 -0
  79. data/spec/r10k-mocks/mock_env.rb +7 -0
  80. data/spec/r10k-mocks/mock_source.rb +10 -0
  81. data/spec/shared-examples/git-ref.rb +7 -7
  82. data/spec/spec_helper.rb +17 -5
  83. data/spec/unit/action/cri_runner_spec.rb +76 -0
  84. data/spec/unit/action/puppetfile/cri_action_spec.rb +65 -0
  85. data/spec/unit/action/runner_spec.rb +64 -0
  86. data/spec/unit/action/visitor_spec.rb +39 -0
  87. data/spec/unit/deployment_spec.rb +142 -0
  88. data/spec/unit/environment/base_spec.rb +38 -0
  89. data/spec/unit/environment/git_spec.rb +40 -10
  90. data/spec/unit/environment/svn_spec.rb +41 -4
  91. data/spec/unit/errors/formatting_spec.rb +84 -0
  92. data/spec/unit/git/alternates_spec.rb +1 -1
  93. data/spec/unit/git/head_spec.rb +1 -1
  94. data/spec/unit/git/ref_spec.rb +1 -1
  95. data/spec/unit/git/working_dir_spec.rb +1 -1
  96. data/spec/unit/module/base_spec.rb +72 -0
  97. data/spec/unit/module/forge_spec.rb +49 -8
  98. data/spec/unit/module/git_spec.rb +78 -0
  99. data/spec/unit/module/svn_spec.rb +40 -4
  100. data/spec/unit/module_spec.rb +3 -3
  101. data/spec/unit/puppetfile_spec.rb +84 -0
  102. data/spec/unit/settings/container_spec.rb +1 -1
  103. data/spec/unit/source/base_spec.rb +31 -0
  104. data/spec/unit/source/git_spec.rb +7 -7
  105. data/spec/unit/source/svn_spec.rb +1 -1
  106. data/spec/unit/svn/working_dir_spec.rb +56 -0
  107. data/spec/unit/util/attempt_spec.rb +82 -0
  108. data/spec/unit/util/setopts_spec.rb +59 -0
  109. data/spec/unit/util/subprocess/result_spec.rb +36 -0
  110. data/spec/unit/util/subprocess/subprocess_error_spec.rb +26 -0
  111. data/spec/unit/util/subprocess_spec.rb +2 -7
  112. metadata +83 -100
  113. data/.nodeset.yml +0 -7
  114. data/.rspec +0 -1
  115. data/README.markdown +0 -276
  116. data/Rakefile +0 -1
  117. data/doc/puppetfile.markdown +0 -87
  118. data/spec/rspec-system-r10k/puppetfile.rb +0 -24
  119. data/spec/rspec-system-r10k/tmpdir.rb +0 -32
  120. data/spec/system-provisioning/el.rb +0 -38
  121. data/spec/system/module/forge/install_spec.rb +0 -51
  122. data/spec/system/module/git/install_spec.rb +0 -117
  123. data/spec/system/module/svn/install_spec.rb +0 -51
  124. data/spec/system/module/svn/update_spec.rb +0 -38
  125. data/spec/system/spec_helper.rb +0 -60
  126. data/spec/system/system-helpers.rb +0 -4
  127. data/spec/system/version_spec.rb +0 -7
@@ -1,7 +0,0 @@
1
- ---
2
- default_set: 'centos-59-x64'
3
- sets:
4
- 'centos-59-x64':
5
- nodes:
6
- "main":
7
- prefab: 'centos-59-x64'
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --default_path spec/unit
@@ -1,276 +0,0 @@
1
- r10k
2
- ====
3
-
4
- Puppet environment and module deployment
5
-
6
- [![Build Status](https://travis-ci.org/adrienthebo/r10k.png?branch=master)](https://travis-ci.org/adrienthebo/r10k)
7
-
8
- Description
9
- -----------
10
-
11
- [librarian-puppet]: https://github.com/rodjek/librarian-puppet
12
- [workflow]: http://puppetlabs.com/blog/git-workflow-and-puppet-environments/
13
-
14
- r10k provides a general purpose toolset for deploying Puppet environments and
15
- modules. It implements the [Puppetfile][librarian-puppet] format and provides a native
16
- implementation of Puppet [dynamic environments][workflow].
17
-
18
- Installation
19
- ------------
20
-
21
- r10k supports the following Ruby versions:
22
-
23
- - 1.8.7 (POSIX minimum version)
24
- - 1.9.3 (Windows minimum version)
25
- - 2.0.0
26
- - 2.1.0
27
-
28
- ### Rubygems
29
-
30
- For general use, you should install r10k from Ruby gems:
31
-
32
- gem install r10k
33
- r10k help
34
-
35
- ### Bundler
36
-
37
- If you have more specific needs or plan on modifying r10k you can run it out of
38
- a git repository using Bundler for dependencies:
39
-
40
- git clone git://github.com/adrienthebo/r10k
41
- cd r10k
42
- bundle install
43
- bundle exec r10k help
44
-
45
- ### Puppet Enterprise
46
-
47
- Puppet Enterprise uses its own Ruby, so you need to use the correct version of gem when installing r10k.
48
-
49
- /opt/puppet/bin/gem install r10k
50
- r10k help
51
-
52
- Common Commands
53
- ---------------
54
-
55
- ### Deploy all environments and Puppetfile specified modules
56
-
57
- r10k deploy environment -p
58
-
59
- ### Deploy all environments but don't update/install modules
60
-
61
- r10k deploy environment
62
-
63
- ### Deploy a specific environment, and its Puppetfile specified modules
64
-
65
- r10k deploy environment your_env -p
66
-
67
- ### Deploy a specific environment, but not its modules
68
-
69
- r10k deploy environment your_env
70
-
71
- ### Display all environments being managed by r10k
72
-
73
- r10k deploy display
74
-
75
- ### Display all environments being managed by r10k, and their modules.
76
-
77
- r10k deploy display -p
78
-
79
- Puppetfile support
80
- ------------------
81
-
82
- r10k can operate on a Puppetfile using the same syntax as librarian-puppet uses.
83
- Puppetfiles are a simple Ruby based DSL that specifies a list of modules to
84
- install, what version to install, and where to fetch them from. Unlike
85
- librarian-puppet dependency resolution is not yet implemented but is on the
86
- roadmap.
87
-
88
- Puppetfile based commands are under the `r10k puppetfile` subcommand.
89
-
90
- ### Installing modules from git
91
-
92
- Puppet modules can be installed from any valid git repository:
93
-
94
- mod 'rsyslog', :git => 'git://github.com/puppetlabs-operations/puppet-rsyslog.git'
95
-
96
- You can deploy a module from a specific branch, tag, or git ref. By default r10k
97
- will track `master` and will assume that you want to keep the module up to date.
98
- If you want to track a specific branch, then
99
-
100
- Examples:
101
-
102
- # track master
103
- mod 'filemapper',
104
- :git => 'git://github.com/adrienthebo/puppet-filemapper.git'
105
-
106
- # Install the filemapper module and track the 1.1.x branch
107
- mod 'filemapper',
108
- :git => 'git://github.com/adrienthebo/puppet-filemapper.git',
109
- :ref => '1.1.x'
110
-
111
- # Install filemapper and use the 1.1.1 tag
112
- mod 'filemapper',
113
- :git => 'git://github.com/adrienthebo/puppet-filemapper.git',
114
- :ref => '1.1.1'
115
-
116
- # Install filemapper and use a specific git commit
117
- mod 'filemapper',
118
- :git => 'git://github.com/adrienthebo/puppet-filemapper.git',
119
- :ref => 'ec2a06d287f744e324cca4e4c8dd65c38bc996e2'
120
-
121
- ### Installing modules from the Puppet forge
122
-
123
- Puppet modules can be installed from the forge using the Puppet module tool.
124
-
125
- # This is currently a noop but will be supported in the future.
126
- forge 'forge.puppetlabs.com'
127
-
128
- # Install puppetlabs-stdlib from the Forge
129
- mod 'puppetlabs/stdlib', '2.5.1'
130
-
131
- Basic Environment Structure
132
- ---------------------------
133
-
134
- r10k supports Dynamic Environments (see below), but simple environment structures
135
- are also supported.
136
-
137
- The basic structure of an environment that uses a Puppetfile to install modules is
138
-
139
- .
140
- |-- manifests
141
- |-- site.pp
142
- |-- Puppetfile
143
- |-- .gitignore
144
-
145
- site.pp would contain your node definitions, and the Puppetfile would specify the modules
146
- to be installed. r10k automatically creates the 'modules' directory when it applies the
147
- Puppetfile.
148
-
149
- It's important to put the modules directory in .gitignore so that git doesn't accidentally
150
- put it into the repo.
151
-
152
- modules/
153
-
154
- Dynamic environment support
155
- ---------------------------
156
-
157
- r10k implements the dynamic environment workflow. Given a git repository with
158
- multiple branches r10k can create an environment for each branch. This means
159
- that you can use git with the normal branch-develop-merge workflow, and easily
160
- test your changes as you work.
161
-
162
- Deployment commands are implemented under the `r10k deploy` subcommand.
163
-
164
- ### Git repository layout
165
-
166
- [modulepath]: http://docs.puppetlabs.com/references/stable/configuration.html#modulepath
167
-
168
- r10k makes the assumption that Puppet modules are stored in subdirectories of
169
- the Git repository. These directories are all loaded into the Puppet master with
170
- the [modulepath][modulepath] directive.
171
-
172
- For example, your Git repository would have a structure something like this:
173
-
174
- .
175
- ├── Puppetfile # An optional Puppetfile
176
- ├── dist # Internally developed generic modules
177
- └── site # Modules for deploying custom services
178
-
179
- ### Puppet master configuration
180
-
181
- In order to use dynamic environments, your Puppet masters will need to be
182
- configured to load manifests and modules relative to the requested environment:
183
-
184
- [master]
185
- modulepath = /etc/puppet/environments/$environment/modules:/etc/puppet/environments/$environment/dist
186
-
187
- # If you use a top level manifest dir
188
- manifestdir = /etc/puppet/environments/$environment/manifests
189
- # If you use a specific site wide manifest
190
- manifest = /etc/puppet/environments/$environment/manifests/nodes.pp
191
-
192
- Note that these settings go into the `[master]` section; you don't need to
193
- explicitly configure an environment section for each environment you want to
194
- use. (But you can if you want.)
195
-
196
- ### Using dynamic environments with a Puppetfile
197
-
198
-
199
- r10k can implement a hybrid workflow with dynamic environments and Puppetfiles.
200
- If a Puppetfile is available at the root of a deployed environment, r10k can
201
- create and manage the `modules` directory within your Git repository.
202
-
203
- It's recommended that you add `/modules` to your project .gitignore.
204
-
205
- A deployed environment with a Puppetfile will look something like this:
206
-
207
- .
208
- ├── Puppetfile # An optional Puppetfile
209
- ├── dist # Internally developed generic modules
210
- ├── modules # Puppet modules deployed by r10k
211
- └── site # Modules for deploying custom services
212
-
213
- It is also possible to set an alternate name/location for your `Puppetfile` and
214
- `modules` directory. This is useful if you want to control multiple environments
215
- and have a single location for your `Puppetfile`.
216
-
217
- Example:
218
-
219
- PUPPETFILE=/etc/r10k.d/Puppetfile.production \
220
- PUPPETFILE_DIR=/etc/puppet/modules/production \
221
- /usr/bin/r10k puppetfile install
222
-
223
- ### Dynamic environment configuration
224
-
225
- r10k uses a yaml based configuration file when handling deployments. The default
226
- location is in /etc/r10k.yaml and can be specified on the command line.
227
-
228
- ### Example
229
-
230
- # The location to use for storing cached Git repos
231
- :cachedir: '/var/cache/r10k'
232
-
233
- # A list of git repositories to create
234
- :sources:
235
- # This will clone the git repository and instantiate an environment per
236
- # branch in /etc/puppet/environments
237
- :plops:
238
- remote: 'git@github.com:my-org/org-shared-modules'
239
- basedir: '/etc/puppet/environments'
240
-
241
- Multiple git repositories can be specified, which is handy if environments are broken up by application.
242
- Application 1 could have its own environment repository with app1_dev, app1_tst, and app1_prd branches while
243
- Application 2 could have its own environment repository with app2_dev, app2_tst, app2_prd branches.
244
-
245
- You might want to take this approach if your environments vary greatly. If you often find yourself making
246
- changes to your Application 1 environments that don't belong in your Application 2 environments, merging changes
247
- can become difficult if all of your environment branches are in a single repository.
248
-
249
- This approach also makes security easier as teams can be given access to control their application's environments
250
- without being able to accidentally impact other groups.
251
-
252
- ### Multiple Environment Repositories Example
253
-
254
- # The location to use for storing cached Git repos
255
- :cachedir: '/var/cache/r10k'
256
-
257
- # A list of git repositories to create
258
- :sources:
259
- # This will clone the git repository and instantiate an environment per
260
- # branch in /etc/puppet/environments
261
- :app1:
262
- remote: 'git@github.com:my-org/app1-environments'
263
- basedir: '/etc/puppet/environments'
264
- :app2:
265
- remote: 'git@github.com:my-org/app2-environments'
266
- basedir: '/etc/puppet/environments'
267
-
268
- More information
269
- ----------------
270
-
271
- The original impetus for r10k is explained at http://somethingsinistral.net/blog/rethinking-puppet-deployment/
272
-
273
- Contributors
274
- ------------
275
-
276
- Please see the CHANGELOG for a listing of the (very awesome) contributors.
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require 'rspec-system/rake_task'
@@ -1,87 +0,0 @@
1
- Puppetfile
2
- ==========
3
-
4
- The Puppetfile is a way to reuse independent Puppet modules in your codebase.
5
-
6
- When directly working with Puppetfiles, you can use the `r10k puppetfile`
7
- subcommand to interact with a Puppetfile.
8
-
9
- When using r10k's deploy functionality, interacting with Puppetfiles is handled
10
- on a case by case basis.
11
-
12
- The Puppetfile format is actually implemented using a Ruby DSL so any valid Ruby
13
- expression can be used. That being said, being a bit too creative in the DSL
14
- can lead to surprising (read: bad) things happening, so consider keeping it
15
- simple.
16
-
17
- Module types
18
- ------------
19
-
20
- ### Git
21
-
22
- Modules can be installed via git.
23
-
24
- #### Examples
25
-
26
- # Install puppetlabs/apache and keep it up to date with 'master'
27
- mod 'apache',
28
- :git => 'https://github.com/puppetlabs/puppetlabs-apache'
29
-
30
- # Install puppetlabs/apache and track the 'docs_experiment' branch
31
- mod 'apache',
32
- :git => 'https://github.com/puppetlabs/puppetlabs-apache',
33
- :ref => 'docs_experiment'
34
-
35
- You can also use the exact object type you want to check out. This may be a
36
- little bit more work but it has the advantage that r10k make certain
37
- optimizations based on the object type that you specify.
38
-
39
- mod 'apache',
40
- :git => 'https://github.com/puppetlabs/puppetlabs-apache',
41
- :tag => '0.9.0'
42
-
43
- mod 'apache',
44
- :git => 'https://github.com/puppetlabs/puppetlabs-apache',
45
- :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
46
-
47
- You can also explicitly specify a branch, but this behaves the same as
48
- specifying :ref and is mainly useful for clarity.
49
-
50
- mod 'apache',
51
- :git => 'https://github.com/puppetlabs/puppetlabs-apache',
52
- :branch => 'docs_experiment'
53
-
54
- ### Forge
55
-
56
- Modules can be installed using the Puppet module tool.
57
-
58
- If no version is specified the latest version available at the time will be
59
- installed, and will be kept at that version.
60
-
61
- mod 'puppetlabs/apache'
62
-
63
- If a version is specified then that version will be installed.
64
-
65
- mod 'puppetlabs/apache', '0.10.0'
66
-
67
- If the version is set to :latest then the module will be always updated to the
68
- latest version available.
69
-
70
- mod 'puppetlabs/apache', :latest
71
-
72
- ### SVN
73
-
74
- Modules can be installed via SVN.
75
-
76
- mod 'apache',
77
- :svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk'
78
-
79
- mod 'apache',
80
- :svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
81
- :rev => '154'
82
-
83
- Alternately,
84
-
85
- mod 'apache',
86
- :svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
87
- :revision => '154'
@@ -1,24 +0,0 @@
1
- require 'tempfile'
2
-
3
- module RSpecSystem
4
- module Puppetfile
5
- def puppetfile_install(options = {})
6
- expected_exit_code = options.fetch(:exit_code, 0)
7
-
8
- shell %[r10k puppetfile install] do |results|
9
- expect(results.exit_code).to eq expected_exit_code
10
- end
11
- end
12
-
13
- def create_puppetfile(*mods)
14
- tmp = Tempfile.new('rs-r10k-puppetfile')
15
- tmp.write(mods.join("\n"))
16
- tmp.flush
17
- rcp :sp => tmp.path, :dp => "Puppetfile"
18
- end
19
- end
20
- end
21
-
22
- RSpec.configure do |config|
23
- config.include RSpecSystem::Puppetfile
24
- end
@@ -1,32 +0,0 @@
1
- # Create and teardown a tmpdir around rspec example groups.
2
-
3
- module RSpecSystem
4
- module Tmpdir
5
- def tmpdir
6
- dir = RSpec.configuration.tmpdir_stack.last
7
- if dir.nil?
8
- raise ArgumentError, "No tmpdir currently defined"
9
- else
10
- dir
11
- end
12
- end
13
- end
14
- end
15
-
16
- RSpec.configure do |config|
17
-
18
- config.add_setting(:tmpdir_stack, :default => [])
19
-
20
- config.include RSpecSystem::Tmpdir
21
- config.extend RSpecSystem::Tmpdir
22
-
23
- config.before(:all, :rs_tmpdir => true) do |example|
24
- shell 'mktemp -p $PWD -d rs.XXXXXXXX' do |sh|
25
- RSpec.configuration.tmpdir_stack.push sh.stdout.chomp
26
- end
27
- end
28
-
29
- config.after(:all, :rs_tmpdir => true) do |example|
30
- RSpec.configuration.tmpdir_stack.pop
31
- end
32
- end
@@ -1,38 +0,0 @@
1
- module SystemProvisioning
2
- module EL
3
- def install_epel_release
4
- rpm_install(
5
- 'epel-release',
6
- 'http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm'
7
- )
8
- end
9
-
10
- def install_puppetlabs_release
11
- rpm_install(
12
- 'puppetlabs-release',
13
- 'http://yum.puppetlabs.com/puppetlabs-release-el-5.noarch.rpm'
14
- )
15
- end
16
-
17
- def yum_install(*pkgs)
18
- pkgs = Array(*pkgs)
19
-
20
- pkgs.each do |pkg|
21
-
22
- check_cmd = shell "rpm -q --filesbypkg #{pkg}"
23
- if check_cmd.exit_code != 0
24
- shell "yum -y install #{pkg}"
25
- end
26
- end
27
- end
28
-
29
- def rpm_install(name, install_name = nil)
30
- install_name ||= name
31
-
32
- check_cmd = shell "rpm -q --filesbypkg #{name}"
33
- if check_cmd.exit_code != 0
34
- shell "rpm -Uvh #{install_name}"
35
- end
36
- end
37
- end
38
- end