puppi 0.0.1alpha → 0.0.2

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/.travis.yml CHANGED
@@ -5,7 +5,5 @@ rvm:
5
5
  - 1.9.3
6
6
  - jruby-18mode # JRuby in 1.8 mode
7
7
  - jruby-19mode # JRuby in 1.9 mode
8
- - rbx-18mode
9
- - rbx-19mode
10
8
  # uncomment this line if your project needs to run something other than `rake`:
11
9
  script: RUN_ENV=TEST bundle exec rspec spec
data/Gemfile CHANGED
@@ -3,6 +3,10 @@ source "http://rubygems.org"
3
3
  gem 'mail'
4
4
  gem 'rake'
5
5
 
6
+ group :development do
7
+ gem 'pry'
8
+ end
9
+
6
10
  group :test do
7
11
  gem 'autotest'
8
12
  gem 'rspec'
data/lib/puppi.rb CHANGED
@@ -11,11 +11,14 @@ module Puppi
11
11
  require 'puppi/notifications/stdout'
12
12
  require 'puppi/version'
13
13
  require 'yaml'
14
+ require 'pry'
14
15
 
15
16
  if ENV["RUN_ENV"] == "TEST"
16
17
  @@puppidir = File.dirname(File.dirname(__FILE__))+"/tmp/config"
18
+ @@stdout_print = false
17
19
  else
18
20
  @@puppidir = "/etc/puppi"
21
+ @@stdout_print = true
19
22
  end
20
23
 
21
24
  class << self
@@ -23,6 +26,10 @@ module Puppi
23
26
  @@puppidir
24
27
  end
25
28
 
29
+ def stdout_print
30
+ @@stdout_print
31
+ end
32
+
26
33
  def initial_checks
27
34
  directories = %w[ data helpers notifications ]
28
35
  directories.each do |directory|
data/lib/puppi/action.rb CHANGED
@@ -35,16 +35,21 @@ module Puppi
35
35
  private
36
36
  def run_command command, module_helper
37
37
  @running_command = prepare_command command.command
38
- output = IO.popen(@running_command, :err => [:child, :out]) unless @running_command.nil?
38
+ output = IO.popen(@running_command) unless @running_command.nil?
39
39
  output.nil? ? nil : output.read
40
40
  end
41
41
 
42
42
  def prepare_command command
43
43
  begin
44
- command % @loaded_datafile.variables
45
- rescue KeyError
46
- nil
47
- end
44
+ @loaded_datafile.variables.each do |index, value|
45
+ command.gsub!("%{"+index.to_s+"}", value.to_s)
46
+ end
47
+ raise StandardError unless command.match(/%\{[a-z]*\}/).nil?
48
+ command
49
+ rescue
50
+ puts "Malformed Datafile"
51
+ exit 1
52
+ end
48
53
  end
49
54
  end
50
55
  end
@@ -23,7 +23,8 @@ module Puppi
23
23
  name: openssh
24
24
  version: 1.0'
25
25
  write_file '/data/standard_hostname.yml', '---
26
- name: hostname'
26
+ name: hostname
27
+ version: 0.1'
27
28
  end
28
29
 
29
30
  def notifications
@@ -33,8 +33,11 @@ module Puppi
33
33
 
34
34
  private
35
35
  def valid_method? (method)
36
- @valid_methods = Puppi::Notifications.constants.select {|c| Class === Puppi::Notifications.const_get(c)}
37
- @valid_methods.include? method.capitalize.to_sym
36
+ @valid_methods = Array.new
37
+ Puppi::Notifications.constants.each do |valid_method|
38
+ @valid_methods << valid_method.to_s
39
+ end
40
+ @valid_methods.include? method.capitalize
38
41
  end
39
42
  end
40
43
  end
@@ -12,7 +12,7 @@ module Puppi
12
12
  mails = load_all
13
13
  mails.each do |mail|
14
14
  mailer = @loader.load_notification(mail)
15
- send_mail (mailer) if valid_mailer? (mailer)
15
+ send_mail (mailer) if valid_mailer?(mailer)
16
16
  end
17
17
  end
18
18
 
@@ -5,7 +5,7 @@ module Puppi
5
5
  end
6
6
 
7
7
  def output(output)
8
- puts output
8
+ puts output if Puppi::stdout_print
9
9
  end
