puppet_generator 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/.gitignore +17 -0
  2. data/.rdebugrc +7 -0
  3. data/.rspec +2 -0
  4. data/.simplecov +8 -0
  5. data/.travis.yml +6 -0
  6. data/.yardopts +5 -0
  7. data/CONTRIBUTING.md +8 -0
  8. data/Gemfile +34 -0
  9. data/LICENSE.md +22 -0
  10. data/README.DEVELOPER.md +11 -0
  11. data/README.md +477 -0
  12. data/Rakefile +3 -0
  13. data/TODO.md +2 -0
  14. data/bin/ppgen +16 -0
  15. data/cucumber.yml +2 -0
  16. data/features/generate_file_definition.feature +357 -0
  17. data/features/generate_module_directories.feature +36 -0
  18. data/features/generate_package_definition.feature +206 -0
  19. data/features/generate_role_definitions.feature +64 -0
  20. data/features/generate_user_definition.feature +193 -0
  21. data/features/list.feature +22 -0
  22. data/features/log_actions.feature +93 -0
  23. data/features/step_definitions.rb +3 -0
  24. data/features/support/env.rb +7 -0
  25. data/features/tasks.feature +25 -0
  26. data/gemfiles/Gemfile.default +34 -0
  27. data/gemfiles/Gemfile.travis +17 -0
  28. data/lib/puppet_generator/actions/copy_files_to_module_directory.rb +23 -0
  29. data/lib/puppet_generator/actions/null.rb +9 -0
  30. data/lib/puppet_generator/api.rb +108 -0
  31. data/lib/puppet_generator/definition.rb +10 -0
  32. data/lib/puppet_generator/entry_converters/file.rb +9 -0
  33. data/lib/puppet_generator/entry_converters/package.rb +9 -0
  34. data/lib/puppet_generator/entry_converters/role.rb +9 -0
  35. data/lib/puppet_generator/entry_converters/user.rb +9 -0
  36. data/lib/puppet_generator/exceptions.rb +104 -0
  37. data/lib/puppet_generator/export_filters/build_role_includes_for_directory.rb +35 -0
  38. data/lib/puppet_generator/export_filters/filesystem_attributes.rb +57 -0
  39. data/lib/puppet_generator/export_filters/null.rb +9 -0
  40. data/lib/puppet_generator/exporters/directory.rb +23 -0
  41. data/lib/puppet_generator/exporters/file.rb +17 -0
  42. data/lib/puppet_generator/exporters/stdout.rb +16 -0
  43. data/lib/puppet_generator/import_filters/null.rb +9 -0
  44. data/lib/puppet_generator/import_filters/passwd.rb +22 -0
  45. data/lib/puppet_generator/import_filters/yaml.rb +20 -0
  46. data/lib/puppet_generator/importers/directory.rb +21 -0
  47. data/lib/puppet_generator/importers/file.rb +17 -0
  48. data/lib/puppet_generator/importers/stdin.rb +16 -0
  49. data/lib/puppet_generator/logger.rb +62 -0
  50. data/lib/puppet_generator/main.rb +36 -0
  51. data/lib/puppet_generator/middleware/apply_export_filters.rb +33 -0
  52. data/lib/puppet_generator/middleware/check_for_empty_source.rb +16 -0
  53. data/lib/puppet_generator/middleware/configure_logging.rb +30 -0
  54. data/lib/puppet_generator/middleware/create_module_directories.rb +42 -0
  55. data/lib/puppet_generator/middleware/create_output.rb +46 -0
  56. data/lib/puppet_generator/middleware/create_puppet_object_from_entry.rb +24 -0
  57. data/lib/puppet_generator/middleware/enable_debugging_libraries.rb +15 -0
  58. data/lib/puppet_generator/middleware/execute_actions.rb +34 -0
  59. data/lib/puppet_generator/middleware/filter_imported_data.rb +22 -0
  60. data/lib/puppet_generator/middleware/handle_errors.rb +62 -0
  61. data/lib/puppet_generator/middleware/output_debug_information_for_models.rb +21 -0
  62. data/lib/puppet_generator/middleware/read_input.rb +27 -0
  63. data/lib/puppet_generator/models/action.rb +36 -0
  64. data/lib/puppet_generator/models/base.rb +115 -0
  65. data/lib/puppet_generator/models/class_based_model.rb +56 -0
  66. data/lib/puppet_generator/models/entry_converter.rb +39 -0
  67. data/lib/puppet_generator/models/error_message.rb +60 -0
  68. data/lib/puppet_generator/models/export_filter.rb +44 -0
  69. data/lib/puppet_generator/models/exporter.rb +51 -0
  70. data/lib/puppet_generator/models/filesystem_based_model.rb +63 -0
  71. data/lib/puppet_generator/models/import_filter.rb +44 -0
  72. data/lib/puppet_generator/models/importer.rb +52 -0
  73. data/lib/puppet_generator/models/logger.rb +11 -0
  74. data/lib/puppet_generator/models/template.rb +120 -0
  75. data/lib/puppet_generator/puppet_helper.rb +19 -0
  76. data/lib/puppet_generator/puppet_objects/file.rb +29 -0
  77. data/lib/puppet_generator/puppet_objects/package.rb +24 -0
  78. data/lib/puppet_generator/puppet_objects/role.rb +27 -0
  79. data/lib/puppet_generator/puppet_objects/user.rb +27 -0
  80. data/lib/puppet_generator/setup/bare.rb +25 -0
  81. data/lib/puppet_generator/setup/default_actions.rb +9 -0
  82. data/lib/puppet_generator/setup/default_entry_converter.rb +8 -0
  83. data/lib/puppet_generator/setup/default_error_messages.rb +10 -0
  84. data/lib/puppet_generator/setup/default_export_filter.rb +9 -0
  85. data/lib/puppet_generator/setup/default_exporter.rb +11 -0
  86. data/lib/puppet_generator/setup/default_import_filter.rb +10 -0
  87. data/lib/puppet_generator/setup/default_importer.rb +10 -0
  88. data/lib/puppet_generator/setup/file.rb +29 -0
  89. data/lib/puppet_generator/setup/module.rb +22 -0
  90. data/lib/puppet_generator/setup/package.rb +27 -0
  91. data/lib/puppet_generator/setup/role.rb +28 -0
  92. data/lib/puppet_generator/setup/user.rb +27 -0
  93. data/lib/puppet_generator/task.rb +39 -0
  94. data/lib/puppet_generator/ui/commandline_parser_helper.rb +31 -0
  95. data/lib/puppet_generator/ui/create.rb +59 -0
  96. data/lib/puppet_generator/ui/runner.rb +23 -0
  97. data/lib/puppet_generator/ui/tasks.rb +16 -0
  98. data/lib/puppet_generator/version.rb +4 -0
  99. data/lib/puppet_generator.rb +79 -0
  100. data/puppet_generator.gemspec +35 -0
  101. data/rakefiles/default.rake +3 -0
  102. data/rakefiles/travis.rake +3 -0
  103. data/script/console +8 -0
  104. data/script/terminal +16 -0
  105. data/spec/examples/actions/missing_method.rb +7 -0
  106. data/spec/examples/apply_export_filters/file.txt +0 -0
  107. data/spec/examples/entry_converters/missing_method.rb +7 -0
  108. data/spec/examples/execute_actions/file.txt +0 -0
  109. data/spec/examples/export_filter/invalid_filter_1.rb +8 -0
  110. data/spec/examples/export_filter/invalid_filter_2.rb +7 -0
  111. data/spec/examples/export_filter/missing_method.rb +7 -0
  112. data/spec/examples/exporter/missing_method.rb +7 -0
  113. data/spec/examples/exporter/test.d/.gitkeep +0 -0
  114. data/spec/examples/exporter/test_file.txt +1 -0
  115. data/spec/examples/import_filter/forbidden_keyword.rb +0 -0
  116. data/spec/examples/import_filter/invalid_filter_1.rb +8 -0
  117. data/spec/examples/import_filter/invalid_filter_2.rb +7 -0
  118. data/spec/examples/import_filter/missing_method.rb +7 -0
  119. data/spec/examples/importer/missing_method.rb +7 -0
  120. data/spec/examples/importer/test.d/.gitkeep +0 -0
  121. data/spec/examples/importer/test_file.txt +1 -0
  122. data/spec/examples/templates/invalid_template.pp.erb +1 -0
  123. data/spec/examples/templates/missing_method.rb +7 -0
  124. data/spec/export_filters/build_role_includes_for_directory_spec.rb +39 -0
  125. data/spec/middleware/apply_export_filters_spec.rb +45 -0
  126. data/spec/middleware/execute_actions_spec.rb +44 -0
  127. data/spec/middleware/handle_errors_spec.rb +12 -0
  128. data/spec/models/action_spec.rb +37 -0
  129. data/spec/models/entry_converter_spec.rb +59 -0
  130. data/spec/models/error_message_spec.rb +78 -0
  131. data/spec/models/export_filter_spec.rb +36 -0
  132. data/spec/models/exporter_spec.rb +71 -0
  133. data/spec/models/import_filter_spec.rb +33 -0
  134. data/spec/models/importer_spec.rb +66 -0
  135. data/spec/models/template_spec.rb +47 -0
  136. data/spec/puppet_generator_spec.rb +7 -0
  137. data/spec/setup/role_spec.rb +22 -0
  138. data/spec/spec_helper.rb +10 -0
  139. data/spec/support/filesystem_helper.rb +12 -0
  140. data/spec/support/libraries.rb +10 -0
  141. data/spec/support/rspec_configuration.rb +5 -0
  142. data/templates/puppet/many_per_file/file.pp.erb +16 -0
  143. data/templates/puppet/many_per_file/package.pp.erb +10 -0
  144. data/templates/puppet/many_per_file/role.pp.erb +7 -0
  145. data/templates/puppet/many_per_file/user.pp.erb +23 -0
  146. data/templates/puppet/one_per_file/file.pp.erb +14 -0
  147. data/templates/puppet/one_per_file/package.pp.erb +8 -0
  148. data/templates/puppet/one_per_file/role.pp.erb +5 -0
  149. data/templates/puppet/one_per_file/user.pp.erb +21 -0
  150. metadata +374 -0
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rdebugrc ADDED
@@ -0,0 +1,7 @@
1
+ set listsize 30
2
+ set history save on
3
+ set history size 99999
4
+ set history filename ~/.rdebug_history
5
+ set autolist
6
+ set autoeval
7
+ set autoreload
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format Fuubar
2
+ --order rand
data/.simplecov ADDED
@@ -0,0 +1,8 @@
1
+ SimpleCov.start do
2
+ add_filter "/features/"
3
+ add_filter "/spec/"
4
+ add_group "actions", "lib/puppet_generator/actions/"
5
+ add_group "actions", "lib/puppet_generator/filter/"
6
+ add_group "actions", "lib/puppet_generator/templates/"
7
+ add_group "lib", "lib/"
8
+ end
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ gemfile: gemfiles/Gemfile.travis
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ script: bundle exec rake -f rakefiles/travis.rake test:travis_specs
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ --verbose
2
+ -
3
+ LICENSE.md
4
+ README.md
5
+ README.DEVELOPER.md
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,8 @@
1
+ # Contributing
2
+
3
+ 1. Fork it
4
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
5
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
6
+ 4. Push to the branch (`git push origin my-new-feature`)
7
+ 5. Create new Pull Request
8
+
data/Gemfile ADDED
@@ -0,0 +1,34 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'fedux_org-stdlib', branch: 'master'
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem 'rake'
9
+ gem 'rspec'
10
+ gem 'simplecov'
11
+ gem 'aruba', git: 'https://github.com/maxmeyer/aruba.git', branch: 'puppet_generator'
12
+ gem 'fuubar'
13
+ gem 'ffaker'
14
+ gem 'cucumber'
15
+ end
16
+
17
+ group :documentation do
18
+ gem 'yard'
19
+ gem 'redcarpet'
20
+ gem 'github-markup'
21
+ end
22
+
23
+ group :development do
24
+ gem 'tmrb'
25
+ gem 'debugger'
26
+ gem 'pry'
27
+ gem 'pry-doc'
28
+ gem 'pry-debugger'
29
+ gem 'debugger-completion'
30
+ gem 'awesome_print'
31
+ gem 'travis-lint'
32
+ gem 'fuubar'
33
+ gem 'churn'
34
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Max Meyer and Contributors
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # PuppetGenerator Developer Documentation
2
+
3
+ [![Build Status for development branch](https://travis-ci.org/maxmeyer/puppet_generator.png?branch=development)](https://travis-ci.org/maxmeyer/puppet_generator)
4
+
5
+ ## Contributing
6
+
7
+ 1. Fork it
8
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
9
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
10
+ 4. Push to the branch (`git push origin my-new-feature`)
11
+ 5. Create new Pull Request
data/README.md ADDED
@@ -0,0 +1,477 @@
1
+ # PuppetGenerator User Documentation
2
+
3
+ [![Build Status for master branch](https://travis-ci.org/maxmeyer/puppet_generator.png?branch=master)](https://travis-ci.org/maxmeyer/puppet_generator)
4
+ [![Code Climate](https://codeclimate.com/github/maxmeyer/puppet_generator.png)](https://codeclimate.com/github/maxmeyer/puppet_generator)
5
+
6
+ Writing [Puppet](https://www.puppetlabs.com)-manifests made easy...
7
+
8
+ ## Description
9
+
10
+ Writing manifests for puppet can be very time consuming and quite boring. The
11
+ PuppetGeneratore reduces the amount of time for writing puppet manifests alot
12
+ by generating a basic structure for:
13
+
14
+ * User resources
15
+ * Package resources
16
+ * File resources
17
+ * ...
18
+
19
+ This project can help you if you:
20
+
21
+ * have alot manifests to write
22
+ * simple manifests to write
23
+ * need a skeleton to start with
24
+
25
+ This project __cannot__ help you if you:
26
+
27
+ * have few very complex manifests to write
28
+ * have no fun in using new tools ;-)
29
+
30
+ ## Installation
31
+
32
+ Add this line to your application's Gemfile:
33
+
34
+ gem 'puppet_generator'
35
+
36
+ And then execute:
37
+
38
+ $ bundle
39
+
40
+ Or install it yourself as:
41
+
42
+ $ gem install puppet_generator
43
+
44
+ ## Usage
45
+
46
+ ### Basics
47
+
48
+ The puppet generator comes with a single executable called `ppgen`. It uses a syntax
49
+ similar to git.
50
+
51
+ ```
52
+ ppgen <command> [options] <subcommand> [suboptions]
53
+ ```
54
+
55
+ To get help, please call it with `help` as parameter or `--help|-h` as option.
56
+
57
+ *Example:*
58
+
59
+ ```
60
+ ppgen help
61
+ ppgen help <command>
62
+ ppgen <command> help <subcommand>
63
+ ppgen --help
64
+ ppgen -h
65
+ ```
66
+
67
+ In general it supports some other special options. A better description for all other options is given below and is
68
+ available via the `help`-command as well.
69
+
70
+ * `--debug`: Gives you very detailed debug output
71
+ * `--silent`: Makes it silent
72
+
73
+ *Example:*
74
+
75
+ ```
76
+ ppgen <command> <subcommand> --debug
77
+ ```
78
+
79
+ *Example:*
80
+
81
+ ```
82
+ ppgen <command> <subcommand> --silent
83
+ ```
84
+
85
+ Besides the given options `ppgen` provides a way to define the name of the
86
+ module and the class name for the given resource used to create the output
87
+
88
+ * Module name: `--module`
89
+ * Class name: `--class`
90
+
91
+ *Example:*
92
+
93
+ ```
94
+ #command
95
+ ppgen <command> <subcommand> --module mymodule --class myclass
96
+
97
+ # output
98
+ class mymodule::myclass {
99
+
100
+ [...]
101
+
102
+ }
103
+ ```
104
+
105
+ ### Data flow
106
+
107
+ The flow of data through `ppgen` is described in the following figure. Today it
108
+ reads data data via an importer (1) first -- there's no streaming support
109
+ available. After the import filter the data via the import filter (2) and then
110
+ the export filter (3). To output the filtered data `ppgen` uses a suitable
111
+ exporter (4).
112
+
113
+ __Please note:__
114
+
115
+ Available options for (1), (2), (3), (4) and (5) may depend on the chosen command
116
+ and/or subcommand.
117
+
118
+ *Figure:*
119
+
120
+ ```
121
+ Input --> Importer --> ImportFilter --> ExportFilter --> Action --> Exporter --> Output
122
+ (1) (2) (3) (4) (5)
123
+ ```
124
+
125
+ ### All Available Options for Importer, Import|ExportFilter, Action, Exporter
126
+
127
+ `ppgen` supports the following importers:
128
+
129
+ * File: Read data from a file
130
+ * Directory: Generate a listing for a directory and use all items (directory/file) found
131
+ * Stdin: Read data from stdin
132
+
133
+ Which importer to use is determined via `<input>`. If it's a file the `File`-importer is used and so on.
134
+
135
+ *Example*
136
+
137
+ ```
138
+ ppgen <command> <subcommand> --source <input>
139
+ ppgen <command> <subcommand> --source file.txt
140
+ ppgen <command> <subcommand> --source dir.d
141
+ ppgen <command> <subcommand> --source stdin
142
+ ```
143
+
144
+ `ppgen` supports the following import filters:
145
+
146
+ * Null (`null`, default): Import plain text data
147
+ * Yaml (`yaml`): Import [YAML](http://www.yaml.org) documents
148
+ * Passwd (`passwd`): Import structured data from `/etc/passwd` (linux/unix-operating
149
+ systems only)
150
+
151
+ *Example*
152
+
153
+ ```
154
+ ppgen <command> <subcommand> --import-filter <filter>
155
+ ppgen <command> <subcommand> --import-filter null
156
+ ppgen <command> <subcommand> --import-filter yaml
157
+ ppgen <command> <subcommand> --import-filter passwd
158
+ ```
159
+
160
+ `ppgen` supports the following export filters:
161
+
162
+ * Null (`null`, default): No modification of data
163
+ * Filesystem attributes (`filesystem_attributes`): It tries to read filesystem attributes like owner,
164
+ mode etc. from the filesystem
165
+ * Build role for directory (`build_role_includes_for_directory`): Special export filter which scans a directory for
166
+ `*.pp` and generates a `<dir'>.pp` including the sub-pp-files
167
+
168
+ *Example*
169
+
170
+ ```
171
+ ppgen <command> <subcommand> --export-filter <filter>
172
+ ppgen <command> <subcommand> --export-filter null
173
+ ppgen <command> <subcommand> --export-filter filesystem_attributes
174
+ ppgen <command> <subcommand> --export-filter build_role_includes_for_directory
175
+ ```
176
+
177
+ `ppgen` supports the following actions:
178
+
179
+ * Null (`null`, default): no action
180
+ * Copy files to module (`copy_files_to_module_directory`): Given a module name (default: mymodule) it copies existing files to a directory `<module>`
181
+
182
+ *Example*
183
+
184
+ ```
185
+ ppgen <command> <subcommand> --action <action>
186
+ ppgen <command> <subcommand> --action null
187
+ ppgen <command> <subcommand> --action copy_files_to_module_directory
188
+ ```
189
+
190
+ `ppgen` supports the following exporters:
191
+
192
+ * File (`file`): Store output in a single file
193
+ * Directory (`dir|directory`): Store output in multiple files (name = equals name of resource, user => hans, name => hans.pp)
194
+ * Stdout (`stdout`): Output data to stdout
195
+
196
+ *Example*
197
+
198
+ ```
199
+ ppgen <command> <subcommand> --destination <destination>
200
+ ppgen <command> <subcommand> --destination file:file.txt
201
+ ppgen <command> <subcommand> --destination dir:dir1.d
202
+ ppgen <command> <subcommand> --destination directory:dir1.d
203
+ ppgen <command> <subcommand> --destination stdout
204
+ ```
205
+
206
+
207
+ It supports `create`, `list` (not implemented yet) and `show`(not implemented
208
+ yet)-commands, as well as the special `tasks`-command. The last one should make
209
+ the usage easier. Instead of giving `ppgen` all needed options it is a shortcut
210
+ for some options so that you need to provide a `--source` and a
211
+ `--destination`-option only.
212
+
213
+ Please use the following command to get an overview about the available
214
+ resource which can be created
215
+
216
+ ```bash
217
+ ppgen help create
218
+ ```
219
+
220
+ ## Data formats
221
+
222
+ If you chose to use the yaml import filter, the following YAML-file-formats are
223
+ supported for the `create`-command.
224
+
225
+ ### User
226
+
227
+ ```
228
+ ---
229
+ user1:
230
+ userid: 1000
231
+ groupid: 1000
232
+ homedir: /home/user1
233
+ shell: /usr/bin/bash
234
+ ```
235
+
236
+ ### Package
237
+
238
+ ```
239
+ ---
240
+ ssh:
241
+ version: 1
242
+ provider: yum
243
+ ```
244
+
245
+
246
+ ### File
247
+
248
+ ```
249
+ ---
250
+ path/to/file:
251
+ type:file
252
+ source: puppet:///module/file.txt
253
+ owner: user1
254
+ mode: 0644
255
+ ```
256
+
257
+ ### Role
258
+
259
+ ```
260
+ ---
261
+ horray:
262
+ includes:
263
+ - name1
264
+ - name2
265
+ ```
266
+
267
+
268
+ ## Tasks
269
+
270
+ ### Create a user manifests from plain text file and writing it to a file
271
+
272
+ Input: `file.txt`
273
+
274
+ ```
275
+ user1
276
+ user2
277
+ ```
278
+
279
+ Command:
280
+
281
+ ```
282
+ ppgen create user --source file.txt --destination file:output.txt
283
+ ```
284
+
285
+ Output: `output.txt`
286
+
287
+ ```
288
+ class mymodule::myclass {
289
+ user {'user1':
290
+ ensure => present,
291
+ managehome => true,
292
+ }
293
+ user {'user2':
294
+ ensure => present,
295
+ managehome => true,
296
+ }
297
+ }
298
+ ```
299
+
300
+ ### Create a user manifests from yaml writing it to stdout
301
+
302
+ Input: `file.yml`
303
+
304
+ ```
305
+ ---
306
+ user1:
307
+ userid: 1000
308
+ groupid: 1000
309
+ homedir: /home/user1
310
+ shell: /usr/bin/bash
311
+ ```
312
+
313
+ Command:
314
+
315
+ ```
316
+ ppgen create user --source file.yml --destination file:output.txt --import-filter yaml
317
+ ```
318
+
319
+ Output: `output.txt`
320
+
321
+ ```
322
+ class mymodule::myclass {
323
+ user {'user1':
324
+ ensure => present,
325
+ managehome => true,
326
+ uid => '1000',
327
+ gid => '1000',
328
+ home => '/home/user1',
329
+ shell => '/usr/bin/bash',
330
+ }
331
+ }
332
+ ```
333
+
334
+ ### Create module skeleton
335
+
336
+ Command:
337
+
338
+ ```
339
+ ppgen create module --module name
340
+ ```
341
+
342
+ Output: Directory `name`
343
+
344
+ ```
345
+ name/
346
+ |-- files
347
+ `-- manifests
348
+ `-- init.pp
349
+ ```
350
+
351
+ ### Create roles for existing pp-files
352
+
353
+ **Please note**:
354
+ You should run this command only on VCS-enabled module directories (e.g.
355
+ git,cvs,svn,bazar,mercurial). It may overwrite existing role-files (e.g.
356
+ directory = 'dir1', role-file = 'dir1.pp').
357
+
358
+ Input:
359
+
360
+ ```
361
+ name
362
+ |-- files
363
+ `-- manifests
364
+ |-- apps
365
+ | |-- firefox.pp
366
+ | |-- i3.pp
367
+ | `-- mutt.pp
368
+ `-- init.pp
369
+ ```
370
+
371
+ Command:
372
+
373
+ ```
374
+ cd name/manifests
375
+ ppgen create role --export-filter build_role_includes_for_directory --source apps --destination dir:./
376
+ ```
377
+
378
+ Output: file `apps.pp`
379
+
380
+ ```
381
+ name
382
+ |-- files
383
+ `-- manifests
384
+ |-- apps
385
+ | |-- firefox.pp
386
+ | |-- i3.pp
387
+ | `-- mutt.pp
388
+ |-- apps.pp <--- NEW
389
+ `-- init.pp
390
+
391
+ ```
392
+
393
+ ## Tipps & Tricks
394
+
395
+ ### Remote access to filesystem
396
+
397
+ Some of `ppgen` commands and/or options need filesystem access. If you try to
398
+ migrate a server and it's not possible to install the `puppet_generator` onto
399
+ the old one, `sshfs` may help you. Please consult the manual of `sshfs` to make
400
+ it work.
401
+
402
+ ### Jump Server Infrastructure
403
+
404
+ To make your life in an infrastructure with a jump server easier, you could use
405
+ the following ssh setup, which can be used with sshfs as well (recommened for
406
+ the use with sshfs by the author of this manual)! Given the following
407
+ infrastructure:
408
+
409
+ ```
410
+ linux/unit work station --> jump server --> target server
411
+ ```
412
+
413
+ You build up a ssh connection from the workstation (1) to the jump server (2).
414
+
415
+ ```
416
+ linux/unit work station ====== jump server
417
+ (1) ssh (2)
418
+ ```
419
+
420
+ Furthermore: You build up a tcp connection from the jump server (2) to the target
421
+ server (3).
422
+
423
+ ```
424
+ jump server ****** target server
425
+ (2) tcp (3)
426
+ ```
427
+
428
+ Done this way you have a connection like the following one in the next figure.
429
+
430
+ ```
431
+ linux/unit work station ====== jump server ****** target server
432
+ ssh tcp
433
+ ```
434
+
435
+ Then you instruct ssh to use this connection for another ssh connection: from
436
+ the workstation to the target server. This works by using the first connection
437
+ as proxy connection via the ssh proxy command (see below).
438
+
439
+ ```
440
+ ssh
441
+ linux/unit work station ------------------------- target server
442
+ (1) (jump server) (3)
443
+ ```
444
+
445
+ To get this up and running you should use a ssh configuration similar to the following one: File `$HOME/.ssh/config`:
446
+
447
+ ```
448
+ Host jump_server
449
+ Hostname jump_server.example.com
450
+ User user
451
+ ForwardAgent yes
452
+ IdentityFile ~/.ssh/id_rsa
453
+
454
+ Host target_server
455
+ Hostname target_server.example.com
456
+ User admin
457
+ ForwardAgent yes
458
+ IdentityFile ~/.ssh/id_rsa
459
+ ProxyCommand ssh user@jump_server "socat - TCP4:%h:%p" <--- most important line
460
+ ```
461
+
462
+ Furthermore you need to install a utitilty which is able to bridge STDIN to TCP
463
+ like `socat` or `netcat`. Personally I prefer `socat` because from my point of
464
+ view it's the most flexible tool for this type of task.
465
+
466
+ ## Development
467
+
468
+ Please see the [developer-documentation](README.DEVELOPER.md) for more details.
469
+
470
+ ## Copyright
471
+
472
+ &copy; 2013 Max Meyer and Contributors. All rights reserved. Please see [Licence](LICENSE.md).
473
+
474
+ ## Contributers
475
+
476
+ * Dennis Günnewig (VR Netze GmbH, https://www.vrnetze.de)
477
+
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'fedux_org/stdlib/rake'
data/TODO.md ADDED
@@ -0,0 +1,2 @@
1
+ * Move filesystem attributes to action instead of filter ?
2
+ * Refactor the filesystem based models: move similar parts to module class
data/bin/ppgen ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'puppet_generator/main'
4
+
5
+ if ENV['PUPPET_GENERATOR_ENV'] and not ENV['TRAVIS_CI'] == 'true'
6
+ case ENV['PUPPET_GENERATOR_ENV'].downcase.to_sym
7
+ when :test
8
+ PuppetGenerator.enable_coverage_report
9
+ PuppetGenerator.enable_debugging_libraries
10
+ when :development
11
+ PuppetGenerator.enable_debugging_libraries
12
+ end
13
+ end
14
+
15
+ require 'puppet_generator'
16
+ PuppetGenerator::Ui::Runner.start
data/cucumber.yml ADDED
@@ -0,0 +1,2 @@
1
+ default: -t @wip:3
2
+ all: -t ~@wip