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
@@ -0,0 +1,45 @@
1
+ SVN Based Dynamic Environments
2
+ ==============================
3
+
4
+ R10k can use SVN repositories to implement dynamic environments. You can create,
5
+ update, and delete Puppet environments automatically as part of your normal SVN
6
+ workflow.
7
+
8
+ How it works
9
+ ------------
10
+
11
+ R10k implements a branching workflow similar to Git by using the SVN concept of
12
+ branches. SVN repositories must conform to the conventional SVN repository
13
+ structure with the directories trunk/, branches/, and optionally tags/ in the
14
+ root of the repository. R10k maps the trunk/ directory to the production
15
+ environment, and production environment, and branches (directories in branches/)
16
+ are created as environments with the name of the given branch.
17
+
18
+ Configuration
19
+ -------------
20
+
21
+ In addition to the settings that all sources support, SVN sources can specify
22
+ the following additional options:
23
+
24
+ ### username/password
25
+
26
+ If the SVN repository requires credentials, you can supply the `username` and
27
+ `password` options.
28
+
29
+ Both `username` and `password` must be specified in order to SVN authentication.
30
+
31
+ **Note**: SVN credentials are passed as command line options, so the SVN
32
+ credentials may be visible in the process table when r10k is running. If you
33
+ choose to supply SVN credentials make sure that the system running r10k is
34
+ appropriately secured.
35
+
36
+ ```yaml
37
+ ---
38
+ sources:
39
+ myenvs:
40
+ type: svn
41
+ remote: 'svn://my-svn.server/my-svn-repo'
42
+ basedir: '/etc/puppet/environments'
43
+ username: 'azurediamond'
44
+ password: 'hunter2'
45
+ ```
@@ -31,7 +31,7 @@ basis.
31
31
 
32
32
  - - -
33
33
 
34
- Update environments while avoiding unnecessary recursion
34
+ Update environments while avoiding unnecessary recursion:
35
35
 
36
36
  r10k deploy environment
37
37
 
@@ -62,20 +62,59 @@ useful if you want to make sure that a given environment is fully up to date.
62
62
 
63
63
  ### Deploying modules
64
64
 
65
- Update a single module across all environments
65
+ Update a single module across all environments:
66
66
 
67
67
  r10k deploy module apache
68
68
 
69
- This is useful for when you're working on a module specified in a Puppetfile and want to update it across all environments.
69
+ This is useful for when you're working on a module specified in a Puppetfile
70
+ and want to update it across all environments. See
71
+ [Puppetfile documentation](doc/puppetfile.mkd) for details on how this affects
72
+ Forge vs. Git/SVN modules.
70
73
 
71
74
  - - -
72
75
 
73
- Update multiple modules across all environments
76
+ Update multiple modules across all environments:
74
77
 
75
78
  r10k deploy module apache jenkins java
76
79
 
77
80
  - - -
78
81
 
79
- Update one or more modules in a single environment
82
+ Update one or more modules in a single environment:
80
83
 
81
84
  r10k deploy module -e production apache jenkins java
