rconf 0.5.9 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,39 +10,38 @@ for each application is becoming increasingly complex and switching from one
10
10
  application to another for development in particular is quickly becoming
11
11
  close to impossible.
12
12
 
13
- RightEnv aims at addressing some of these difficulties by providing a uniform
13
+ rconf aims at addressing some of these difficulties by providing a uniform
14
14
  and consistent mechanism for applications developed at RightScale to
15
- declaratively specify the tools they depend on in various systems (development,
16
- test, staging, production) and platforms (linux, darwin and windows). RightEnv
17
- uses a DSL close to Chef recipes for defining an application configuration.
15
+ declaratively specify the tools they depend on various platforms (linux, darwin
16
+ and potentially windows).
17
+
18
+ rconf uses a DSL close to Chef recipes for defining an application configuration.
18
19
  Each application must be equipped with a definition that must reside at the top
19
- level directory of the application and must be named "<application>.re" (where
20
- "<application>" should be subsituted with the name of the application.
21
- Configuring the system to run the application then merely consists of running
22
- the "script/bootstrap_environment" script provided in the "script" directory
23
- ("script/bootstrap_environment.bat" on windows).
20
+ level directory of the application and use the '.rc' file extension. When run
21
+ for the first time rconf sets up a .rvmrc file which gets invoked and sets up
22
+ the environment each time the application directory gets 'cd-ed' into.
24
23
 
25
- Internally RightEnv relies on 'configurators' to configure the machine
24
+ Internally rconf relies on 'configurators' to configure the machine
26
25
  appropriately. There is one configurator per tool that needs configuration.
27
- Each configurator is dynamically instantiated by RightEnv as it reads the
26
+ Each configurator is dynamically instantiated by rconf as it reads the
28
27
  application configuration file. This makes for an extensible system where new
29
28
  configurator may be added to configure new tools that new applications may
30
- rely on. For a list of available configurators run "script/configurator --list".
29
+ rely on.
31
30
 
32
31
  == REQUIREMENTS
33
32
 
34
33
  === Running
35
34
 
36
- - Linux and MAc OS X
35
+ ==== Linux and Mac OS X
37
36
 
38
- - ruby >= 1.8.6
39
- - curl
40
- - tar
37
+ - ruby >= 1.8.6
38
+ - curl
39
+ - tar
41
40
 
42
- - Windows
41
+ ==== Windows
43
42
 
44
- - ruby >= 1.8.6
45
- - Win32API gem
43
+ - ruby >= 1.8.6
44
+ - Win32API gem
46
45
 
47
46
  === Unit testing
48
47
 
@@ -54,3 +53,50 @@ Then the build can be tested with
54
53
 
55
54
  rake spec
56
55
 
56
+ == WRITING RCONF CONFIGURATION FILES
57
+
58
+ rconf uses a ruby DSL for configuration files (.rc). Each configurator is
59
+ associated with a keyword. The configuration for a given configurator then
60
+ lists each configurator setting it needs to set and the associated value as in:
61
+
62
+ ruby do
63
+ version 'ruby-1.9.2-p136'
64
+ end
65
+
66
+ The configuration file consists of a sequence of these configurator sections
67
+ executed in order. For a complete list of available configurators run:
68
+
69
+ rconf --configurators
70
+
71
+ The same configurator can appear multiple times in a configuration file.
72
+
73
+ == EXTENDING RCONF WITH NEW CONFIGURATORS
74
+
75
+ Writing a configurator consists of writing a ruby class which includes the
76
+ +RightConf::Configurator+ module and uses the class methods define there to
77
+ register, provide a description and list its settings.
78
+
79
+ The exact methods are:
80
+
81
+ - +register+: Takes one argument which is the keyword associated with the configurator in configuration files.
82
+ - +description+: Associates the description with the configurator used in the help.
83
+ - +settings+: The value should be a hash where the keys are the settings names (ruby symbols) and the value is the setting description.
84
+ - +validate_has_settings+: An array of settings names (symbols) for all settings that must be set for a configuration to be valid when using that configurator.
85
+
86
+ The configurator class then needs to implement the +run+ method which gets
87
+ called whenever rconf executes a configuration section using the configurator.
88
+
89
+ Alternatively the configurator class may implement +run_<platform>+ where
90
+ +<platform>+ can take the values 'darwin', 'linux' or 'windows' if the
91
+ implementation needs to be platform specific.
92
+
93
+ The configurator can also provide distribution specific implementations by
94
+ implementing +run_<platform>_<flavor>+ where +<flavor>+ depends on the
95
+ platform and can take the values 'ubuntu', 'centos' etc. (linux).
96
+
97
+ Finally the +run+ method can also be implemented using the full specification
98
+ for a platform including the release number (e.g. +run_linux_ubuntu_10_10+). In
99
+ each case rconf will use the most specific implementation (so if both
100
+ +run_linux+ and +run_linux_ubuntu+ are provided and the configurator is
101
+ running on Ubuntu then rconf will call the +run_linux_ubuntu+ implementation).
102
+
data/bin/rconf CHANGED
@@ -37,7 +37,7 @@ where [options] are:
37
37
  opt :output, 'Output file (output to STDOUT by default)', :type => :string
38
38
  opt :verbose, 'Print debug output'
39
39
  end
40
- if opts[:config].nil?
40
+ if opts[:config].nil? && !opts[:configurators]
41
41
  opts[:config] = Dir['./*.rc']
42
42
  if opts[:config].empty?
43
43
  Trollop::die :config, "not used and could not find a '.rc' file in the working directory"
@@ -74,7 +74,8 @@ where [options] are:
74
74
  configurator.all_settings.each do |name, desc|
75
75
  num_spaces = max_size - name.to_s.size + 1
76
76
  print " - #{name.to_s.blue}:#{' ' * num_spaces}#{desc}"
77
- if configurator.required_settings.include?(name)
77
+ required_settings = configurator.required_settings || []
78
+ if required_settings.include?(name)
78
79
  puts ' [required]'.green
79
80
  else
80
81
  puts
@@ -22,7 +22,8 @@ module RightConf
22
22
  settings :debian => 'Packages to be installed on Debian based Linux',
23
23
  :centos => 'Packages to be installed on RedHat / Centos',
24
24
  :windows => 'Softwared to be downloaded and installed on Windows',
25
- :mac => 'Brew packages to be installed on Mac OS X (https://github.com/mxcl/homebrew)'
25
+ :mac => 'Brew packages to be installed on Mac OS X (https://github.com/mxcl/homebrew)',
26
+ :abort_on_failure => 'Whether to abort if packages failed to install (false by default)'
26
27
 
27
28
  # Install debian packages
28
29
  #
@@ -31,7 +32,8 @@ module RightConf
31
32
  def run_linux_ubuntu
32
33
  return if debian.nil?
33
34
  report_check("Installing the following packages:\n#{debian.join(' ')}\nThis could take a while")
34
- opts = debian << { :abort_on_failure => 'Failed to install packages' }
35
+ opts = debian.dup
36
+ opts << { :abort_on_failure => 'Failed to install packages' } if abort_on_failure
35
37
  Command.execute('sudo', 'aptitude', 'install', *opts)
36
38
  report_success
37
39
  end
@@ -44,7 +46,8 @@ module RightConf
44
46
  def run_linux_centos
45
47
  return if centos.nil?
46
48
  report_check("Installing the following packages:\n#{centos.join(' ')}\nThis could take a while")
47
- opts = centos << { :abort_on_failure => 'Failed to install packages' }
49
+ opts = centos.dup
50
+ opts << { :abort_on_failure => 'Failed to install packages' } if abort_on_failure
48
51
  Command.execute('sudo', 'yum', 'install', '-y', *opts)
49
52
  report_success
50
53
  end
data/lib/rconf/version.rb CHANGED
@@ -12,8 +12,8 @@
12
12
  module RightConf
13
13
 
14
14
  MAJOR = 0
15
- MINOR = 5
16
- BUILD = 9
15
+ MINOR = 6
16
+ BUILD = 1
17
17
 
18
18
  VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
19
19
 
@@ -39,7 +39,7 @@ describe RightConf::BundlerConfigurator do
39
39
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
40
40
  'bundle', 'install', {:abort_on_failure=>"Failed to install gems"}).and_return(success_result)
