kafo 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kafo might be problematic. Click here for more details.

data/README.md CHANGED
@@ -58,7 +58,7 @@ mkdir foreman-installer
58
58
  cd foreman-installer
59
59
  ```
60
60
 
61
- Now we run +kafofy+ script which will prepare directory structure and
61
+ Now we run ```kafofy``` script which will prepare directory structure and
62
62
  optionally create a bin script according to first parameter.
63
63
 
64
64
  ```bash
@@ -69,7 +69,7 @@ You can see that it created modules directory where your puppet modules
69
69
  should live. It also created config and bin directories. If you specified
70
70
  argument (foreman-installer in this case) a script in bin was created.
71
71
  It's the script you can use to run installer. If you did not specify any
72
- you can run your installer by +kafo-configure+ which is provided by the gem.
72
+ you can run your installer by ```kafo-configure``` which is provided by the gem.
73
73
  All configuration related files are to be found in config directory.
74
74
 
75
75
  So for example to install foreman you want to
@@ -122,12 +122,13 @@ the lower the item is the higher precedence it has:
122
122
 
123
123
  ## Testing aka noop etc
124
124
 
125
- You'll probably want to tweak your installer before so you may find --noop
126
- argument handy. This will run puppet in noop so no change will be done to your
127
- system. Default value is false!
125
+ You'll probably want to tweak your installer before so you may find
126
+ ```--noop``` argument handy (-n for short). This will run puppet in
127
+ noop so no change will be done to your system. Default value is
128
+ false!
128
129
 
129
130
  Sometimes you may want kafo not to store answers from current run. You can
130
- disable saving by passing a --dont-save-answers argument (or -d for short).
131
+ disable saving by passing a ```--dont-save-answers``` argument (or -d for short).
131
132
 
132
133
  ## Parameters prefixes
133
134
 
@@ -178,11 +179,52 @@ in puppet manifest documentation like this
178
179
  type:boolean
179
180
  ```
180
181
 
181
- Supported types are: string, boolean, integer, array
182
+ Supported types are: string, boolean, integer, array, password
182
183
 
183
184
  Note that all arguments that are nil (have no value in answers.yaml or you
184
185
  set them UNDEF (see below) are translated to ```undef``` in puppet.
185
186
 
187
+ ## Password arguments
188
+
189
+ Kafo support password arguments. It's adding some level of protection for you
190
+ passwords. Usually people generate random strings for passwords. However all
191
+ values are stored in config/answers.yaml which introduce some security risk.
192
+
193
+ If this is something to concern for you, you can use password type. It will
194
+ generate a secure (random) password of decent length (32 chars) and encrypts
195
+ it using AES 256 in CBC mode. It uses a passphrase that is stored in
196
+ config/kafo.yaml so if anyone gets an access to this file, he can read all
197
+ other passwords from answers.yaml. A random password is generated and stored
198
+ if there is none in kafo.yaml yet.
199
+
200
+ When Kafo runs puppet, puppet will read this password from config/kafo.yaml.
201
+ It runs under the same user so it should have read access by default. Kafo
202
+ puppet module also provides a function that you can use to decrypt such
203
+ parameters. You can use it like this
204
+
205
+ ```erb
206
+ password: <%= scope.function_decrypt([scope.lookupvar("::foreman::db_password"))]) -%>
207
+ ```
208
+
209
+ Also you can take advantage of already encrypted password and store as it is
210
+ (encrypted). Your application can decrypt it as long as it knows the
211
+ passphrase. Passphrase can be obtained as $kafo_configure::password.
212
+
213
+ Note that we use a bit extraordinary form of encrypted passwords. All our
214
+ encrypted passwords looks like "$1$base64encodeddata". As you can see we
215
+ use $1$ prefix by which we can detect that its encrypted password by us.
216
+ The form has nothing common with Modular Crypt Format. Also our AES output
217
+ is base64 encoded. To get a password from this format you can do something
218
+ like this in your application
219
+
220
+ ```ruby
221
+ require 'base64'
222
+ encrypted = "$1$base64encodeddata"
223
+ encrypted = encrypted[3..-1] # strip $1$ prefix
224
+ encrypted = Base64.decode64(encrypted) # decode base64 string
225
+ result = aes_decrypt(encrypted) # for example how to implement aes_decrypt see lib/kafo/password_manager.rb
226
+ ```
227
+
186
228
  ## Array arguments
187
229
 
188
230
  Some arguments may be Arrays. If you want to specify array values you can
@@ -200,9 +242,9 @@ By default Kafo expects a common module structure. For example if you add
200
242
  ```yaml