10
10
  end
11
11
  end
data/lib/puppi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Puppi
2
- VERSION = "0.0.1alpha"
2
+ VERSION = "0.0.2"
3
3
  end
data/puppi.gemspec CHANGED
@@ -27,4 +27,9 @@ EOF
27
27
  # specify any dependencies here; for example:
28
28
  # s.add_development_dependency "rspec"
29
29
  # s.add_runtime_dependency "rest-client"
30
+ s.add_development_dependency "autotest"
31
+ s.add_development_dependency "rspec"
32
+ s.add_development_dependency "fakefs"
33
+ s.add_development_dependency "simplecov"
34
+ s.add_runtime_dependency "mail"
30
35
  end
@@ -44,13 +44,13 @@ describe "Puppi::Action" do
44
44
  output.should include("+ openssh +\n")
45
45
  end
46
46
 
47
+ subject { Puppi::Action.new({:action => 'check', :puppi_module => nil}).output }
47
48
  it "should return all command output when running check command" do
48
- output = Puppi::Action.new({:action => 'check', :puppi_module => nil}).output
49
- output.should be_an(Array)
50
- output.should have(4).items
51
- output.should include("| hostname |\n")
52
- output.should include(nil)
53
- output.should include("| openssh |\n")
54
- output.should include("| 1.0 |\n")
49
+ should be_an(Array)
50
+ should have(4).items
51
+ should include("| hostname |\n")
52
+ should include("| 0.1 |\n")
53
+ should include("| openssh |\n")
54
+ should include("| 1.0 |\n")
55
55
  end
56
56
  end
@@ -37,7 +37,8 @@ version: 1.0'
37
37
  it "should the standard datafile for hostname module" do
38
38
  standard_helper = File.open(Puppi::puppidir+'/data/standard_hostname.yml', 'rb') { |file| file.read }
39
39
  standard_helper.should eql '---
40
- name: hostname'
40
+ name: hostname
41
+ version: 0.1'
41
42
  end
42
43
 
43
44
  it "should generate the standard notification to user1@mail.com for mail method" do
@@ -48,7 +48,7 @@ describe "Puppi::Loader" do
48
48
  it "should load all hostname standard data file" do
49
49
  @p = @loader.load_datafile('standard_hostname')
50
50
  @p.should be_a(Puppi::Files::Datafile)
51
- @p.variables.should have(1).items
51
+ @p.variables.should have(2).items
52
52
  end
53
53
 
54
54
  it "should raise an exception for a invalid data file" do
metadata CHANGED
@@ -1,28 +1,105 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: puppi
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1alpha
5
- prerelease: 5
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Celso Fernandes
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-08-06 00:00:00.000000000 Z
13
- dependencies: []
14
- description: ! "Puppi is a Puppet module that lets sysadmins standardize, manage and
15
- automate the deployment of web applications \nand provides quick and standard commands
16
- to obtain informations about the system and what’s is going on it.\n\nIts structure
17
- provides FULL flexibility on the actions required for virtually any kind of application
18
- deployment \nand information gathering.\n"
19
- email:
17
+
18
+ date: 2012-08-19 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ prerelease: false
31
+ type: :development
32
+ name: autotest
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ hash: 3
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ prerelease: false
45
+ type: :development
46
+ name: rspec
47
+ requirement: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ prerelease: false
59
+ type: :development
60
+ name: fakefs
61
+ requirement: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ version_requirements: &id004 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ prerelease: false
73
+ type: :development
74
+ name: simplecov
75
+ requirement: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ version_requirements: &id005 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ prerelease: false
87
+ type: :runtime
88
+ name: mail
89
+ requirement: *id005
90
+ description: "Puppi is a Puppet module that lets sysadmins standardize, manage and automate the deployment of web applications \n\
91
+ and provides quick and standard commands to obtain informations about the system and what\xE2\x80\x99s is going on it.\n\n\
92
+ Its structure provides FULL flexibility on the actions required for virtually any kind of application deployment \n\
93
+ and information gathering.\n"
94
+ email:
20
95
  - fernandes@zertico.com
21
- executables:
96
+ executables:
22
97
  - puppi
23
98
  extensions: []
99
+
24
100
  extra_rdoc_files: []
25
- files:
101
+
102
+ files:
26
103
  - .autotest