41
41
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
42
- 'gem', 'uninstall', 'bundler', '-a', '-x', {:abort_on_failure=>"Failed to uninstall bundler"}).and_return(success_result)
42
+ 'gem', 'uninstall', 'bundler', '-a', '-x').and_return(success_result)
43
43
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
44
44
  'gem', 'install',
45
45
  File.join(RightConf::BundlerConfigurator::DEFAULT_GEM_PATH, 'bundler-0.gem'),
@@ -27,15 +27,13 @@ describe RightConf::PackagesConfigurator do
27
27
 
28
28
  it 'should install packages on Ubuntu' do
29
29
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
30
- 'sudo', 'aptitude', 'install', 'deb1', 'deb2',
31
- {:abort_on_failure=>"Failed to install packages"}).and_return(success_result)
30
+ 'sudo', 'aptitude', 'install', 'deb1', 'deb2').and_return(success_result)
32
31
  @configurator.run_linux_ubuntu
33
32
  end
34
33
 
35
34
  it 'should install packages on Centos' do
36
35
  flexmock(RightConf::Command.instance).should_receive(:execute).once.with(
37
- 'sudo', 'yum', 'install', '-y', 'cent1', 'cent2',
38
- {:abort_on_failure=>"Failed to install packages"}).and_return(success_result)
36
+ 'sudo', 'yum', 'install', '-y', 'cent1', 'cent2').and_return(success_result)
39
37
  @configurator.run_linux_centos
40
38
  end
41
39
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rconf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.9
5
+ version: 0.6.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Raphael Simon
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-07 00:00:00 -08:00
13
+ date: 2011-03-08 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency