marionette 0.0.3 → 0.0.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/README.md CHANGED
@@ -38,18 +38,9 @@ Example
38
38
  The following has been tested on Centos 5.5 running Ruby 1.8.7-p174 and p302.
39
39
  In this example, puppet and master are on the same local network and the puppet's ip is 192.168.1.1.
40
40
 
41
- Note: By default, Marionette connects to "tcp://127.0.0.1:5555"
42
41
 
43
- Results:
44
42
 
45
- 1) on the pupet, /tmp/test.out contains "test #{Time.now}"
46
-
47
- 2) master.receive returns puppet's facts as a hash.
48
-
49
- 3) Note: this example does not execute a puppet run.
50
-
51
-
52
- Ruby:
43
+ Ruby:
53
44
 
54
45
  require 'rubygems'
55
46
  require 'marionette'
@@ -60,21 +51,46 @@ Results:
60
51
  master.send message
61
52
  master.receive
62
53
 
54
+ # Results:
55
+ #
56
+ # 1) on the pupet, /tmp/test.out contains "test #{Time.now}"
57
+ # 2) master.receive returns puppet's facts as a hash.
58
+ # 3) Note: this example does not execute a puppet run.
63
59
 
64
60
 
65
- CLI:
66
61
 
67
- marionette start tcp://192.168.1.1:5555 # start marionette as a daemon
62
+ CLI:
68
63
 
64
+ # To start marionette as a daemon
65
+ marionette start tcp://192.168.1.1:5555
69
66
 
67
+ # To setup marionette as a service
68
+ # pass the tcp address if you don't want to accept the default on eth1.
69
+ marionette-setup
70
+ marionette-setup tcp://192.168.1.1:5555
70
71
 
71
- MISC:
72
+
73
+
74
+ MISC:
75
+ # By default, the tcp connection is on eth1 over port 5555.
76
+ # Tcp location is read from /etc/marionette.tcp. Update if necessary.
72
77
 
73
78
  # run as root
74
79
  chkconfig marionette on # start marionette daemon at boot
75
80
  service marionette start # start marionette as a service
76
81
  service marionette restart # restart marionette service
77
82
  service marionette stop # stop marionette service
83
+
84
+
85
+
86
+ To Do
87
+ ----
88
+
89
+ 1) Complete implementation for puppet runs.
90
+
91
+ 2) Example of executing a run.
92
+
93
+ 3) Instructions for setting up SSH Tunnel to secure marionette.
78
94
 
79
95
 
80
96
 
data/Rakefile CHANGED
@@ -1,97 +1,3 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- def setup_service
5
- # Set up marionette as a service to start at boot.
6
- # define task:
7
- # 1) write to init.d/marionette
8
- # 2) set permissions
9
- # 3) set ifconfig
10
- # 4) start service
11
-
12
-
13
- script = <<CODE
14
- #!/bin/bash
15
-
16
- ### BEGIN INIT INFO
17
- # Provides: marionette
18
- # Default-Start: 2 3 4 5
19
- # Default-Stop: 0 1 6
20
- # Short-Description: start and stop marionette
21
- # Description: 0mq connection for puppet and master.
22
- # chkconfig: - 85 15
23
- ### END INIT INFO
24
-
25
- # source function library
26
- . /etc/rc.d/init.d/functions
27
-
28
- RETVAL=0
29
- prog="marionette"
30
-
31
- set -e
32
-
33
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
34
- DESC="marionette daemon"
35
- NAME=marionette
36
- DAEMON=/usr/local/bin/$NAME
37
- PIDFILE=/var/run/$NAME.pid
38
- LOGFILE=/var/log/$NAME.log
39
- TCPFILE=/etc/marionette.tcp
40
- SCRIPTNAME=/etc/init.d/$NAME
41
- TCP=`cat $TCPFILE`
42
-
43
- # Gracefully exit if the package has been removed.
44
- # test -x $DAEMON || exit 0
45
- echo "connecting on $TCP..."
46
-
47
- d_start() {
48
- $DAEMON start $TCP || echo -en "\n already running"
49
- }
50
-
51
- d_stop() {
52
- kill -9 `cat $PIDFILE` || echo -en "\n not running"
53
- }
54
-
55
- case "$1" in
56
- start)
57
- echo -n "Starting $DESC: $NAME"
58
- d_start
59
- echo "."
60
- ;;
61
- stop)
62
- echo -n "Stopping $DESC: $NAME"
63
- d_stop
64
- echo "."
65
- ;;
66
- restart)
67
- echo -n "Restarting $DESC: $NAME"
68
- d_stop
69
- sleep 5
70
- d_start
71
- echo "."
72
- ;;
73
- *)
74
- echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
75
- exit 3
76
- ;;
77
- esac
78
-
79
- exit 0
80
-
81
- CODE
82
-
83
- ip = `sudo /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
84
-
85
- file = File.open('/etc/marionette.tcp','w')
86
- file.write ip
87
- file.close
88
-
89
- file = File.open('/etc/init.d/marionette','w')
90
- file.write script
91
- file.close
92
-
93
- system "sudo chmod 755 /etc/init.d/marionette"
94
-
95
- end
96
-
97
- setup_service
@@ -0,0 +1,23 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'daemons'
5
+ require 'marionette'
6
+
7
+ tcp = ARGV[1] rescue nil
8
+ options = { :uri => tcp } unless ARGV.nil?
9
+
10
+ HeadStartApp::Marionette.setup(options)
11
+
12
+ puts <<CODE
13
+ Marionette is now ready to run as a service.
14
+
15
+ Here's a quick cheat sheet:
16
+
17
+ chkconfig marionette on # start service at boot
18
+ service marionette start # start as a service
19
+ service marionette restart # restart service
20
+ service marionette stop # stop service
21
+
22
+
23
+ CODE
@@ -2,6 +2,7 @@ module HeadStartApp
2
2
  module Marionette
3
3
 
4
4
  require 'uri'
5
+ require 'marionette/setup'
5
6
  require 'marionette/master'
6
7
  require 'marionette/puppet'
7
8
 
@@ -1,21 +1,22 @@
1
- # This rake task sets up marionette as a service to start at boot.
2
- # rake marionette:service
3
-
4
- require 'rake'
5
-
6
- namespace :marionette do
7
-
8
- # task description
9
- desc 'Set up marionette as a service (run this as sudo/root)'
10
-
11
- # define task:
12
- # 1) write to init.d/marionette
13
- # 2) set permissions
14
- # 3) set ifconfig
15
- # 4) start service
16
- task :service do
17
-
18
- script = <<CODE
1
+ module HeadStartApp
2
+ module Marionette
3
+
4
+ # Setup method configures the server for running marionette as a service at boot up.
5
+ def setup(options={})
6
+
7
+ # Set default(s)
8
+ ip = `sudo /sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
9
+ options = { :uri => "tcp://#{ip}:5555" } if options.nil?
10
+
11
+ # Set up marionette as a service to start at boot.
12
+ # define task:
13
+ # 1) write to init.d/marionette
14
+ # 2) set permissions
15
+ # 3) set ifconfig
16
+ # 4) start service
17
+
18
+
19
+ script = <<CODE
19
20
  #!/bin/bash
