kafo 0.6.12 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +181 -41
- data/bin/kafo-export-params +1 -1
- data/bin/kafofy +36 -18
- data/config/kafo.yaml.example +12 -4
- data/lib/kafo/color_scheme.rb +11 -4
- data/lib/kafo/configuration.rb +137 -20
- data/lib/kafo/exit_handler.rb +4 -2
- data/lib/kafo/hooking.rb +6 -1
- data/lib/kafo/kafo_configure.rb +97 -28
- data/lib/kafo/logger.rb +18 -10
- data/lib/kafo/migration_context.rb +21 -0
- data/lib/kafo/migrations.rb +54 -0
- data/lib/kafo/param.rb +1 -1
- data/lib/kafo/param_builder.rb +1 -1
- data/lib/kafo/params/password.rb +1 -1
- data/lib/kafo/puppet_command.rb +7 -6
- data/lib/kafo/puppet_module.rb +13 -6
- data/lib/kafo/scenario_manager.rb +221 -0
- data/lib/kafo/system_checker.rb +3 -1
- data/lib/kafo/validator.rb +5 -3
- data/lib/kafo/version.rb +1 -1
- data/lib/kafo/wizard.rb +0 -1
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2cd9bfcb84fbe243ae9497b70a2507e6f22a97
|
4
|
+
data.tar.gz: 3754932d4a739e84c8bac944de846275c49d0cf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e101e1d508b08dfe5df3fe967f719d4fa6a7250633e59e6a9cabefb7c8e32c7bb3ad4229d32f4c20aa5de521df6089295ed7f556c294666a0e5125b3483f41ad
|
7
|
+
data.tar.gz: d06b2bea38b080f2a628720120af2f9e5d9c1bb343c14ff05cabe887c911b6aba8555e4eb675edfca569bc60a302d07a005a6015a3ecd9e6916cee0168e13dde
|
data/README.md
CHANGED
@@ -16,10 +16,13 @@ your puppet infrastructure (e.g. install it to your clients) or you want to inst
|
|
16
16
|
it in order to create a puppet infrastructure itself (e.g. foreman or
|
17
17
|
foreman-proxy).
|
18
18
|
|
19
|
-
With kafo you can reuse your puppet modules for creating an installer.
|
19
|
+
With kafo you can reuse your puppet modules for creating an installer.
|
20
20
|
Even better: After the installation you can easily modify your configuration.
|
21
21
|
All using the very same puppet modules.
|
22
22
|
|
23
|
+
With your installer you can also provide multiple configuration files defining
|
24
|
+
different installation scenarios.
|
25
|
+
|
23
26
|
## What does it do, how does it work?
|
24
27
|
|
25
28
|
Kafo reads a config file to find out which modules it should use. Then it
|
@@ -62,35 +65,47 @@ Now we run ```kafofy``` script which will prepare the directory structure and
|
|
62
65
|
optionally create a bin script according to the first parameter.
|
63
66
|
|
64
67
|
```bash
|
65
|
-
kafofy -n foreman-installer
|
68
|
+
kafofy -n foreman-installer -s foreman
|
66
69
|
```
|
67
70
|
|
68
71
|
You can see that it created a modules directory where your puppet modules
|
69
|
-
should live. It also created config and bin directories
|
70
|
-
argument ```--name``` (or -n for short,
|
71
|
-
the "bin" directory with this name will be created.
|
72
|
+
should live. It also created config and bin directories and the default installation
|
73
|
+
scenario config file. If you specify the argument ```--name``` (or -n for short,
|
74
|
+
foreman-installer in this case) a script in the "bin" directory with this name will be created.
|
72
75
|
|
73
76
|
It's the script you can use to run the installer. If you did not specify any
|
74
77
|
arguments you can run your installer by `kafo-configure` which is the default.
|
75
78
|
All configuration related files are to be found in the config directory.
|
76
79
|
|
77
|
-
You can supply custom
|
78
|
-
options:
|
80
|
+
You can supply custom location for your scenario configuration and answer files
|
81
|
+
and change configuration and answer files names using options:
|
79
82
|
```
|
80
83
|
kafofy --help
|
81
84
|
Usage: kafofy [options]
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
+
-c, --config_dir DIR location of the scenarios configuration directory [./config/installer-scenarios.d/]
|
86
|
+
-s, --scenario SCENARIO scenario file name (without extension) [default]
|
87
|
+
-a, --answer_file ANSWERS answer file file name (without extension) [default-answers]
|
88
|
+
-n, --name NAME installer name [kafo-configure]
|
85
89
|
```
|
86
90
|
|
87
|
-
The configuration file will be created by a default template. It's the configuration
|
91
|
+
The scenario configuration file will be created by a default template. It's the configuration
|
88
92
|
of your installer (so you can setup the log level, path to puppet modules etc).
|
89
93
|
On the other hand, the answer file must be created manually. Answer files define
|
90
94
|
which modules should be used and hold all values for the puppet class parameters.
|
91
95
|
|
96
|
+
To add another installation scenario just run kafofy again:
|
97
|
+
```bash
|
98
|
+
kafofy -n foreman-installer -s foreman-proxy
|
99
|
+
```
|
100
|
+
it will create new configuration template for you. You can check available scenarios with:
|
101
|
+
```bash
|
102
|
+
$ bin/foreman-installer --list-scenarios
|
103
|
+
Available scenarios
|
104
|
+
foreman-proxy (use: --scenario foreman-proxy)
|
105
|
+
foreman (use: --scenario foreman)
|
106
|
+
```
|
92
107
|
|
93
|
-
|
108
|
+
Let's see for example how to install foreman:
|
94
109
|
```bash
|
95
110
|
cd foreman-installer/modules
|
96
111
|
git clone https://github.com/theforeman/puppet-foreman/ foreman
|
@@ -99,7 +114,7 @@ You must also download any dependant modules.
|
|
99
114
|
Then you need to tell kafo it's going to use the foreman module.
|
100
115
|
```bash
|
101
116
|
cd ..
|
102
|
-
echo "foreman: true" > config/answers.yaml
|
117
|
+
echo "foreman: true" > config/installer-scenarios.d/foreman-answers.yaml
|
103
118
|
```
|
104
119
|
|
105
120
|
Alternatively you can use the librarian-puppet project to manage all dependencies for you.
|
@@ -107,8 +122,9 @@ You just create a Puppetfile and call librarian to install your modules. See
|
|
107
122
|
https://github.com/rodjek/librarian-puppet for more details.
|
108
123
|
|
109
124
|
When you have your modules in-place, fire the installer with -h as argument
|
125
|
+
and specify the foreman scenario to let installer find the right modules
|
110
126
|
```bash
|
111
|
-
bin/foreman-installer -h
|
127
|
+
bin/foreman-installer -S foreman -h
|
112
128
|
```
|
113
129
|
|
114
130
|
This will show you all the possible arguments you can pass to kafo. Note that underscored
|
@@ -117,9 +133,10 @@ also see a documentation extracted from the foreman puppet module and a default
|
|
117
133
|
value.
|
118
134
|
|
119
135
|
Now run it without the -h argument. It will print you the puppet apply command
|
120
|
-
to execute. This will be automatized later.
|
121
|
-
|
122
|
-
|
136
|
+
to execute. This will be automatized later. Once the installer is run the scenario
|
137
|
+
is remembered and it is not necessary to specify it again.
|
138
|
+
Look at config/answers.yaml, it was populated with default values.
|
139
|
+
To change those options you can use arguments like this
|
123
140
|
|
124
141
|
```bash
|
125
142
|
bin/foreman-installer --foreman-enc=false --foreman-db-type=sqlite
|
@@ -131,8 +148,8 @@ or you can run it in interactive mode
|
|
131
148
|
bin/foreman-installer --interactive
|
132
149
|
```
|
133
150
|
|
134
|
-
Also every change made to the config/answers.yaml persists
|
135
|
-
value for the next run.
|
151
|
+
Also every change made to the `config/installer-scenarios.d/foreman-answers.yaml` persists
|
152
|
+
and becomes the new default value for the next run.
|
136
153
|
|
137
154
|
As you may have noticed there are several ways how to specify arguments. Here's the list:
|
138
155
|
(the lower the item is in this list the higher precedence it has):
|
@@ -144,14 +161,14 @@ As you may have noticed there are several ways how to specify arguments. Here's
|
|
144
161
|
## How do I report bugs or contribute?
|
145
162
|
|
146
163
|
You can find our redmine issue tracker [here](http://projects.theforeman.org/projects/kafo),
|
147
|
-
you can use your github account for logging in. When reporting new issues please
|
164
|
+
you can use your github account for logging in. When reporting new issues please
|
148
165
|
don't forget to specify your:
|
149
166
|
* puppet version
|
150
167
|
* installation options (GEM/RPM/DEB)
|
151
168
|
* error trace (if any) or log with debug level
|
152
169
|
* reproducing steps
|
153
170
|
|
154
|
-
Since Kafo is a side project of Foreman you can use its IRC channels to
|
171
|
+
Since Kafo is a side project of Foreman you can use its IRC channels to
|
155
172
|
contact us on freenode. #theforeman is the channel for generic discussions
|
156
173
|
and #theforeman-dev is reserved only for technical topics. Likewise you can use the Foreman
|
157
174
|
mailing lists on googlegroups. For more information see [this page](http://theforeman.org/support.html)
|
@@ -181,6 +198,123 @@ can disable this behavior in config/kafo.yaml. Just enable the following option
|
|
181
198
|
```yaml
|
182
199
|
:no_prefix: true
|
183
200
|
```
|
201
|
+
## Scenarios
|
202
|
+
|
203
|
+
With your installer you can provide multiple configuration files aka. scenarios.
|
204
|
+
Every scenario has its own answer file to store the scenario settings.
|
205
|
+
The files are kept in `installer-scenarios.d/` directory.
|
206
|
+
|
207
|
+
### Using scenarios
|
208
|
+
|
209
|
+
To list scenarios available on your system
|
210
|
+
```bash
|
211
|
+
foreman-installer --list-scenarios
|
212
|
+
```
|
213
|
+
|
214
|
+
The installer needs to know the configuration even for such a basic operation
|
215
|
+
as printing help is because it contains basic settings and defines where
|
216
|
+
to look for module parameters. There are multiple ways how the installer can select the scenario:
|
217
|
+
* from a command line argument `-S` or `--scenario`
|
218
|
+
```bash
|
219
|
+
foreman-installer --scenario foreman -h
|
220
|
+
...
|
221
|
+
```
|
222
|
+
* by user selection in interractive mode (`-i` or `--interractive`)
|
223
|
+
```bash
|
224
|
+
foreman-installer -i
|
225
|
+
|
226
|
+
Select installation scenario
|
227
|
+
|
228
|
+
Please select one of the pre-set installation scenarios. You can customize your installtion later during the installtion.
|
229
|
+
|
230
|
+
Available actions:
|
231
|
+
1. Foreman: Basic and most generic installation of Foreman
|
232
|
+
2. Foreman Proxy: Install Foreman proxy without Foreman
|
233
|
+
3. Cancel Installation
|
234
|
+
Your choice:
|
235
|
+
```
|
236
|
+
* automatically if there is only one scenario available
|
237
|
+
* automatically if installer was ran already with scenario selected
|
238
|
+
|
239
|
+
### Re-installing with different scenario
|
240
|
+
|
241
|
+
Lets assume you have already completed installation with one scenario (e.g. smart-proxy).
|
242
|
+
Now you want to reinstall or upgrade with different scenario (e.g. foreman). This is tricky
|
243
|
+
situation and may end with unpredictable results so you should double check
|
244
|
+
if the scenario and the puppet modules used in it support such kind of change.
|
245
|
+
|
246
|
+
Installer tries to prevent unintentional change of a scenario and interrupts when such situation is detected:
|
247
|
+
```bash
|
248
|
+
foreman-installer -S foreman-installer
|
249
|
+
ERROR: You are trying to replace existing installation with different scenario. This may lead to unpredictable states. Use --force to override. You can use --compare-scenarios to see the differences
|
250
|
+
```
|
251
|
+
|
252
|
+
To avoid losing some configuration values installer can detect differences between answer files of the two scenarios.
|
253
|
+
To display them use either interactive mode (`-i`) or `--compare-scenarios` flag:
|
254
|
+
```bash
|
255
|
+
foreman-installer --compare-scenarios --scenario foreman
|
256
|
+
Scenarios are being compared, that may take a while...
|
257
|
+
|
258
|
+
Values from previous installation that will be added by installer:
|
259
|
+
foreman_proxy::http_port: 8000 -> 8080
|
260
|
+
|
261
|
+
Values from previous installation that will be lost by scenario change:
|
262
|
+
foreman_proxy::plugin::abrt::enabled: true
|
263
|
+
...
|
264
|
+
```
|
265
|
+
|
266
|
+
It may take some time as the installer has to evaluate default values for both scenarios. As a result it prints two lists.
|
267
|
+
- __Values from previous installation that will be added by installer:__ - in this list are options present in both scenarios but having different default values.
|
268
|
+
The only item from the example says that the default value for the new scenario is '8000' while the value for currently intalled scenario is '8080'.
|
269
|
+
When the new scenario is used the installer tries to keep the customized values from current installation and thus will use the `8080` value
|
270
|
+
- __Values from previous installation that will be lost by scenario change:__ - this list contains options that are part of current installation
|
271
|
+
and are missing from the new scenario. Most of the items are options from puppet modules that are disabled in the new scenario by default but were enabled
|
272
|
+
in the old one.
|
273
|
+
|
274
|
+
If you are sure you want to proceed use `--force` to run the installation. Installer will replace
|
275
|
+
the default values with values from the previous installation where possible as was indicated in the `--compare-scenario` output.
|
276
|
+
|
277
|
+
### Adding scenario
|
278
|
+
|
279
|
+
You can add new scenario using kafofy as it was explained earlier or by creating
|
280
|
+
config and answer file in the `installer-scenarios.d/` directory.
|
281
|
+
[Template](https://github.com/theforeman/kafo/blob/master/config/kafo.yaml.example)
|
282
|
+
provided by Kafo can be used and customized to satisfy your needs
|
283
|
+
```bash
|
284
|
+
cp `gem content kafo|grep "kafo.yaml.example"` <config>/installer-scenarios.d/new-scenario.yaml
|
285
|
+
touch <config>/installer-scenarios.d/new-scenario-answers.yaml
|
286
|
+
```
|
287
|
+
|
288
|
+
### Scenario as an installer plugin
|
289
|
+
|
290
|
+
Scenarios were designed to make it possible to package them separately as optional installer extension.
|
291
|
+
Config files are located in separate directory which makes packaging of additional scenarios easy.
|
292
|
+
Configuration of paths to modules, checks and hooks accepts multiple directories
|
293
|
+
so it is possible to bundle your scenario with additional modules, hooks and checks.
|
294
|
+
|
295
|
+
### Updating scenarios
|
296
|
+
|
297
|
+
As your project grows you may need to change your installer modules or add new ones. To make upgrades of existing installations easier
|
298
|
+
Kafo has support for scenario migrations. Migrations are ruby scripts similar to hooks and are located
|
299
|
+
in `<config>/installer-scenarios.d/your-scenario.migrations/` so each scenario has its own set of independent migrations.
|
300
|
+
During its initialization the installer checks for migrations that were not applied yet. It happens exactly between execution of `pre-migrations` and `boot` hooks.
|
301
|
+
The installer stores names of applied migrations in `<config>/installer-scenarios.d/your-scenario.migrations/.applied` to avoid runnig the migrations multiple times.
|
302
|
+
It is recommended to prefix the migration names with `date +%y%m%d%H%M%S` to avoid migration ordering issues.
|
303
|
+
|
304
|
+
In a migration you can modify the scenario configuration as well as the answer file. The changed configs are stored immediately after all the migrations were applied.
|
305
|
+
Note that `--noop` and `--dont-save-answers` has no effect on migrations.
|
306
|
+
|
307
|
+
Sample migration adding new module could look like as follows:
|
308
|
+
|
309
|
+
```bash
|
310
|
+
cat <<EOF > "/etc/foreman/installer-scenarios.d/foreman-installer.migrations/`date +%y%m%d%H%M%S`-gutterball.rb"
|
311
|
+
scenario[:mapping]['katello::plugin::gutterball'] = {
|
312
|
+
:dir_name => 'katello',
|
313
|
+
:manifest_name => 'plugin/gutterball'
|
314
|
+
}
|
315
|
+
answers['katello::plugin::gutterball'] = true
|
316
|
+
EOF
|
317
|
+
```
|
184
318
|
|
185
319
|
## Documentation
|
186
320
|
|
@@ -270,7 +404,7 @@ Kafo supports password arguments. It's adding some level of protection for your
|
|
270
404
|
passwords. Usually people generate random strings for passwords. However all
|
271
405
|
values are stored in config/answers.yaml which may introduce a security risk.
|
272
406
|
|
273
|
-
If this is something to consider for you, you can use the password type (see
|
407
|
+
If this is something to consider for you, you can use the password type (see
|
274
408
|
Argument types for more info how to define parameter type). It will
|
275
409
|
generate a secure (random) password with a length of 32 chars and encrypts
|
276
410
|
it using AES 256 in CBC mode. It uses a passphrase that is stored in
|
@@ -365,7 +499,7 @@ example:
|
|
365
499
|
|
366
500
|
When you enter the Testing class module in interactive mode you can see parameters
|
367
501
|
from the Basic group and options to configure parameters which belong to the rest
|
368
|
-
of groups on same level, in this case Advanced and Extra parameters.
|
502
|
+
of groups on same level, in this case Advanced and Extra parameters.
|
369
503
|
|
370
504
|
```
|
371
505
|
Module foreman configuration
|
@@ -376,11 +510,11 @@ Module foreman configuration
|
|
376
510
|
5. Back to main menu
|
377
511
|
```
|
378
512
|
|
379
|
-
When you enter Extra parameters, you see only $three and an option to get back
|
380
|
-
to the parent. In Advanced you can see $two and two more subgroups - Advanced A and
|
513
|
+
When you enter Extra parameters, you see only $three and an option to get back
|
514
|
+
to the parent. In Advanced you can see $two and two more subgroups - Advanced A and
|
381
515
|
Advanced B. When you enter these subgroups, you can again see their parameters.
|
382
|
-
Nesting is unlimited. Also there's no naming rule. Just notice that
|
383
|
-
the main group must be called `Parameters` and it's parameters are always
|
516
|
+
Nesting is unlimited. Also there's no naming rule. Just notice that
|
517
|
+
the main group must be called `Parameters` and it's parameters are always
|
384
518
|
displayed on first level of the module configuration.
|
385
519
|
|
386
520
|
```
|
@@ -390,9 +524,9 @@ Group Extra parameters (of module foreman)
|
|
390
524
|
```
|
391
525
|
|
392
526
|
If there's no primary group a new one is created for you and it does not have
|
393
|
-
any parameter. This means when a user enters the module configuration he or she will
|
394
|
-
see only subgroups in the menu (no parameters until a particular subgroup is entered).
|
395
|
-
If there is no group in the documentation a new primary group is created and it
|
527
|
+
any parameter. This means when a user enters the module configuration he or she will
|
528
|
+
see only subgroups in the menu (no parameters until a particular subgroup is entered).
|
529
|
+
If there is no group in the documentation a new primary group is created and it
|
396
530
|
holds all module parameters (there are no subgroups in the module configuration).
|
397
531
|
|
398
532
|
## Conditional parameters in interactive mode
|
@@ -518,6 +652,7 @@ You may need to add new features to the installer. Kafo provides a simple hook
|
|
518
652
|
mechanism that allows you to run custom code at 6 different occasions.
|
519
653
|
We currently support the following hooks.
|
520
654
|
|
655
|
+
* pre_migrations - just after kafo reads its configuration - useful for config file updates. Only in this stage it is posible to request config reload (`Kafo.request_config_reload`) to get in our changes
|
521
656
|
* boot - before kafo is ready to work, useful for adding new installer arguments, but logger won't work yet
|
522
657
|
* init - just after hooking is initialized and kafo is configured, parameters have no values yet
|
523
658
|
* pre_values - just before value from CLI is set to parameters (they already have default values)
|
@@ -571,7 +706,7 @@ Last but not least you have access to logger. For more details, see
|
|
571
706
|
If you don't want to modify your installer script you can place your hooks into the
|
572
707
|
hooks directory. By default the hooks dir is searched for ruby files in subdirectories
|
573
708
|
based on hook type. For example pre hooks are searched for in ```$installer_dir/hooks/pre/*.rb```
|
574
|
-
The hooks from the previous example would look like this. The only change to the code is
|
709
|
+
The hooks from the previous example would look like this. The only change to the code is
|
575
710
|
that you don't explicitely register hooks, it's done automatically for you.
|
576
711
|
|
577
712
|
```ruby
|
@@ -606,20 +741,20 @@ in the installer configuration file.
|
|
606
741
|
- /my/plugin/hooks
|
607
742
|
```
|
608
743
|
|
609
|
-
You can register as many hooks as you need. The order of execution for a particular hook type
|
744
|
+
You can register as many hooks as you need. The order of execution for a particular hook type
|
610
745
|
is based on hook file name.
|
611
746
|
|
612
747
|
If you want to cancel the installation you can use the ```exit``` method and specify an exit code.
|
613
748
|
|
614
749
|
## Colors
|
615
750
|
|
616
|
-
Everybody loves colors right? In case you don't you can disable them using the ```--no-colors```
|
751
|
+
Everybody loves colors right? In case you don't you can disable them using the ```--no-colors```
|
617
752
|
argument or disallow them in the installer config file (search for ```colors:``` key and set
|
618
753
|
it to false). If you don't touch this setting, kafo will try to detect whether colors
|
619
754
|
are supported and will enable/disable it accordingly.
|
620
755
|
|
621
756
|
Kafo supports two sets of colors, one for terminals with bright and one for dark backround.
|
622
|
-
You can specify your installer default scheme in installer config file (```color_of_background```
|
757
|
+
You can specify your installer default scheme in installer config file (```color_of_background```
|
623
758
|
key). Alternatively the user can override this default setting with the ```--color-of-background``` argument.
|
624
759
|
Possible values are ```dark``` and ```bright```.
|
625
760
|
|
@@ -646,7 +781,7 @@ end
|
|
646
781
|
As you can see you can use HighLine helpers (e.g. say) with colors. Look at kafo/color_schema.rb for
|
647
782
|
supported color identifiers. We can guarantee that there will always be at least :good, :bad, :info.
|
648
783
|
|
649
|
-
Methods like module_enabled? and get_param are just helpers defined in the same file. If you find
|
784
|
+
Methods like module_enabled? and get_param are just helpers defined in the same file. If you find
|
650
785
|
them useful, here's the definition
|
651
786
|
|
652
787
|
```ruby
|
@@ -668,13 +803,16 @@ paths. In order to do that you can use following configuration options:
|
|
668
803
|
|
669
804
|
* :answer_file: /etc/kafo/kafo.yaml
|
670
805
|
* :installer_dir: /usr/share/kafo/
|
671
|
-
* :
|
806
|
+
* :module_dirs: /usr/share/foreman-installer/modules
|
807
|
+
* :hook_dirs: /user/share/foreman-installer/hooks
|
808
|
+
* :check_dirs: /user/share/foreman-installer/checks
|
672
809
|
* :kafo_modules_dir: /usr/share/kafo/modules
|
673
810
|
|
674
|
-
Answer file is obvious. The "installer_dir" is the place where your installer is
|
675
|
-
located. E.g. system checks will be loaded from here (under checks
|
676
|
-
subdirectory)
|
677
|
-
using
|
811
|
+
Answer file is obvious. The "installer_dir" is the place where your installer is
|
812
|
+
located. E.g. system checks will be loaded from here (under checks
|
813
|
+
subdirectory) if not set elsewhere by `check_dirs`. You can optionally change foreman-installer modules dir
|
814
|
+
using `module_dirs` option and hooks dir using `hook_dirs` option. `module_dirs`, `hook_dirs` and `check_dirs`
|
815
|
+
can hold multiple directories where to look for the resources.
|
678
816
|
|
679
817
|
On debian systems you may want to specify kafo modules dir
|
680
818
|
independent on your installer location. If you specify this option kafo's
|
@@ -737,7 +875,7 @@ but you want the logs to be readable by specific users.
|
|
737
875
|
When you want to make sure that a user has a certain software installed or has the
|
738
876
|
right version you can write a simple script and put it into the checks directory.
|
739
877
|
All files found there will be executed and if any of these exits with an non-zero
|
740
|
-
exit code, kafo won't execute puppet but only print an error message
|
878
|
+
exit code, kafo won't execute puppet but only print an error message
|
741
879
|
`Your system does not meet configuration criteria.`
|
742
880
|
|
743
881
|
Everything on STDOUT and STDERR is logged in error level.
|
@@ -773,6 +911,8 @@ Other exit codes that can be returned:
|
|
773
911
|
* '23' means that you have no answer file
|
774
912
|
* '24' means that your answer file asks for puppet module that you did not provide
|
775
913
|
* '25' means that kafo could not get default values from puppet
|
914
|
+
* '26' means that kafo could not find the specified scenario
|
915
|
+
* '27' means that kafo found previous installation that has different scenario than is the specified scenario
|
776
916
|
* '130' user interrupt (^C)
|
777
917
|
|
778
918
|
## Running Puppet Profiling
|
data/bin/kafo-export-params
CHANGED
@@ -33,7 +33,7 @@ module Kafo
|
|
33
33
|
c = Configuration.new(config, false)
|
34
34
|
KafoConfigure.config = c
|
35
35
|
KafoConfigure.root_dir = File.expand_path(c.app[:installer_dir])
|
36
|
-
KafoConfigure.
|
36
|
+
KafoConfigure.module_dirs = File.expand_path(c.app[:module_dirs])
|
37
37
|
KafoConfigure.logger = Logger.new(STDOUT)
|
38
38
|
|
39
39
|
exporter = self.class.const_get(format.capitalize).new(c)
|
data/bin/kafofy
CHANGED
@@ -12,25 +12,30 @@ require 'kafo/configuration'
|
|
12
12
|
options = {}
|
13
13
|
OptionParser.new do |opts|
|
14
14
|
opts.banner = "Usage: kafofy"
|
15
|
-
options[:
|
16
|
-
opts.on("-
|
17
|
-
options[:
|
15
|
+
options[:config_dir] = './config/installer-scenarios.d/'
|
16
|
+
opts.on("-c", "--config_dir DIR", "location of the scenarios configuration directory [./config/installer-scenarios.d/]") do |config_dir|
|
17
|
+
options[:config_dir] = config_dir
|
18
18
|
end
|
19
|
-
opts.on("-
|
20
|
-
options[:
|
19
|
+
opts.on("-s", "--scenario SCENARIO", "scenario file name (without extension) [default]") do |scenario|
|
20
|
+
options[:scenario] = scenario
|
21
21
|
end
|
22
|
-
opts.on("-
|
22
|
+
opts.on("-a", "--answer_file ANSWERS", "answer file file name (without extension) [default-answers]") do |answer_file|
|
23
|
+
options[:answer_file] = File.join(options[:config_dir], answer_file + '.yaml')
|
24
|
+
end
|
25
|
+
opts.on("-n", "--name NAME", "installer name [kafo-configure]") do |name|
|
23
26
|
options[:name] = name
|
24
27
|
end
|
25
28
|
end.parse!
|
26
29
|
|
27
30
|
config = Kafo::Configuration::DEFAULT
|
28
|
-
options[:
|
31
|
+
options[:scenario] ||= 'default'
|
32
|
+
options[:answer_file] ||= File.join(options[:config_dir], options[:scenario] + '-answers.yaml')
|
29
33
|
options[:name] ||= "kafo-configure"
|
30
|
-
options[:config_file] ||=
|
34
|
+
options[:config_file] ||= File.join(options[:config_dir], options[:scenario] + '.yaml')
|
31
35
|
|
32
36
|
# Create directory structure
|
33
|
-
%w(bin config modules hooks)
|
37
|
+
dirs = %w(bin config modules hooks) << options[:config_dir]
|
38
|
+
dirs.each do |dir|
|
34
39
|
FileUtils.mkdir_p dir
|
35
40
|
end
|
36
41
|
|
@@ -41,7 +46,7 @@ src = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
41
46
|
end
|
42
47
|
|
43
48
|
# Create default config file
|
44
|
-
puts "
|
49
|
+
puts "creating #{options[:config_file]} as a default scenario file"
|
45
50
|
if !File.exists?(options[:config_file])
|
46
51
|
puts "... creating config file #{options[:config_file]}"
|
47
52
|
FileUtils.touch options[:config_file]
|
@@ -49,23 +54,35 @@ if !File.exists?(options[:config_file])
|
|
49
54
|
FileUtils.cp('config/kafo.yaml.example', options[:config_file])
|
50
55
|
if options[:answer_file]
|
51
56
|
`sed -i 's/^# :answer_file.*$/:answer_file: #{options[:answer_file].gsub('/', '\/')}/' #{options[:config_file]}`
|
52
|
-
`sed -i 's/^# :name.*$/:name: #{options[:
|
57
|
+
`sed -i 's/^# :name.*$/:name: #{options[:scenario]}/' #{options[:config_file]}`
|
53
58
|
end
|
54
59
|
end
|
55
60
|
|
56
|
-
# Installer script
|
61
|
+
# Installer script
|
57
62
|
script_name = "bin/#{options[:name]}"
|
58
63
|
puts "... creating #{script_name}"
|
59
|
-
|
64
|
+
if !File.exists?(script_name)
|
65
|
+
content = <<EOS
|
60
66
|
#!/usr/bin/env ruby
|
61
67
|
require 'rubygems'
|
62
|
-
CONFIG_FILE = '#{options[:config_file]}'
|
63
68
|
require 'kafo'
|
64
|
-
|
65
|
-
|
69
|
+
|
70
|
+
# where to find scenarios
|
71
|
+
CONFIG_DIR = '#{options[:config_dir]}'
|
72
|
+
|
73
|
+
# Run the install
|
74
|
+
@result = Kafo::KafoConfigure.run
|
75
|
+
|
76
|
+
# handle exit code when help was invoked or installer ended with '2' (success in puppet)
|
77
|
+
if @result.nil? || (!@result.config.app[:detailed_exitcodes] && @result.exit_code == 2)
|
78
|
+
exit(0)
|
79
|
+
else
|
80
|
+
exit(@result.exit_code)
|
81
|
+
end
|
66
82
|
EOS
|
67
|
-
File.open(script_name, 'w') { |file| file.write(content) }
|
68
|
-
FileUtils.chmod 0755, script_name
|
83
|
+
File.open(script_name, 'w') { |file| file.write(content) }
|
84
|
+
FileUtils.chmod 0755, script_name
|
85
|
+
end
|
69
86
|
|
70
87
|
puts "Your directory was kafofied"
|
71
88
|
|
@@ -73,3 +90,4 @@ puts "Now you should:"
|
|
73
90
|
puts " 1. upload your puppet modules to modules directory (you can use librarian-puppet project)"
|
74
91
|
puts " 2. create default #{options[:answer_file]} or modify #{options[:config_file]} to load another answer file"
|
75
92
|
puts " 3. run #{script_name} to install your modules"
|
93
|
+
puts " Note: You can add more scenarios by running kafofy multiple times"
|