85
+
86
+ ### Viewing environments
87
+
88
+ Display all environments being managed by r10k:
89
+
90
+ r10k deploy display
91
+
92
+ Display all environments being managed by r10k, and modules specified in the
93
+ Puppetfile:
94
+
95
+ r10k deploy display -p
96
+
97
+ Display all environments being managed by r10k, and modules specified in the
98
+ Puppetfile along with their expected and actual versions:
99
+
100
+ r10k deploy display -p --detail
101
+
102
+ Display an explicit list of environments being managed by r10k and modules
103
+ specified in the Puppetfile along with their expected and actual versions:
104
+
105
+ r10k deploy display -p --detail production vmwr webrefactor
106
+
107
+ User accounts
108
+ -------------
109
+
110
+ When running commands to deploy code on a master, r10k needs to have write
111
+ access to your Puppet environment path and should create files that are
112
+ readable by the user account running the master. If you're using Puppet
113
+ Enterprise this account is `pe-puppet`, and if you're using Puppet open source
114
+ this account is `puppet`.
115
+
116
+ This can be done in a few ways. First off, you can run r10k as the puppet user
117
+ itself. You can also create a new user that has write access to the Puppet
118
+ environment path, has the same GID as the puppet user, and has a umask of 0027.
119
+ You can also run r10k as root, which is the simplest solution but does require
120
+ access control to the root user.
@@ -0,0 +1,247 @@
1
+ R10k's dynamic deployments work best with a workflow that understands and
2
+ respects how r10k works, to prevent automation and manual processes from
3
+ conflicting. Your workflow will need to be customized to meet your team's
4
+ skills, tools, and needs. This guide describes a generic workflow that can
5
+ be customized easily.
6
+
7
+ This guide assumes that each of your modules is in a separate repository
8
+ and that the `Puppetfile` is in its own repo called the
9
+ [Control Repo](http://www.jeffmalnick.com/blog/2014/05/16/r10k-control-repos/).
10
+ All module repos have a primary branch of *master* and the Control's primary
11
+ branch is *production*. All changes are made through r10k and no user makes
12
+ manual changes to the environments under **/etc/puppet**.
13
+
14
+ Adding New Modules
15
+ ------------------
16
+
17
+ This workflow is useful when adding a forge or internally-developed module
18
+ to your puppet environment.
19
+
20
+ ### Create new feature branch
21
+
22
+ Create a new feature branch in your module repositories. Do this for each
23
+ repository, including the control repository, that will reference the new
24
+ module. You do not need to do so for modules that are not being edited.
25
+
26
+ ```git checkout -b feature```
27
+
28
+ If you are simply adding the module at this time and not referencing it in
29
+ other modules or manifests, only the Control repo requires a new branch.
30
+
31
+ ### Add new module and branches to control repo
32
+
33
+ The new module is added to the control repository's `Puppetfile` like so:
34
+
35
+ ```
36
+ # Forge modules:
37
+ mod "puppetlabs/ntp"
38
+
39
+ # Your modules:
40
+ mod "custom_facts",
41
+ :git => "git://github.com/user/custom_facts"
42
+ ```
43
+
44
+ For any existing modules that you branched, add a reference to the new branch
45
+ name. Don't forget the comma at the end of the *:git* value.
46
+
47
+ ```
48
+ mod "other_module",
49
+ :git => "git://github.com/user/other_module",
50
+ :ref => "feature"
51
+ ```
52
+
53
+ ### Reference new module in manifests, modules, and hiera
54
+
55
+ If you are simply adding the module at this time and not referencing it in
56
+ other modules or manifests, you may skip this step.
57
+
58
+ Edit your existing manifests, modules, and hiera as needed to make sure of
59
+ the new module.
60
+
61
+ ### Deploy environments
62
+
63
+ Save all your changes in each module repo. Commit and push the changes upstream:
64
+
65
+ ```
66
+ git commit -a -m ‘Add feature reference to module’
67
+ git push origin feature
68
+ ```
69
+
70
+ Commit and push the change in your control repo upstream:
71
+
72
+ ```
73
+ git commit -a -m ‘Add module puppetlabs/ntp to branch feature'
74
+ git push origin feature
75
+ ```
76
+
77
+ Finally, deploy the environments via r10k. This step must occur on the master:
78
+
79
+ ```r10k deploy environment -p```
80
+
81
+ Add the **-v** option for verbosity if you need to troubleshoot any errors. The
82
+ new branch should be located at `$environmentpath/feature`.
83
+
84
+
85
+ ### Test the new module branches
86
+
87
+ If you are simply adding the module at this time and not referencing it in
88
+ other modules or manifests, you may skip this step.
89
+
90
+ Run the puppet agent against the new environment from at least two nodes, one
91
+ that should not be impacted by change and one that should be impacted.
92
+
93
+ ```puppet agent -t --environment feature```
94
+
95
+ Verify that catalog compilation succeeds and that you are satisfied that the
96
+ effective changes match your expected changes. Repeat the steps above until
97
+ you are satisfied with the results.
98
+
99
+ ### Merge changes
100
+
101
+ In each of the changed modules and the control repo, checkout the main branch,
102
+ merge, and push changes to the master/production branch.
103
+
104
+ ```
105
+ # Module repos
106
+ git checkout master
107
+ git merge feature
108
+ git push origin master
109
+
110
+ # Control repo
111
+ git checkout production
112
+ git merge feature
113
+ vi Puppetfile
114
+ # Remove all :ref's pointing to 'feature'. Don't forget the trailing commas
115
+ # on the :git statements
116
+ git commit -a -m 'Remove refs to feature branch for module puppetlabs/ntp'
117
+ git push origin production
118
+ ```
119
+
120
+ If you are simply adding the module at this time and not referencing it in
121
+ other modules or manifests, you are now finished.
122
+
123
+ ### Cleanup feature branches
124
+
125
+ You may skip this step for long-lived branches, however most feature branches
126
+ should be short-lived and can be pruned once testing and merging is complete.
127
+
128
+ Remove the old branches in each repo:
129
+
130
+ ```
131
+ git branch -D repo
132
+ git push origin :repo
133
+ ```
134
+
135
+ Deploy via r10k on the master and ensure there are no errors. The *feature*
136
+ dynamic environment will no longer exist at `$environmentpath/feature` if you
137
+ deleted the branch in your Control repo.
138
+
139
+ ```r10k deploy environment -p```
140
+
141
+ Editing existing Modules
142
+ ------------------------
143
+
144
+ When editing your own existing modules, this workflow should be followed.
145
+
146
+ ### Create new feature branches
147
+
148
+ Create a new feature branch in your module repositories. Do this in the edited
149
+ module, the control repository, and in each module that will reference the
150
+ updated module. You do not need to do so for modules that are not being edited.
151
+
152
+ ```git checkout -b feature```
153
+
154
+ ### Update control repo to reference new branch
155
+
156
+ For all modules that you branched, add a reference to the new branch name to
157
+ the `Puppetfile` in your Control repo. Don't forget the comma at the end of
158
+ the *:git* value.
159
+
160
+ ```
161
+ mod "other_module",
162
+ :git => "git://github.com/user/other_module",
163
+ :ref => "feature"
164
+ ```
165
+
166
+ ### Modify existing module, references to module
167
+
168
+ Make the required changes to your existing module. Edit your existing manifests,
169
+ modules, and hiera as needed to make sure of the updated module.
170
+
171
+ ### Deploy environments
172
+
173
+ Save all your changes in each modified repo. Commit and push the changes upstream:
174
+
175
+ ```
176
+ git commit -a -m ‘Add feature reference to module’
177
+ git push origin feature
178
+ ```
179
+
180
+ Commit and push the change in your control repo upstream:
181
+
182
+ ```
183
+ git commit -a -m ‘Add module puppetlabs/ntp to branch feature'
184
+ git push origin feature
185
+ ```
186
+
187
+ Finally, deploy the environments via r10k. This step must occur on the master:
188
+
189
+ ```r10k deploy environment -p```
190
+
191
+ Add the *-v* option for verbosity if you need to troubleshoot any errors. The
192
+ new branch should be located at `$environmentpath/feature`.
193
+
194
+ ### Test the new module branches
195
+
196
+ Run the puppet agent against the new environment from at least two nodes, one
197
+ that should not be impacted by change and one that should be impacted.
198
+
199
+ ```puppet agent -t --environment feature```
200
+
201
+ Verify that catalog compilation succeeds and that you are satisfied that the
202
+ effective changes match your expected changes. Repeat the steps above until
203
+ you are satisfied with the results.
204
+
205
+ ### Merge changes
206
+
207
+ In each of the changed module repos, checkout the main branch and merge.
208
+
209
+ ```
210
+ # Module repos
211
+ git checkout master
212
+ git merge feature
213
+ git push origin master
214
+ ```
215
+
216
+ In the Control repo, check out master. Do NOT merge the feature branch as it
217
+ now references the incorrect branch for each git repo, and no other changes
218
+ were made (unlike a new module, where a new repo is referenced).
219
+
220
+ ```
221
+ # Control repo
222
+ git checkout master
223
+ ```
224
+
225
+ ### Cleanup feature branches
226
+
227
+ You may skip this step for long-lived branches, however most feature branches
228
+ should be short-lived and can be pruned once testing and merging is complete.
229
+
230
+ Remove the old branches in each repo:
231
+
232
+ ```
233
+ git branch -D repo
234
+ git push origin :repo
235
+ ```
236
+
237
+ Redeploy with r10k on the master and ensure there are no errors. The *feature*
238
+ dynamic environment should no longer exist at `$environmentpath/feature`.
239
+
240
+ ```r10k deploy environment -p```
241
+
242
+ Customize Your Workflow
243
+ -----------------------
244
+
245
+ This guide is very generic in nature. Use it as a template and expand and
246
+ modify it to fit your team, your tools, and your company culture. Above all,
247
+ be consistent in your methodology.
@@ -0,0 +1,52 @@
1
+ Frequently Asked Questions
2
+ ==========================
3
+
4
+ ### The default Git branch is 'master', while the default Puppet environment is 'production'. How do I reconcile this?
5
+
6
+ The default Git branch name is 'master', but this is a somewhat arbitrary name
7
+ and doesn't necessarily map to every use case. In the case of R10K it's generally
8
+ easiest to rename 'master' to 'production'. You can rename the master branch
9
+ with the following:
10
+
11
+ ```
12
+ git branch -m master production
13
+ git push --set-upstream origin production
14
+ ```
15
+
16
+ Note that this will only create a new branch called production with a copy of
17
+ master - to change the default branch for all subsequent clones, read on.
18
+
19
+ #### Changing the default branch for bare Git repositories
20
+
21
+ When you clone a repository, Git checks out the [currently active branch][git-clone]
22
+ on the remote repository. Changing this for a non-bare repository is simple - just
23
+ check out a different branch and subsequent clones from that repository will
24
+ use that branch.
25
+
26
+ For bare repositories things are a bit more complex. Bare repositories do not
27
+ have a working directory that can be checked out, but they do have a [symbolic
28
+ ref][git-symbolic-ref] that serves the same role. To change this, run the
29
+ following command:
30
+
31
+ ```
32
+ git --git-dir /path/to/bare/repo symbolic-ref HEAD refs/heads/production
33
+ ```
34
+
35
+ #### Changing the default branch for different Git services
36
+
37
+ For Git hosting services where you may not cannot directly invoke commands,
38
+ there are usually administrative tools to allow you to change the default branch
39
+ on your remote repositories:
40
+
41
+ * [GitHub][github-default-branch]
42
+ * [Bitbucket][bitbucket-default-branch]
43
+ * [Gitolite v2][gitolite-v2-default-branch]
44
+ * [Gitolite v3][gitolite-v3-default-branch]
45
+
46
+ [git-clone]: https://www.kernel.org/pub/software/scm/git/docs/git-clone.html "git-clone(1)"
47
+ [git-symbolic-ref]: https://www.kernel.org/pub/software/scm/git/docs/git-symbolic-ref.html "git-symbolic-ref(1)"
48
+
49
+ [github-default-branch]: https://help.github.com/articles/setting-the-default-branch "Setting the default branch"
50
+ [bitbucket-default-branch]: https://answers.atlassian.com/questions/280944/how-to-change-main-branch-in-bitbucket "How to change MAIN branch in BitBucket?"
51
+ [gitolite-v2-default-branch]: http://stackoverflow.com/questions/7091599/git-default-remote-branch-with-gitolite "git default remote branch with gitolite"
52
+ [gitolite-v3-default-branch]: http://stackoverflow.com/questions/13949093/git-change-default-branch-gitolite "git change default branch (gitolite)"
@@ -0,0 +1,203 @@
1
+ Puppetfile
2
+ ==========
3
+
4
+ Puppetfiles are a simple Ruby based DSL that specifies a list of modules to
5
+ install, what version to install, and where to fetch them from. r10k can use a
6
+ Puppetfile to install a set of Puppet modules for local development, or they can
7
+ be used with r10k environment deployments to install additional modules into a
8
+ given environment.
9
+
10
+ Unlike librarian-puppet, the r10k implementation of Puppetfiles does not include
11
+ dependency resolution, but it is on the roadmap.
12
+
13
+ When directly working with Puppetfiles, you can use the `r10k puppetfile`
14
+ subcommand to interact with a Puppetfile.
15
+
16
+ When using r10k's deploy functionality, interacting with Puppetfiles is handled
17
+ on a case by case basis.
18
+
19
+ Because the Puppetfile format is actually implemented using a Ruby DSL any valid
20
+ Ruby expression can be used. That being said, being a bit too creative in the
21
+ DSL can lead to surprising (read: bad) things happening, so consider keeping it
22
+ simple.
23
+
24
+ Commands
25
+ --------
26
+
27
+ Puppetfile subcommands assume that the Puppetfile to operate on is in the
28
+ current working directory and modules should be installed in the 'modules'
29
+ directory relative to the current working directory.
30
+
31
+ Install or update all modules in a given Puppetfile
32
+ into ./modules)
33
+
34
+ r10k puppetfile install
35
+
36
+ Verify the Puppetfile syntax
37
+
38
+ r10k puppetfile check
39
+
40
+ Remove any modules in the 'modules' directory that are not specified in the
41
+ Puppetfile:
42
+
43
+ r10k puppetfile purge
44
+
45
+ Global settings
46
+ ---------------
47
+
48
+ The following settings can be used to control how the Puppetfile installs and
49
+ handles modules.
50
+
51
+ ### forge
52
+
53
+ The `forge` setting specifies which server that Forge based modules are fetched
54
+ from. This is currently a noop and is provided for compatibility with
55
+ librarian-puppet, but will be made functional in a future version. See
56
+ [GH-106](https://github.com/adrienthebo/r10k/issues/106) for more information.
57
+
58
+ ### moduledir
59
+
60
+ The `moduledir` setting specifies where modules from the Puppetfile will be
61
+ installed. This defaults to the `modules` directory relative to the Puppetfile.
62
+ If the path is absolute then the modules will be installed to that absolute
63
+ path, otherwise it's assumed that the `moduledir` setting should be relative and
64
+ the modules will be installed in that directory relative to the Puppetfile.
65
+
66
+ The moduledir setting should be placed before any modules are declared.
67
+
68
+ Install modules to an absolute path:
69
+
70
+ ```ruby
71
+ moduledir '/etc/puppet/modules'
72
+
73
+ mod 'branan/eight_hundred' # will be installed into '/etc/puppet/modules/eight_hundred'
74
+ ```
75
+
76
+ Install modules to a relative path:
77
+
78
+ ```ruby
79
+ moduledir 'thirdparty'
80
+
81
+ mod 'branan/eight_hundred' # will be installed into `dirname /path/to/Puppetfile`/thirdparty/eight_hundred
82
+ ```
83
+
84
+ **Note**: support for a relative moduledir was added in r10k 1.4.0; the behavior
85
+ of a relative moduledir path is undefined on earlier versions of r10k.
86
+
87
+ Module types
88
+ ------------
89
+
90
+ r10k can install Puppet modules from a number of different sources. Right now
91
+ modules can be installed via Git, SVN, and from the Puppet Forge.
92
+
93
+ ### Git
94
+
95
+ Git repositories that contain a Puppet module can be cloned and used as modules.
96
+ When Git is used, the module version can be specified by using `:ref`, `:tag`,
97
+ `:commit`, and `:branch`.
98
+
99
+ When a module is installed using `:ref`, r10k uses some simple heuristics to
100
+ determine the type of Git object that should be checked out. This can be used
101
+ with a git commit, branch reference, or a tag.
102
+
103
+ When a module is installed using `:tag` or `:commit`, r10k assumes that the
104
+ given object is a tag or commit and can do some optimizations around fetching
105
+ the object. If the tag or commit is already available r10k will skip network
106
+ operations when updating the repo, which can speed up install times.
107
+
108
+ Module versions can also be specified using `:branch`. This behaves similarly to
109
+ `:ref`, and is mainly useful for clarity.
110
+
111
+ #### Examples
112
+
113
+ # Install puppetlabs/apache and keep it up to date with 'master'
114
+ mod 'apache',
115
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache'
116
+
117
+ # Install puppetlabs/apache and track the 'docs_experiment' branch
118
+ mod 'apache',
119
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
120
+ :ref => 'docs_experiment'
121
+
122
+ # Install puppetlabs/apache and pin to the '0.9.0' tag
123
+ mod 'apache',
124
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
125
+ :tag => '0.9.0'
126
+
127
+ # Install puppetlabs/apache and pin to the '83401079' commit
128
+ mod 'apache',
129
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
130
+ :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
131
+
132
+ # Install puppetlabs/apache and track the 'docs_experiment' branch
133
+ mod 'apache',
134
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
135
+ :branch => 'docs_experiment'
136
+
137
+ ### Forge
138
+
139
+ Modules can be installed using the Puppet module tool.
140
+
141
+ If no version is specified the latest version available at the time will be
142
+ installed, and will be kept at that version.
143
+
144
+ mod 'puppetlabs/apache'
145
+
146
+ If a version is specified then that version will be installed.
147
+
148
+ mod 'puppetlabs/apache', '0.10.0'
149
+
150
+ If the version is set to :latest then the module will be always updated to the
151
+ latest version available.
152
+
153
+ mod 'puppetlabs/apache', :latest
154
+
155
+ ### SVN
156
+
157
+ Modules can be installed via SVN. If no version is given, the module will track
158
+ the latest version available in the main SVN repository.
159
+
160
+ mod 'apache',
161
+ :svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk'
162
+
163
+ If an SVN revision number is specified with `:rev` (or `:revision`), that
164
+ SVN revision will be kept checked out.
165
+
166
+ mod 'apache',
167
+ :svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
168
+ :rev => '154'
169
+
170
+ mod 'apache',
171
+ :svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
172
+ :revision => '154'
173
+
174
+ If the SVN repository requires credentials, you can supply the `:username` and
175
+ `:password` options.
176
+
177
+ mod 'apache',
178
+ :svn => 'https://github.com/puppetlabs/puppetlabs-apache/trunk',
179
+ :username => 'azurediamond',
180
+ :password => 'hunter2'
181
+
182
+ **Note**: SVN credentials are passed as command line options, so the SVN
183
+ credentials may be visible in the process table when r10k is running. If you
184
+ choose to supply SVN credentials make sure that the system running r10k is
185
+ appropriately secured.
186
+
187
+ ## Environment variables
188
+
189
+ It is possible to set an alternate name/location for your `Puppetfile` and
190
+ `modules` directory. This is useful if you want to control multiple environments
191
+ and have a single location for your `Puppetfile`.
192
+
193
+ Example:
194
+
195
+ PUPPETFILE=/etc/r10k.d/Puppetfile.production \
196
+ PUPPETFILE_DIR=/etc/puppet/modules/production \
197
+ /usr/bin/r10k puppetfile install
198
+
199
+ NOTE: using these environment variables is not a suggested configuration, and
200
+ have different semantics than librarian-puppet. Specifically, the PUPPETFILE_DIR
201
+ is the environment that r10k will install modules into, and it will take full
202
+ control over that directory and _remove any unmanaged content_. Use these
203
+ variables with caution.