201
243
  foreman: true
202
244
  ```
203
- to you answer file, Kafo expects a +foreman+ subdirectory in +modules/+. Also
245
+ to you answer file, Kafo expects a ```foreman``` subdirectory in ```modules/```. Also
204
246
  it expects that there will be init.pp which it will instantiate. If you need
205
- to change this behavior you can via +mapping+ option in +config/kafo.yaml+.
247
+ to change this behavior you can via ```mapping``` option in ```config/kafo.yaml```.
206
248
 
207
249
  Suppose we have puppet module and we want to use puppet/server.pp as our init
208
250
  file. Also we want to name our module as puppetmaster. We add following mapping
data/bin/kafofy CHANGED
@@ -21,10 +21,11 @@ if ARGV.size > 0
21
21
  puts "... creating #{script_name}"
22
22
  content = <<EOS
23
23
  #!/usr/bin/env ruby
24
+ require 'rubygems'
24
25
  require 'kafo'
25
26
  KafoConfigure.run
26
27
  EOS
27
- File.write script_name, content
28
+ File.open(script_name, 'w') { |file| file.write(content) }
28
29
  FileUtils.chmod 0755, script_name
29
30
  end
30
31
 
@@ -10,7 +10,7 @@ class Configuration
10
10
  end
11
11
 
12
12
  def self.save_configuration(configuration)
13
- File.write(application_config_file, YAML.dump(configuration))
13
+ File.open(application_config_file, 'w') { |file| file.write(YAML.dump(configuration)) }
14
14
  end
15
15
 
16
16
  def self.configure_application
@@ -91,7 +91,7 @@ class Configuration
91
91
  end
92
92
 
93
93
  def store(data)
94
- File.write(config_file, config_header + YAML.dump(data))
94
+ File.open(config_file, 'w') { |file| file.write(config_header + YAML.dump(data)) }
95
95
  end
96
96
 
97
97
  private
@@ -42,7 +42,7 @@ class ParamBuilder
42
42
 
43
43
  def get_type(docs)
44
44
  type = (get_attributes(docs)[:type] || '').capitalize
45
- type.empty? || !Params.const_defined?(type) ? Params::String : Params.const_get(type, false)
45
+ type.empty? || !Params.const_defined?(type) ? Params::String : Params.const_get(type)
46
46
  end
47
47
 
48
48
  def get_attributes(docs)
data/lib/kafo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kafo
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -3,7 +3,7 @@
3
3
  module Puppet::Parser::Functions
4
4
  newfunction(:dump_values) do |args|
5
5
  data = Hash[args.map { |arg| [arg, lookupvar(arg)] }]
6
- File.write('config/default_values.yaml', YAML.dump(data))
6
+ File.open('config/default_values.yaml', 'w') { |file| file.write(YAML.dump(data)) }
7
7
  end
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kafo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-27 00:00:00.000000000 Z
12
+ date: 2013-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -132,45 +132,42 @@ executables:
132
132
  extensions: []
133
133
  extra_rdoc_files: []
134
134
  files:
135
- - .gitignore
136
- - Gemfile
137
- - LICENSE.txt
138
- - README.md
139
- - Rakefile
140
135
  - bin/kafo-configure
141
136
  - bin/kafofy
142
- - config/config_header.txt
143
137
  - config/kafo.yaml.example
144
- - kafo.gemspec
145
- - lib/kafo.rb
138
+ - config/config_header.txt
139
+ - lib/kafo/puppet_module.rb
140
+ - lib/kafo/puppet_module_parser.rb
141
+ - lib/kafo/password_manager.rb
146
142
  - lib/kafo/configuration.rb
143
+ - lib/kafo/validator.rb
147
144
  - lib/kafo/exceptions.rb
148
- - lib/kafo/kafo_configure.rb
149
- - lib/kafo/logger.rb
150
- - lib/kafo/param.rb
151
- - lib/kafo/param_builder.rb
152
- - lib/kafo/params/array.rb
153
- - lib/kafo/params/boolean.rb
154
- - lib/kafo/params/integer.rb
145
+ - lib/kafo/system_checker.rb
146
+ - lib/kafo/wizard.rb
155
147
  - lib/kafo/params/password.rb
156
148
  - lib/kafo/params/string.rb
157
- - lib/kafo/password_manager.rb
158
- - lib/kafo/puppet_module.rb
159
- - lib/kafo/puppet_module_parser.rb
149
+ - lib/kafo/params/boolean.rb
150
+ - lib/kafo/params/array.rb
151
+ - lib/kafo/params/integer.rb
152
+ - lib/kafo/kafo_configure.rb
160
153
  - lib/kafo/string_helper.rb
161
- - lib/kafo/system_checker.rb
162
- - lib/kafo/validator.rb
154
+ - lib/kafo/logger.rb
155
+ - lib/kafo/param.rb
163
156
  - lib/kafo/version.rb
164
- - lib/kafo/wizard.rb
165
- - modules/kafo_configure/lib/puppet/parser/functions/class_name.rb
157
+ - lib/kafo/param_builder.rb
158
+ - lib/kafo.rb
166
159
  - modules/kafo_configure/lib/puppet/parser/functions/decrypt.rb
167
- - modules/kafo_configure/lib/puppet/parser/functions/dump_values.rb
168
- - modules/kafo_configure/lib/puppet/parser/functions/hash_keys.rb
169
160
  - modules/kafo_configure/lib/puppet/parser/functions/is_hash.rb
161
+ - modules/kafo_configure/lib/puppet/parser/functions/class_name.rb
162
+ - modules/kafo_configure/lib/puppet/parser/functions/dump_values.rb
170
163
  - modules/kafo_configure/lib/puppet/parser/functions/load_kafo_password.rb
164
+ - modules/kafo_configure/lib/puppet/parser/functions/hash_keys.rb
171
165
  - modules/kafo_configure/lib/puppet/parser/functions/loadanyyaml.rb
172
- - modules/kafo_configure/manifests/init.pp
173
166
  - modules/kafo_configure/manifests/yaml_to_class.pp
167
+ - modules/kafo_configure/manifests/init.pp
168
+ - LICENSE.txt
169
+ - Rakefile
170
+ - README.md
174
171
  homepage: https://github.com/theforeman/kafo
175
172
  licenses:
176
173
  - GPLv3+
data/.gitignore DELETED
@@ -1,18 +0,0 @@
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
18
- .idea
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in kafo.gemspec
4
- gemspec
data/kafo.gemspec DELETED
@@ -1,36 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- $LOAD_PATH.unshift(lib + '/kafo')
5
- $LOAD_PATH.unshift(lib + '/kafo/params')
6
- require 'kafo/version'
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = "kafo"
10
- spec.version = Kafo::VERSION
11
- spec.authors = ["Marek Hulan"]
12
- spec.email = ["ares@igloonet.cz"]
13
- spec.description = %q{A gem for making installations based on puppet user friendly}
14
- spec.summary = %q{If you write puppet modules for installing your software, you can use kafo to create powerful installer}
15
- spec.homepage = "https://github.com/theforeman/kafo"
16
- spec.license = "GPLv3+"
17
-
18
- spec.files = `git ls-files`.split($/)
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
- spec.require_paths = ["lib"]
22
-
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
-
26
- # puppet manifests parsing
27
- spec.add_dependency 'puppet'
28
- spec.add_dependency 'rdoc', '~> 3.0'
29
- # better logging
30
- spec.add_dependency 'logging'
31
- # CLI interface
32
- spec.add_dependency 'clamp'
33
- # interactive mode
34
- spec.add_dependency 'highline'
35
-
36
- end