20
21
 
21
22
  ### BEGIN INIT INFO
@@ -47,7 +48,7 @@ TCP=`cat $TCPFILE`
47
48
 
48
49
  # Gracefully exit if the package has been removed.
49
50
  # test -x $DAEMON || exit 0
50
- echo `connecting on $TCP...`
51
+ echo "connecting on $TCP..."
51
52
 
52
53
  d_start() {
53
54
  $DAEMON start $TCP || echo -en "\n already running"
@@ -84,23 +85,21 @@ esac
84
85
  exit 0
85
86
 
86
87
  CODE
87
-
88
- ip = `ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
89
-
90
- file = File.open('/etc/init.d/marionette','w')
91
- file.write script
92
- file.close
93
-
94
- file = File.open('/etc/marionette.tcp','w')
95
- file.write ip
96
- file.close
88
+
89
+ file = File.open('/etc/marionette.tcp','w')
90
+ file.write "tcp://#{ip}:5555"
91
+ file.close
92
+
93
+ file = File.open('/etc/init.d/marionette','w')
94
+ file.write script
95
+ file.close
96
+
97
+ system "sudo chmod 755 /etc/init.d/marionette"
98
+
99
+ end
100
+
101
+ module_function :setup
97
102
 
98
- system "chmod 755 /etc/init.d/marionette"
99
- system "chkconfig marionette on"
100
- system "service marionette start"
101
103
  end
102
-
103
- # set "service" as the default task
104
- task :default => [:service]
105
104
 
106
105
  end
@@ -1,5 +1,5 @@
1
1
  module HeadStartApp
2
2
  module Marionette
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
data/marionette.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.executables << 'marionette'
21
+ s.executables << 'marionette-setup'
21
22
  s.add_dependency('bundler')
22
23
  s.add_dependency('facter')
23
24
  s.add_dependency('zmq')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marionette
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dan Lee
@@ -107,7 +107,9 @@ email:
107
107
  - dan@headstartapp.com
108
108
  executables:
109
109
  - marionette
110
+ - marionette-setup
110
111
  - marionette
112
+ - marionette-setup
111
113
  extensions: []
112
114
 
113
115
  extra_rdoc_files: []
@@ -119,12 +121,13 @@ files:
119
121
  - README.md
120
122
  - Rakefile
121
123
  - bin/marionette
124
+ - bin/marionette-setup
122
125
  - lib/marionette.rb
123
126
  - lib/marionette/connect.rb
124
127
  - lib/marionette/master.rb
125
128
  - lib/marionette/puppet.rb
129
+ - lib/marionette/setup.rb
126
130
  - lib/marionette/version.rb
127
- - lib/tasks/marionette.rake
128
131
  - marionette.gemspec
129
132
  has_rdoc: true
130
133
  homepage: http://headstartapp.com