puppet_generator 0.5.4

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.
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
@@ -0,0 +1,357 @@
1
+ Feature: Generate file definitions
2
+
3
+ As a administrator
4
+ I need to write file definitions for puppet
5
+ In order to get those things up and running via puppet
6
+
7
+ Background: Process environment
8
+ Given I set the environment variables to:
9
+ | variable | value |
10
+ | PUPPET_GENERATOR_ENV | test |
11
+
12
+ Scenario: Plain Input File
13
+ Given a file named "input.txt" with:
14
+ """
15
+ asdf
16
+ """
17
+ When I successfully run `ppgen create file`
18
+ Then the file "out.d/asdf.pp" should contain:
19
+ """
20
+ class mymodule::asdf {
21
+ file {'asdf':
22
+ ensure => file,
23
+ }
24
+ }
25
+
26
+ """
27
+
28
+ Scenario: Non Existing Input File
29
+ When I run `ppgen create file`
30
+ Then the exit status should be 8
31
+ And the stderr should contain "The file/directory \"input.txt\" does not exist"
32
+
33
+ Scenario: Input via Stdin
34
+ When I run `ppgen create file --source stdin` interactively
35
+ And I type "asdf"
36
+ And I close the stdin stream
37
+ Then the file "out.d/asdf.pp" should contain:
38
+ """
39
+ class mymodule::asdf {
40
+ file {'asdf':
41
+ ensure => file,
42
+ }
43
+ }
44
+
45
+ """
46
+
47
+ Scenario: empty input source
48
+ When I run `ppgen create file --source ''`
49
+ Then the exit status should be 8
50
+ And the stderr should contain "The file/directory \"\" does not exist."
51
+
52
+ Scenario: Multiple lines in input file
53
+ Given a file named "input.txt" with:
54
+ """
55
+ asdf
56
+ test123
57
+ """
58
+ When I successfully run `ppgen create file`
59
+ Then the file "out.d/asdf.pp" should contain:
60
+ """
61
+ class mymodule::asdf {
62
+ file {'asdf':
63
+ ensure => file,
64
+ }
65
+ }
66
+
67
+ """
68
+ And the file "out.d/test123.pp" should contain:
69
+ """
70
+ class mymodule::test123 {
71
+ file {'test123':
72
+ ensure => file,
73
+ }
74
+ }
75
+
76
+ """
77
+
78
+ Scenario: Module name given
79
+ Given a file named "input.txt" with:
80
+ """
81
+ asdf
82
+ """
83
+ When I successfully run `ppgen create file --module string1::string2`
84
+ Then the file "out.d/asdf.pp" should contain:
85
+ """
86
+ class string1::string2::asdf {
87
+ file {'asdf':
88
+ ensure => file,
89
+ }
90
+ }
91
+
92
+ """
93
+
94
+ Scenario: Multiple lines in input file with one output file
95
+ Given a file named "input.txt" with:
96
+ """
97
+ asdf
98
+ test123
99
+ """
100
+ When I successfully run `ppgen create file --destination file:out.txt`
101
+ Then the file "out.txt" should contain:
102
+ """
103
+ class mymodule::myclass {
104
+ file {'asdf':
105
+ ensure => file,
106
+ }
107
+ file {'test123':
108
+ ensure => file,
109
+ }
110
+ }
111
+
112
+ """
113
+
114
+ Scenario: Output to stdout
115
+ Given a file named "input.txt" with:
116
+ """
117
+ asdf
118
+ """
119
+ When I successfully run `ppgen create file --destination stdout`
120
+ Then the stdout should contain:
121
+ """
122
+ class mymodule::myclass {
123
+ file {'asdf':
124
+ ensure => file,
125
+ }
126
+ }
127
+
128
+ """
129
+
130
+ Scenario: Multiple lines in input file with one output file and one module definition
131
+ Given a file named "input.txt" with:
132
+ """
133
+ asdf
134
+ test123
135
+ """
136
+ When I successfully run `ppgen create file --destination file:out.txt --class test`
137
+ Then the file "out.txt" should contain:
138
+ """
139
+ class mymodule::test {
140
+ file {'asdf':
141
+ ensure => file,
142
+ }
143
+ file {'test123':
144
+ ensure => file,
145
+ }
146
+ }
147
+
148
+ """
149
+
150
+ Scenario: Real path with output to single file
151
+ Given a file named "input.txt" with:
152
+ """
153
+ path/to/file
154
+ """
155
+ When I successfully run `ppgen create file --destination file:out.txt`
156
+ Then the file "out.txt" should contain:
157
+ """
158
+ class mymodule::myclass {
159
+ file {'path/to/file':
160
+ ensure => file,
161
+ }
162
+ }
163
+
164
+ """
165
+
166
+ Scenario: Real path with output to multiple files
167
+ Given a file named "input.txt" with:
168
+ """
169
+ path/to/file1
170
+ """
171
+ When I successfully run `ppgen create file --destination dir:out.d`
172
+ Then the file "out.d/file1.pp" should contain:
173
+ """
174
+ class mymodule::file1 {
175
+ file {'path/to/file1':
176
+ ensure => file,
177
+ }
178
+ }
179
+
180
+ """
181
+
182
+ Scenario: With file system meta data
183
+ Given a directory named "testdir"
184
+ And an empty file named "testdir/file1" with mode "0644"
185
+ And an empty file named "testdir/file2" with mode "0644"
186
+ And an empty file named "testdir/file3" with mode "0644"
187
+ When I successfully run `ppgen create file --source testdir --destination file:out.txt --export-filter filesystem_attributes`
188
+ Then the file "out.txt" should contain:
189
+ """
190
+ class mymodule::myclass
191
+ """
192
+ And the file "out.txt" should contain:
193
+ """
194
+ file {'testdir':
195
+ """
196
+ And the file "out.txt" should contain:
197
+ """
198
+ file {'testdir/file1':
199
+ """
200
+ And the file "out.txt" should contain:
201
+ """
202
+ file {'testdir/file2':
203
+ """
204
+ And the file "out.txt" should contain:
205
+ """
206
+ file {'testdir/file3':
207
+ """
208
+ And the file "out.txt" should contain:
209
+ """
210
+ owner =>
211
+ """
212
+ And the file "out.txt" should contain:
213
+ """
214
+ mode => '100644',
215
+ """
216
+
217
+ Scenario: With file system meta data in separate files
218
+ Given a directory named "testdir"
219
+ And an empty file named "testdir/file1" with mode "0644"
220
+ And an empty file named "testdir/file2" with mode "0644"
221
+ And an empty file named "testdir/file3" with mode "0644"
222
+ When I successfully run `ppgen create file --source testdir --export-filter filesystem_attributes`
223
+ Then the file "out.d/file1.pp" should contain:
224
+ """
225
+ file {'testdir/file1':
226
+ ensure => file,
227
+ """
228
+ Then the file "out.d/testdir.pp" should contain:
229
+ """
230
+ file {'testdir':
231
+ ensure => directory,
232
+ """
233
+ Then the file "out.d/file3.pp" should contain:
234
+ """
235
+ file {'testdir/file3':
236
+ ensure => file,
237
+ """
238
+ Then the file "out.d/file2.pp" should contain:
239
+ """
240
+ file {'testdir/file2':
241
+ ensure => file,
242
+ """
243
+ Then the file "out.d/file2.pp" should contain:
244
+ """
245
+ mode => '100644',
246
+ """
247
+
248
+ Scenario: Copy files afterwards
249
+ Given a directory named "testdir"
250
+ And a file named "testdir/file1" with:
251
+ """
252
+ asdf
253
+ """
254
+ And an empty file named "testdir/file2"
255
+ And an empty file named "testdir/file3"
256
+ When I successfully run `ppgen create module`
257
+ And I successfully run `ppgen create file --source testdir --action copy_files_to_module_directory`
258
+ Then a directory named "mymodule" should exist
259
+ And a directory named "mymodule/files/testdir" should exist
260
+ And the file "mymodule/files/testdir/file1" should contain:
261
+ """
262
+ asdf
263
+ """
264
+
265
+ Scenario: Fails if wrong action is chosen
266
+ Given a directory named "testdir"
267
+ When I run `ppgen create file --source testdir --action unknown_action`
268
+ Then the exit status should be 7
269
+ And the stderr should contain "unknown_action"
270
+
271
+ Scenario: Use a tag to choose the correct template
272
+ Given a file named "input.txt" with:
273
+ """
274
+ asdf1
275
+ asdf2
276
+ """
277
+ When I successfully run `ppgen create file --template-tagged-with many_per_file --destination file:output.txt`
278
+ Then the file "output.txt" should contain:
279
+ """
280
+ class mymodule::myclass {
281
+ file {'asdf1':
282
+ ensure => file,
283
+ }
284
+ file {'asdf2':
285
+ ensure => file,
286
+ }
287
+ }
288
+
289
+ """
290
+
291
+ Scenario: Error if chosen a wrong combination
292
+ Given a file named "input.txt" with:
293
+ """
294
+ asdf1
295
+ asdf2
296
+ """
297
+ When I run `ppgen create file --template-tagged-with many_per_file`
298
+ Then the exit status should be 9
299
+ Then the stderr should contain:
300
+ """
301
+ I was not able to find a suitable template for the given command "file", for the given tags "many_per_file" and for the given destination "dir:out.d"
302
+ """
303
+
304
+ Scenario: Export filter null
305
+ Given a file named "input.txt" with:
306
+ """
307
+ asdf1
308
+ asdf2
309
+ """
310
+ And an empty file named "asdf1" with mode "644"
311
+ When I successfully run `ppgen create file --export-filter null`
312
+ Then the file "out.d/asdf1.pp" should contain:
313
+ """
314
+ class mymodule::asdf1 {
315
+ file {'asdf1':
316
+ ensure => file,
317
+ }
318
+ }
319
+
320
+ """
321
+
322
+ Scenario: Export filter filesystem attributes
323
+ Given a file named "input.txt" with:
324
+ """
325
+ asdf1
326
+ asdf2
327
+ """
328
+ And an empty file named "asdf1" with mode "0644"
329
+ When I successfully run `ppgen create file --export-filter filesystem_attributes`
330
+ Then the file "out.d/asdf1.pp" should contain:
331
+ """
332
+ class mymodule::asdf1 {
333
+ """
334
+ And the file "out.d/asdf1.pp" should contain:
335
+ """
336
+ file {'asdf1':
337
+ """
338
+ And the file "out.d/asdf1.pp" should contain:
339
+ """
340
+ ensure => file,
341
+ """
342
+ And the file "out.d/asdf1.pp" should contain:
343
+ """
344
+ owner =>
345
+ """
346
+ And the file "out.d/asdf1.pp" should contain:
347
+ """
348
+ mode => '100644',
349
+ """
350
+ And the file "out.d/asdf1.pp" should contain:
351
+ """
352
+ }
353
+ """
354
+ And the file "out.d/asdf1.pp" should contain:
355
+ """
356
+ }
357
+ """
@@ -0,0 +1,36 @@
1
+ Feature: Generate module directories definitions
2
+
3
+ As a administrator
4
+ I need to create a module for puppet
5
+ In order to get those things up and running via puppet
6
+
7
+ Background: Process environment
8
+ Given I set the environment variables to:
9
+ | variable | value |
10
+ | PUPPET_GENERATOR_ENV | test |
11
+
12
+ Scenario: predefined module name
13
+ When I successfully run `ppgen create module`
14
+ Then a directory named "mymodule" should exist
15
+ And a directory named "mymodule/manifests" should exist
16
+ And a directory named "mymodule/files" should exist
17
+ And the file "mymodule/manifests/init.pp" should contain:
18
+ """
19
+ class mymodule {
20
+
21
+ }
22
+
23
+ """
24
+
25
+ Scenario: Different name for module
26
+ When I successfully run `ppgen create module --module testmodule`
27
+ Then a directory named "testmodule" should exist
28
+ And a directory named "testmodule/manifests" should exist
29
+ And a directory named "testmodule/files" should exist
30
+ And the file "testmodule/manifests/init.pp" should contain:
31
+ """
32
+ class testmodule {
33
+
34
+ }
35
+
36
+ """
@@ -0,0 +1,206 @@
1
+ Feature: Generate package definitions
2
+
3
+ As a administrator
4
+ I need to write packages definitions for puppet
5
+ In order to get those things up and running via puppet
6
+
7
+ Background: Process environment
8
+ Given I set the environment variables to:
9
+ | variable | value |
10
+ | PUPPET_GENERATOR_ENV | test |
11
+
12
+ Scenario: Existing Input File
13
+ Given a file named "input.txt" with:
14
+ """
15
+ asdf
16
+ """
17
+ When I successfully run `ppgen create package`
18
+ Then the file "out.d/asdf.pp" should contain:
19
+ """
20
+ class mymodule::asdf {
21
+ package {'asdf':
22
+ ensure => installed,
23
+ }
24
+ }
25
+
26
+ """
27
+
28
+ Scenario: Non Existing Input File
29
+ When I run `ppgen create package`
30
+ Then the exit status should be 8
31
+ And the stderr should contain "The file/directory \"input.txt\" does not exist"
32
+
33
+ Scenario: Input via Stdin
34
+ When I run `ppgen create package --source stdin` interactively
35
+ And I type "asdf"
36
+ And I close the stdin stream
37
+ Then the file "out.d/asdf.pp" should contain:
38
+ """
39
+ class mymodule::asdf {
40
+ package {'asdf':
41
+ ensure => installed,
42
+ }
43
+ }
44
+
45
+ """
46
+
47
+ Scenario: Invalid importer
48
+ Given a directory named "testdir"
49
+ When I run `ppgen create package --source testdir --destination file:out.txt`
50
+ Then the exit status should be 1
51
+ And the stderr should contain "You entered an invalid source"
52
+
53
+ Scenario: Multiple lines in input file
54
+ Given a file named "input.txt" with:
55
+ """
56
+ asdf
57
+ test123
58
+ """
59
+ When I successfully run `ppgen create package`
60
+ Then the file "out.d/asdf.pp" should contain:
61
+ """
62
+ class mymodule::asdf {
63
+ package {'asdf':
64
+ ensure => installed,
65
+ }
66
+ }
67
+
68
+ """
69
+ And the file "out.d/test123.pp" should contain:
70
+ """
71
+ class mymodule::test123 {
72
+ package {'test123':
73
+ ensure => installed,
74
+ }
75
+ }
76
+
77
+ """
78
+
79
+ Scenario: Module name given
80
+ Given a file named "input.txt" with:
81
+ """
82
+ asdf
83
+ """
84
+ When I successfully run `ppgen create package --module string1::string2`
85
+ Then the file "out.d/asdf.pp" should contain:
86
+ """
87
+ class string1::string2::asdf {
88
+ package {'asdf':
89
+ ensure => installed,
90
+ }
91
+ }
92
+
93
+ """
94
+
95
+ Scenario: Multiple lines in input file with one output file
96
+ Given a file named "input.txt" with:
97
+ """
98
+ asdf
99
+ test123
100
+ """
101
+ When I successfully run `ppgen create package --destination file:out.txt`
102
+ Then the file "out.txt" should contain:
103
+ """
104
+ class mymodule::myclass {
105
+ package {'asdf':
106
+ ensure => installed,
107
+ }
108
+ package {'test123':
109
+ ensure => installed,
110
+ }
111
+ }
112
+
113
+ """
114
+
115
+ Scenario: Output to stdout
116
+ Given a file named "input.txt" with:
117
+ """
118
+ asdf
119
+ """
120
+ When I successfully run `ppgen create package --destination stdout`
121
+ Then the output should contain:
122
+ """
123
+ class mymodule::myclass {
124
+ package {'asdf':
125
+ ensure => installed,
126
+ }
127
+ }
128
+
129
+ """
130
+
131
+ Scenario: Multiple lines in input file with one output file and one module definition
132
+ Given a file named "input.txt" with:
133
+ """
134
+ asdf
135
+ test123
136
+ """
137
+ When I successfully run `ppgen create package --destination file:out.txt --class test`
138
+ Then the file "out.txt" should contain:
139
+ """
140
+ class mymodule::test {
141
+ package {'asdf':
142
+ ensure => installed,
143
+ }
144
+ package {'test123':
145
+ ensure => installed,
146
+ }
147
+ }
148
+
149
+ """
150
+
151
+ Scenario: Definition from yaml file
152
+ Given a file named "input.yml" with:
153
+ """
154
+ ---
155
+ ssh-server:
156
+ version: 1.2.3
157
+ provider: yum
158
+ ssh-client:
159
+ version: latest
160
+ zsh:
161
+ version: installed
162
+ bash: {}
163
+ """
164
+ When I successfully run `ppgen create package --source input.yml --destination file:out.txt --import-filter yaml`
165
+ Then the file "out.txt" should contain:
166
+ """
167
+ class mymodule::myclass {
168
+ package {'ssh-server':
169
+ ensure => 1.2.3,
170
+ provider => yum,
171
+ }
172
+ package {'ssh-client':
173
+ ensure => latest,
174
+ }
175
+ package {'zsh':
176
+ ensure => installed,
177
+ }
178
+ package {'bash':
179
+ ensure => installed,
180
+ }
181
+ }
182
+
183
+ """
184
+
185
+ Scenario: Definition from yaml file with error
186
+ Given a file named "input.yml" with:
187
+ """
188
+ ---
189
+ ssh-server:
190
+ version: 1.2.3
191
+ zsh:
192
+ version: installed
193
+ bash: {}
194
+ """
195
+ When I run `ppgen create package --source input.yml --destination file:out.txt --import-filter yaml`
196
+ Then the exit status should be 5
197
+ And the stderr should contain "The input is no YAML valid for this use case"
198
+
199
+ Scenario: Unknown import filter
200
+ Given a file named "input.txt" with:
201
+ """
202
+ asdf
203
+ """
204
+ When I run `ppgen create package --import-filter asfd`
205
+ Then the exit status should be 4
206
+ And the stderr should contain "There's no import filter \"asfd\""
@@ -0,0 +1,64 @@
1
+ Feature: Generate role definitions
2
+
3
+ As a administrator
4
+ I need to write role definitions for puppet
5
+ In order to get those things up and running via puppet
6
+
7
+ Background: Process environment
8
+ Given I set the environment variables to:
9
+ | variable | value |
10
+ | PUPPET_GENERATOR_ENV | test |
11
+
12
+ Scenario: Plain Input File
13
+ Given a file named "input.txt" with:
14
+ """
15
+ asdf
16
+ """
17
+ When I successfully run `ppgen create role`
18
+ Then the file "out.d/asdf.pp" should contain:
19
+ """
20
+ class mymodule::asdf {
21
+ }
22
+
23
+ """
24
+
25
+ Scenario: Yaml Input File
26
+ Given a file named "input.yml" with:
27
+ """
28
+ yaml_test:
29
+ includes:
30
+ - one
31
+ - two
32
+ yaml_test2:
33
+ includes:
34
+ - one
35
+ - two
36
+ """
37
+ When I successfully run `ppgen create role --source input.yml --destination file:output.txt --import-filter yaml`
38
+ Then the file "output.txt" should contain:
39
+ """
40
+ class mymodule::yaml_test {
41
+ include mymodule::yaml_test::one
42
+ include mymodule::yaml_test::two
43
+ }
44
+ class mymodule::yaml_test2 {
45
+ include mymodule::yaml_test2::one
46
+ include mymodule::yaml_test2::two
47
+ }
48
+
49
+ """
50
+
51
+ Scenario: Scan module
52
+ Given a directory named "test"
53
+ And a directory named "test/dir1"
54
+ And an empty file named "test/dir1/file1.pp"
55
+ And an empty file named "test/dir1/file2.pp"
56
+ When I successfully run `ppgen create role --source test --destination dir:./ --export-filter build_role_includes_for_directory`
57
+ Then the file "test/dir1.pp" should contain:
58
+ """
59
+ class mymodule::dir1 {
60
+ include mymodule::dir1::file1
61
+ include mymodule::dir1::file2
62
+ }
63
+
64
+ """