27
104
  - .gitignore
28
105
  - .rvmrc
@@ -32,9 +109,6 @@ files:
32
109
  - Rakefile
33
110
  - autotest/discover.rb
34
111
  - bin/puppi
35
- - etc/data/standard_openssh.yaml
36
- - etc/helpers/standard.yaml
37
- - etc/t.rb
38
112
  - lib/puppi.rb
39
113
  - lib/puppi/action.rb
40
114
  - lib/puppi/files/datafile.rb
@@ -61,32 +135,38 @@ files:
61
135
  - spec/support/publicize_methods.rb
62
136
  homepage: http://fernandes.github.com/puppi
63
137
  licenses: []
138
+
64
139
  post_install_message:
65
140
  rdoc_options: []
66
- require_paths:
141
+
142
+ require_paths:
67
143
  - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
144
+ required_ruby_version: !ruby/object:Gem::Requirement
69
145
  none: false
70
- requirements:
71
- - - ! '>='
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
- segments:
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ hash: 3
150
+ segments:
75
151
  - 0
76
- hash: -3422487645257531727
77
- required_rubygems_version: !ruby/object:Gem::Requirement
152
+ version: "0"
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
154
  none: false
79
- requirements:
80
- - - ! '>'
81
- - !ruby/object:Gem::Version
82
- version: 1.3.1
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ hash: 3
159
+ segments:
160
+ - 0
161
+ version: "0"
83
162
  requirements: []
163
+
84
164
  rubyforge_project: puppi
85
165
  rubygems_version: 1.8.24
86
166
  signing_key:
87
167
  specification_version: 3
88
168
  summary: Puppet module to manage applications deployments and servers local management
89
- test_files:
169
+ test_files:
90
170
  - spec/core/rake_task.rb
91
171
  - spec/puppi/action_spec.rb
92
172
  - spec/puppi/files/datafile_spec.rb
@@ -1,59 +0,0 @@
1
- ---
2
- name: openssh
3
- config_file_mode: "0644"
4
- puppi_helper: standard
5
- monitor_tool: puppi nagios munin
6
- manage_file: present
7
- manage_monitor: true
8
- source_dir_purge: false
9
- bool_debug: false
10
- title: openssh
11
- data_dir: /etc/ssh
12
- config_file_init: /etc/sysconfig/sshd
13
- firewall: false
14
- source_dir: ""
15
- caller_module_name: openssh
16
- port: "22"
17
- log_file: /var/log/messages
18
- service: sshd
19
- firewall_tool: ""
20
- bool_firewall: false
21
- protocol: tcp
22
- config_file_owner: root
23
- process: sshd
24
- puppi: "true"
25
- monitor_target: 0.0.0.0
26
- manage_file_replace: true
27
- config_file_group: root
28
- process_user: root
29
- firewall_src: 0.0.0.0/0
30
- bool_absent: false
31
- manage_package: present
32
- service_status: true
33
- package: openssh-server
34
- monitor: "yes"
35
- disableboot: false
36
- template: ""
37
- manage_service_ensure: running
38
- manage_firewall: true
39
- config_file: /etc/ssh/sshd_config
40
- config_dir: /etc/ssh
41
- bool_disableboot: false
42
- bool_monitor: true
43
- bool_audit_only: false
44
- module_name: openssh
45
- process_args: ""
46
- debug: "no"
47
- disable: false
48
- bool_disable: false
49
- bool_puppi: true
50
- log_dir: /var/log
51
- pid_file: /var/run/sshd.pid
52
- audit_only: false
53
- absent: false
54
- source: ""
55
- my_class: ""
56
- manage_service_enable: true
57
- firewall_dst: 10.42.20.10
58
- options: ""
59
- bool_source_dir_purge: false
@@ -1,13 +0,0 @@
1
- ---
2
- :info:
3
- -
4
- :command: "rpm -qi $package_name"
5
- :description: "show package info"
6
- -
7
- :command: "service $service_name"
8
- :description: "show service info"
9
- :check:
10
- -
11
- :command: "chk_port $port"
12
- :description: "checks port"
13
-
data/etc/t.rb DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- require 'pry'
5
- require File.dirname(__FILE__) + '/lib/puppi'
6
-
7
- require 'puppi'
8
-
9
- binding.pry