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.
- data/.gitignore +17 -0
- data/.rdebugrc +7 -0
- data/.rspec +2 -0
- data/.simplecov +8 -0
- data/.travis.yml +6 -0
- data/.yardopts +5 -0
- data/CONTRIBUTING.md +8 -0
- data/Gemfile +34 -0
- data/LICENSE.md +22 -0
- data/README.DEVELOPER.md +11 -0
- data/README.md +477 -0
- data/Rakefile +3 -0
- data/TODO.md +2 -0
- data/bin/ppgen +16 -0
- data/cucumber.yml +2 -0
- data/features/generate_file_definition.feature +357 -0
- data/features/generate_module_directories.feature +36 -0
- data/features/generate_package_definition.feature +206 -0
- data/features/generate_role_definitions.feature +64 -0
- data/features/generate_user_definition.feature +193 -0
- data/features/list.feature +22 -0
- data/features/log_actions.feature +93 -0
- data/features/step_definitions.rb +3 -0
- data/features/support/env.rb +7 -0
- data/features/tasks.feature +25 -0
- data/gemfiles/Gemfile.default +34 -0
- data/gemfiles/Gemfile.travis +17 -0
- data/lib/puppet_generator/actions/copy_files_to_module_directory.rb +23 -0
- data/lib/puppet_generator/actions/null.rb +9 -0
- data/lib/puppet_generator/api.rb +108 -0
- data/lib/puppet_generator/definition.rb +10 -0
- data/lib/puppet_generator/entry_converters/file.rb +9 -0
- data/lib/puppet_generator/entry_converters/package.rb +9 -0
- data/lib/puppet_generator/entry_converters/role.rb +9 -0
- data/lib/puppet_generator/entry_converters/user.rb +9 -0
- data/lib/puppet_generator/exceptions.rb +104 -0
- data/lib/puppet_generator/export_filters/build_role_includes_for_directory.rb +35 -0
- data/lib/puppet_generator/export_filters/filesystem_attributes.rb +57 -0
- data/lib/puppet_generator/export_filters/null.rb +9 -0
- data/lib/puppet_generator/exporters/directory.rb +23 -0
- data/lib/puppet_generator/exporters/file.rb +17 -0
- data/lib/puppet_generator/exporters/stdout.rb +16 -0
- data/lib/puppet_generator/import_filters/null.rb +9 -0
- data/lib/puppet_generator/import_filters/passwd.rb +22 -0
- data/lib/puppet_generator/import_filters/yaml.rb +20 -0
- data/lib/puppet_generator/importers/directory.rb +21 -0
- data/lib/puppet_generator/importers/file.rb +17 -0
- data/lib/puppet_generator/importers/stdin.rb +16 -0
- data/lib/puppet_generator/logger.rb +62 -0
- data/lib/puppet_generator/main.rb +36 -0
- data/lib/puppet_generator/middleware/apply_export_filters.rb +33 -0
- data/lib/puppet_generator/middleware/check_for_empty_source.rb +16 -0
- data/lib/puppet_generator/middleware/configure_logging.rb +30 -0
- data/lib/puppet_generator/middleware/create_module_directories.rb +42 -0
- data/lib/puppet_generator/middleware/create_output.rb +46 -0
- data/lib/puppet_generator/middleware/create_puppet_object_from_entry.rb +24 -0
- data/lib/puppet_generator/middleware/enable_debugging_libraries.rb +15 -0
- data/lib/puppet_generator/middleware/execute_actions.rb +34 -0
- data/lib/puppet_generator/middleware/filter_imported_data.rb +22 -0
- data/lib/puppet_generator/middleware/handle_errors.rb +62 -0
- data/lib/puppet_generator/middleware/output_debug_information_for_models.rb +21 -0
- data/lib/puppet_generator/middleware/read_input.rb +27 -0
- data/lib/puppet_generator/models/action.rb +36 -0
- data/lib/puppet_generator/models/base.rb +115 -0
- data/lib/puppet_generator/models/class_based_model.rb +56 -0
- data/lib/puppet_generator/models/entry_converter.rb +39 -0
- data/lib/puppet_generator/models/error_message.rb +60 -0
- data/lib/puppet_generator/models/export_filter.rb +44 -0
- data/lib/puppet_generator/models/exporter.rb +51 -0
- data/lib/puppet_generator/models/filesystem_based_model.rb +63 -0
- data/lib/puppet_generator/models/import_filter.rb +44 -0
- data/lib/puppet_generator/models/importer.rb +52 -0
- data/lib/puppet_generator/models/logger.rb +11 -0
- data/lib/puppet_generator/models/template.rb +120 -0
- data/lib/puppet_generator/puppet_helper.rb +19 -0
- data/lib/puppet_generator/puppet_objects/file.rb +29 -0
- data/lib/puppet_generator/puppet_objects/package.rb +24 -0
- data/lib/puppet_generator/puppet_objects/role.rb +27 -0
- data/lib/puppet_generator/puppet_objects/user.rb +27 -0
- data/lib/puppet_generator/setup/bare.rb +25 -0
- data/lib/puppet_generator/setup/default_actions.rb +9 -0
- data/lib/puppet_generator/setup/default_entry_converter.rb +8 -0
- data/lib/puppet_generator/setup/default_error_messages.rb +10 -0
- data/lib/puppet_generator/setup/default_export_filter.rb +9 -0
- data/lib/puppet_generator/setup/default_exporter.rb +11 -0
- data/lib/puppet_generator/setup/default_import_filter.rb +10 -0
- data/lib/puppet_generator/setup/default_importer.rb +10 -0
- data/lib/puppet_generator/setup/file.rb +29 -0
- data/lib/puppet_generator/setup/module.rb +22 -0
- data/lib/puppet_generator/setup/package.rb +27 -0
- data/lib/puppet_generator/setup/role.rb +28 -0
- data/lib/puppet_generator/setup/user.rb +27 -0
- data/lib/puppet_generator/task.rb +39 -0
- data/lib/puppet_generator/ui/commandline_parser_helper.rb +31 -0
- data/lib/puppet_generator/ui/create.rb +59 -0
- data/lib/puppet_generator/ui/runner.rb +23 -0
- data/lib/puppet_generator/ui/tasks.rb +16 -0
- data/lib/puppet_generator/version.rb +4 -0
- data/lib/puppet_generator.rb +79 -0
- data/puppet_generator.gemspec +35 -0
- data/rakefiles/default.rake +3 -0
- data/rakefiles/travis.rake +3 -0
- data/script/console +8 -0
- data/script/terminal +16 -0
- data/spec/examples/actions/missing_method.rb +7 -0
- data/spec/examples/apply_export_filters/file.txt +0 -0
- data/spec/examples/entry_converters/missing_method.rb +7 -0
- data/spec/examples/execute_actions/file.txt +0 -0
- data/spec/examples/export_filter/invalid_filter_1.rb +8 -0
- data/spec/examples/export_filter/invalid_filter_2.rb +7 -0
- data/spec/examples/export_filter/missing_method.rb +7 -0
- data/spec/examples/exporter/missing_method.rb +7 -0
- data/spec/examples/exporter/test.d/.gitkeep +0 -0
- data/spec/examples/exporter/test_file.txt +1 -0
- data/spec/examples/import_filter/forbidden_keyword.rb +0 -0
- data/spec/examples/import_filter/invalid_filter_1.rb +8 -0
- data/spec/examples/import_filter/invalid_filter_2.rb +7 -0
- data/spec/examples/import_filter/missing_method.rb +7 -0
- data/spec/examples/importer/missing_method.rb +7 -0
- data/spec/examples/importer/test.d/.gitkeep +0 -0
- data/spec/examples/importer/test_file.txt +1 -0
- data/spec/examples/templates/invalid_template.pp.erb +1 -0
- data/spec/examples/templates/missing_method.rb +7 -0
- data/spec/export_filters/build_role_includes_for_directory_spec.rb +39 -0
- data/spec/middleware/apply_export_filters_spec.rb +45 -0
- data/spec/middleware/execute_actions_spec.rb +44 -0
- data/spec/middleware/handle_errors_spec.rb +12 -0
- data/spec/models/action_spec.rb +37 -0
- data/spec/models/entry_converter_spec.rb +59 -0
- data/spec/models/error_message_spec.rb +78 -0
- data/spec/models/export_filter_spec.rb +36 -0
- data/spec/models/exporter_spec.rb +71 -0
- data/spec/models/import_filter_spec.rb +33 -0
- data/spec/models/importer_spec.rb +66 -0
- data/spec/models/template_spec.rb +47 -0
- data/spec/puppet_generator_spec.rb +7 -0
- data/spec/setup/role_spec.rb +22 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/filesystem_helper.rb +12 -0
- data/spec/support/libraries.rb +10 -0
- data/spec/support/rspec_configuration.rb +5 -0
- data/templates/puppet/many_per_file/file.pp.erb +16 -0
- data/templates/puppet/many_per_file/package.pp.erb +10 -0
- data/templates/puppet/many_per_file/role.pp.erb +7 -0
- data/templates/puppet/many_per_file/user.pp.erb +23 -0
- data/templates/puppet/one_per_file/file.pp.erb +14 -0
- data/templates/puppet/one_per_file/package.pp.erb +8 -0
- data/templates/puppet/one_per_file/role.pp.erb +5 -0
- data/templates/puppet/one_per_file/user.pp.erb +21 -0
- metadata +374 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Feature: Generate user definitions
|
|
2
|
+
|
|
3
|
+
As a administrator
|
|
4
|
+
I need to write users 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 user`
|
|
18
|
+
Then the file "out.d/asdf.pp" should contain:
|
|
19
|
+
"""
|
|
20
|
+
class mymodule::asdf {
|
|
21
|
+
user {'asdf':
|
|
22
|
+
ensure => present,
|
|
23
|
+
managehome => true,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
Scenario: Non Existing Input File
|
|
30
|
+
When I run `ppgen create user`
|
|
31
|
+
Then the exit status should be 8
|
|
32
|
+
And the stderr should contain "The file/directory \"input.txt\" does not exist."
|
|
33
|
+
|
|
34
|
+
Scenario: Input via Stdin
|
|
35
|
+
When I run `ppgen create user --source stdin` interactively
|
|
36
|
+
And I type "asdf"
|
|
37
|
+
And I close the stdin stream
|
|
38
|
+
Then the file "out.d/asdf.pp" should contain:
|
|
39
|
+
"""
|
|
40
|
+
class mymodule::asdf {
|
|
41
|
+
user {'asdf':
|
|
42
|
+
ensure => present,
|
|
43
|
+
managehome => true,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
Scenario: Multiple lines in input file
|
|
50
|
+
Given a file named "input.txt" with:
|
|
51
|
+
"""
|
|
52
|
+
asdf
|
|
53
|
+
test123
|
|
54
|
+
"""
|
|
55
|
+
When I successfully run `ppgen create user`
|
|
56
|
+
Then the file "out.d/asdf.pp" should contain:
|
|
57
|
+
"""
|
|
58
|
+
class mymodule::asdf {
|
|
59
|
+
user {'asdf':
|
|
60
|
+
ensure => present,
|
|
61
|
+
managehome => true,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
"""
|
|
66
|
+
And the file "out.d/test123.pp" should contain:
|
|
67
|
+
"""
|
|
68
|
+
class mymodule::test123 {
|
|
69
|
+
user {'test123':
|
|
70
|
+
ensure => present,
|
|
71
|
+
managehome => true,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
Scenario: Module name given
|
|
78
|
+
Given a file named "input.txt" with:
|
|
79
|
+
"""
|
|
80
|
+
asdf
|
|
81
|
+
"""
|
|
82
|
+
When I successfully run `ppgen create user --module string1::string2`
|
|
83
|
+
Then the file "out.d/asdf.pp" should contain:
|
|
84
|
+
"""
|
|
85
|
+
class string1::string2::asdf {
|
|
86
|
+
user {'asdf':
|
|
87
|
+
ensure => present,
|
|
88
|
+
managehome => true,
|
|
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 user --destination file:out.txt`
|
|
101
|
+
Then the file "out.txt" should contain:
|
|
102
|
+
"""
|
|
103
|
+
class mymodule::myclass {
|
|
104
|
+
user {'asdf':
|
|
105
|
+
ensure => present,
|
|
106
|
+
managehome => true,
|
|
107
|
+
}
|
|
108
|
+
user {'test123':
|
|
109
|
+
ensure => present,
|
|
110
|
+
managehome => true,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
Scenario: Output to stdout
|
|
117
|
+
Given a file named "input.txt" with:
|
|
118
|
+
"""
|
|
119
|
+
asdf
|
|
120
|
+
"""
|
|
121
|
+
When I successfully run `ppgen create user --destination stdout`
|
|
122
|
+
Then the stdout should contain:
|
|
123
|
+
"""
|
|
124
|
+
class mymodule::myclass {
|
|
125
|
+
user {'asdf':
|
|
126
|
+
ensure => present,
|
|
127
|
+
managehome => true,
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
Scenario: Multiple lines in input file with one output file and one module definition
|
|
134
|
+
Given a file named "input.txt" with:
|
|
135
|
+
"""
|
|
136
|
+
asdf
|
|
137
|
+
test123
|
|
138
|
+
"""
|
|
139
|
+
When I successfully run `ppgen create user --destination file:out.txt --class test`
|
|
140
|
+
Then the file "out.txt" should contain:
|
|
141
|
+
"""
|
|
142
|
+
class mymodule::test {
|
|
143
|
+
user {'asdf':
|
|
144
|
+
ensure => present,
|
|
145
|
+
managehome => true,
|
|
146
|
+
}
|
|
147
|
+
user {'test123':
|
|
148
|
+
ensure => present,
|
|
149
|
+
managehome => true,
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
Scenario: Using passwd
|
|
156
|
+
Given a file named "etc_passwd" with:
|
|
157
|
+
"""
|
|
158
|
+
root:x:0:0:root:/root:/bin/bash
|
|
159
|
+
mail:x:8:12:mail:/var/spool/mail:/bin/false
|
|
160
|
+
"""
|
|
161
|
+
When I successfully run `ppgen create user --source etc_passwd --destination file:out.txt --import-filter passwd`
|
|
162
|
+
Then the file "out.txt" should contain:
|
|
163
|
+
"""
|
|
164
|
+
class mymodule::myclass {
|
|
165
|
+
user {'root':
|
|
166
|
+
ensure => present,
|
|
167
|
+
managehome => true,
|
|
168
|
+
uid => '0',
|
|
169
|
+
gid => '0',
|
|
170
|
+
home => '/root',
|
|
171
|
+
shell => '/bin/bash',
|
|
172
|
+
}
|
|
173
|
+
user {'mail':
|
|
174
|
+
ensure => present,
|
|
175
|
+
managehome => true,
|
|
176
|
+
uid => '8',
|
|
177
|
+
gid => '12',
|
|
178
|
+
home => '/var/spool/mail',
|
|
179
|
+
shell => '/bin/false',
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
Scenario: Using passwd with error
|
|
186
|
+
Given a file named "etc_passwd" with:
|
|
187
|
+
"""
|
|
188
|
+
root:x:0:0:root:/root:/bin/bash
|
|
189
|
+
mail:
|
|
190
|
+
"""
|
|
191
|
+
When I run `ppgen create user --source etc_passwd --destination file:out.txt --import-filter passwd`
|
|
192
|
+
Then the exit status should be 6
|
|
193
|
+
And the stderr should contain "The input is no passwd file valid for this use case"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Feature: List things
|
|
2
|
+
|
|
3
|
+
As a administrator
|
|
4
|
+
I want to get a list of available <resources>
|
|
5
|
+
In order to start in using the puppet generator
|
|
6
|
+
|
|
7
|
+
Background: Process environment
|
|
8
|
+
Given I set the environment variables to:
|
|
9
|
+
| variable | value |
|
|
10
|
+
| PUPPET_GENERATOR_ENV | test |
|
|
11
|
+
|
|
12
|
+
Scenario: List available ressources
|
|
13
|
+
When I successfully run `ppgen help list`
|
|
14
|
+
Then the output contains:
|
|
15
|
+
"""
|
|
16
|
+
resources
|
|
17
|
+
exporter
|
|
18
|
+
importer
|
|
19
|
+
import_filter
|
|
20
|
+
export_filter
|
|
21
|
+
"""
|
|
22
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Feature: Logging
|
|
2
|
+
|
|
3
|
+
As a software developer
|
|
4
|
+
I need more feedback during development
|
|
5
|
+
In order to get those things up and running
|
|
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 with verbose information
|
|
13
|
+
Given a file named "input.txt" with:
|
|
14
|
+
"""
|
|
15
|
+
asdf
|
|
16
|
+
"""
|
|
17
|
+
When I successfully run `ppgen create file --debug`
|
|
18
|
+
Then the stderr should contain:
|
|
19
|
+
"""
|
|
20
|
+
Logging is configured with mode "debug".
|
|
21
|
+
"""
|
|
22
|
+
Then the stderr should contain:
|
|
23
|
+
"""
|
|
24
|
+
Available templates: file, file
|
|
25
|
+
"""
|
|
26
|
+
Then the stderr should contain:
|
|
27
|
+
"""
|
|
28
|
+
Available import filter: null, yaml
|
|
29
|
+
"""
|
|
30
|
+
Then the stderr should contain:
|
|
31
|
+
"""
|
|
32
|
+
Available export filter: filesystem_attributes, null
|
|
33
|
+
"""
|
|
34
|
+
Then the stderr should contain:
|
|
35
|
+
"""
|
|
36
|
+
Available actions: copy_files_to_module_directory, null
|
|
37
|
+
"""
|
|
38
|
+
Then the stderr should contain:
|
|
39
|
+
"""
|
|
40
|
+
Waiting for errors to occure. ;-)
|
|
41
|
+
"""
|
|
42
|
+
Then the stderr should contain:
|
|
43
|
+
"""
|
|
44
|
+
Read data from input "input.txt".
|
|
45
|
+
"""
|
|
46
|
+
Then the stderr should contain:
|
|
47
|
+
"""
|
|
48
|
+
Using importer "file" to read data.
|
|
49
|
+
"""
|
|
50
|
+
Then the stderr should contain:
|
|
51
|
+
"""
|
|
52
|
+
Count input lines: 1
|
|
53
|
+
"""
|
|
54
|
+
Then the stderr should contain:
|
|
55
|
+
"""
|
|
56
|
+
Checking if given source "input.txt" is empty.
|
|
57
|
+
"""
|
|
58
|
+
Then the stderr should contain:
|
|
59
|
+
"""
|
|
60
|
+
Filter the input with filter "null"
|
|
61
|
+
"""
|
|
62
|
+
Then the stderr should contain:
|
|
63
|
+
"""
|
|
64
|
+
Execute action "null" on output.
|
|
65
|
+
"""
|
|
66
|
+
Then the stderr should contain:
|
|
67
|
+
"""
|
|
68
|
+
Convert entries for command "file"
|
|
69
|
+
"""
|
|
70
|
+
Then the stderr should contain:
|
|
71
|
+
"""
|
|
72
|
+
Render template for channel "dir" and sink "out.d".
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
Scenario: Silent action
|
|
76
|
+
Given a file named "input.txt" with:
|
|
77
|
+
"""
|
|
78
|
+
asdf
|
|
79
|
+
"""
|
|
80
|
+
When I successfully run `ppgen create file --silent`
|
|
81
|
+
Then the output should contain:
|
|
82
|
+
"""
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
Scenario: Normal action
|
|
86
|
+
Given a file named "input.txt" with:
|
|
87
|
+
"""
|
|
88
|
+
asdf
|
|
89
|
+
"""
|
|
90
|
+
When I successfully run `ppgen create file`
|
|
91
|
+
Then the output should contain:
|
|
92
|
+
"""
|
|
93
|
+
"""
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Feature: Use tasks to make usage easier
|
|
2
|
+
|
|
3
|
+
As a administrator
|
|
4
|
+
I need to use the puppet_generator a lot
|
|
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: Scan module
|
|
13
|
+
Given a directory named "test"
|
|
14
|
+
And a directory named "test/dir1"
|
|
15
|
+
And an empty file named "test/dir1/file1.pp"
|
|
16
|
+
And an empty file named "test/dir1/file2.pp"
|
|
17
|
+
When I successfully run `ppgen tasks create_roles_in_directory --source test --destination dir:./`
|
|
18
|
+
Then the file "test/dir1.pp" should contain:
|
|
19
|
+
"""
|
|
20
|
+
class mymodule::dir1 {
|
|
21
|
+
include mymodule::dir1::file1
|
|
22
|
+
include mymodule::dir1::file2
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
"""
|
|
@@ -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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gemspec path: '../'
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem 'rake'
|
|
7
|
+
gem 'rspec'
|
|
8
|
+
gem 'fuubar'
|
|
9
|
+
gem 'aruba', git: 'https://github.com/maxmeyer/aruba.git', branch: 'puppet_generator'
|
|
10
|
+
gem 'cucumber'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
group :documentation do
|
|
14
|
+
gem 'yard'
|
|
15
|
+
gem 'redcarpet'
|
|
16
|
+
gem 'github-markup'
|
|
17
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module PuppetGenerator
|
|
2
|
+
module Actions
|
|
3
|
+
class CopyFilesToModuleDirectory
|
|
4
|
+
def run( task , data )
|
|
5
|
+
src = data.collect { |e| e[:name] }
|
|
6
|
+
dst = File.join( task.meta[:module] , 'files')
|
|
7
|
+
|
|
8
|
+
FileUtils.mkdir_p dst
|
|
9
|
+
FileUtils.cp_r src , dst
|
|
10
|
+
|
|
11
|
+
data.collect { |e| e[:source] = make_source( task.meta[:module] , e[:name]) ; e }
|
|
12
|
+
rescue
|
|
13
|
+
raise Exceptions::ErrorDuringCopyFiles
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def make_source(module_name, src)
|
|
19
|
+
"puppet:///modules/#{module_name}/#{ src.sub( %r[^/], '' ) }"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
module PuppetGenerator
|
|
2
|
+
class Api
|
|
3
|
+
|
|
4
|
+
private
|
|
5
|
+
|
|
6
|
+
def pre_stack
|
|
7
|
+
::Middleware::Builder.new do
|
|
8
|
+
use PuppetGenerator::Middleware::EnableDebuggingLibraries
|
|
9
|
+
use PuppetGenerator::Middleware::ConfigureLogging
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def default_creator_stack
|
|
14
|
+
::Middleware::Builder.new do
|
|
15
|
+
use PuppetGenerator::Middleware::OutputDebugInformationForModels
|
|
16
|
+
use PuppetGenerator::Middleware::HandleErrors
|
|
17
|
+
use PuppetGenerator::Middleware::ReadInput
|
|
18
|
+
use PuppetGenerator::Middleware::CheckForEmptySource
|
|
19
|
+
use PuppetGenerator::Middleware::FilterImportedData
|
|
20
|
+
use PuppetGenerator::Middleware::ApplyExportFilters
|
|
21
|
+
use PuppetGenerator::Middleware::ExecuteActions
|
|
22
|
+
use PuppetGenerator::Middleware::CreatePuppetObjectFromEntry
|
|
23
|
+
use PuppetGenerator::Middleware::CreateOutput
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def _generate_definition(options, setup_klass, startup_message)
|
|
28
|
+
task = _setup options, setup_klass
|
|
29
|
+
pre_stack.call(task)
|
|
30
|
+
|
|
31
|
+
run_with_messages startup_message: startup_message do
|
|
32
|
+
default_creator_stack.call(task)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def _setup(options, klass)
|
|
37
|
+
s = klass.new(options)
|
|
38
|
+
s.setup_environment
|
|
39
|
+
|
|
40
|
+
s.create_task
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
public
|
|
44
|
+
|
|
45
|
+
def generate_package_definition(options)
|
|
46
|
+
_generate_definition options, Setup::Package, "Generating puppet definitions for type \"package\"."
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def generate_file_definition(options)
|
|
50
|
+
_generate_definition options, Setup::File, "Generating puppet definitions for type \"file\"."
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def generate_user_definition(options)
|
|
54
|
+
_generate_definition options, Setup::User, "Generating puppet definitions for type \"user\"."
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def generate_role_definition(options)
|
|
58
|
+
_generate_definition options, Setup::Role, "Generating puppet definitions for type \"role\"."
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def generate_module(options)
|
|
62
|
+
task = _setup options, Setup::Module
|
|
63
|
+
|
|
64
|
+
stack = ::Middleware::Builder.new do
|
|
65
|
+
use PuppetGenerator::Middleware::OutputDebugInformationForModels
|
|
66
|
+
use PuppetGenerator::Middleware::HandleErrors
|
|
67
|
+
use PuppetGenerator::Middleware::CreateModuleDirectories
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
pre_stack.call(task)
|
|
71
|
+
|
|
72
|
+
run_with_messages startup_message: "Generating files and directories to build a module." do
|
|
73
|
+
stack.call(task)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def output_error_messages(options)
|
|
78
|
+
task = Task.new(options, :error_message)
|
|
79
|
+
|
|
80
|
+
stack = ::Middleware::Builder.new do
|
|
81
|
+
use PuppetGenerator::Middleware::OutputDebugInformationForModels
|
|
82
|
+
use PuppetGenerator::Middleware::HandleErrors
|
|
83
|
+
use PuppetGenerator::Middleware::CreateOutput
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
pre_stack.call(task)
|
|
87
|
+
|
|
88
|
+
run_with_messages do
|
|
89
|
+
stack.call(task)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
private
|
|
95
|
+
|
|
96
|
+
def run_with_messages(opts, &block)
|
|
97
|
+
options = {
|
|
98
|
+
startup_message: "Operation successfully started.",
|
|
99
|
+
teardown_message: "Operation successfully ended."
|
|
100
|
+
}.merge opts
|
|
101
|
+
|
|
102
|
+
PuppetGenerator.logger.info(self.class.name) { options[:startup_message] }
|
|
103
|
+
block.call
|
|
104
|
+
PuppetGenerator.logger.info(self.class.name) { options[:teardown_message] }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
end
|