promotion 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,10 +1,14 @@
1
- Version 1.1.0::
2
- Added dependency on log4r. Fixed several broken dependencies caused
3
- by converting to a gem.
1
+ == Version 1.2.0
2
+ - Make Promotion a better gem citizen by making the installation of executables
3
+ an explicit command, as shown in the post-installation message.
4
4
 
5
- Version 1.0.9::
6
- Minor documentation fixes.
5
+ === Version 1.1.0
6
+ - Added dependency on log4r.
7
+ - Fixed several broken dependencies caused by converting to a gem.
7
8
 
8
- Version 1.0.8::
9
- Added extension to install executables: promote, evolve, devolve.
10
- Added mkdeploy executable to create a template deployment descriptor.
9
+ === Version 1.0.9
10
+ - Minor documentation fixes.
11
+
12
+ === Version 1.0.8
13
+ - Added extension to install executables: promote, evolve, devolve.
14
+ - Added mkdeploy executable to create a template deployment descriptor.
data/README CHANGED
@@ -49,7 +49,10 @@ files that need to be adjusted to enable an application to startup or run proper
49
49
  - /var/cron/tabs/*
50
50
 
51
51
  Promotion generates these files based on the set of all of the deployment descriptors it finds
52
- in the staging area.
52
+ in the staging area. It will preserve the original contents of the file, and append generated
53
+ contents after the following special demarcation line:
54
+ #---promotion---
55
+ This respects the need for an administrator to add custom contents (above the line).
53
56
 
54
57
  An important aspect is that a deployment is *idempotent* - you can do it as many
55
58
  times as you like and the result will be the same. This means its safe to make a
@@ -68,8 +71,17 @@ to suit your system's paths.
68
71
 
69
72
  DO NOT USE ON A PRODUCTION SYSTEM without rigorous testing in a virtual machine first.
70
73
 
71
- Installing promotion automatically creates the /var/staging directory
74
+ Install the promotion gem, which displays a post-installation message:
75
+
72
76
  $ sudo gem install promotion
77
+
78
+ To install the executables issue the following command:
79
+
80
+ $ sudo ruby -rubygems -e "require 'promotion/install'"
81
+
82
+ This will install the executables (+promote+, +evolve+, +devolve+, +mkdeploy+) and
83
+ create the staging area +/var/staging+.
84
+
73
85
  Now you are ready to use Promotion to deploy other applications.
74
86
 
75
87
  == Usage
@@ -173,7 +185,7 @@ override the default Mode, Owner, and Group.
173
185
  === +Files+
174
186
  Finally we can specify how to move the files into place:
175
187
  <Files Owner="root" Group="wheel" Mode="0644" Source="conf">
176
- <File>/etc/my.cnf</File>
188
+ <File Backup="true">/etc/my.cnf</File>
177
189
  <File>/etc/myapp.conf</File>
178
190
  </Files>
179
191
  <Files Owner="root" Group="wheel" Mode="0750" Source="sbin">
@@ -192,6 +204,10 @@ This results in Promotion executing a command such as:
192
204
  This allows a flatter, more convenient project folder structure, since the deployment descriptor maps
193
205
  the files into their proper operating system locations.
194
206
 
207
+ Note that the file +my.cnf+ has an extra *Backup* attribute. This makes a backup of the original file
208
+ to +my.cnf-original+ once only. This is a good idea for important original configuration files
209
+ such as snort.conf or httpd.conf. They often have hundreds of comments that are useful for reference.
210
+
195
211
  As for Folders, the Files element can define the default Owner, Group and Mode for all File children.
196
212
 
197
213
  === +Allfiles+
@@ -6,7 +6,7 @@
6
6
  spec.elements.each("/Specification/Environment") do |env|
7
7
  env.elements.each("Variable") do |var|
8
8
  t = var.cdatas.length > 0 ? var.cdatas[0].to_s() : var.text() %>
9
- export <%= var.attributes["Name"] %>="<%= t.strip() %>"<% end %>
9
+ export <%= var.attributes["Name"] %>="<%= t %>"<% end %>
10
10
  <% env.elements.each("Alias") do |ali|
11
11
  t = ali.cdatas.length > 0 ? ali.cdatas[0].to_s() : ali.text()
12
12
  %><% if ali.attributes["Comment"] %><%= "\n# "+ali.attributes["Comment"]
@@ -0,0 +1,65 @@
1
+ require 'fileutils'
2
+
3
+ #______________________
4
+ if Process.euid != 0
5
+ puts("This script must be run as root")
6
+ exit 1
7
+ end
8
+
9
+ #______________________
10
+ # Enable graceful exit especially while seeking input
11
+ ["INT", "TERM", "QUIT"].each { |sig|
12
+ Signal.trap(sig) {
13
+ puts("")
14
+ exit(0)
15
+ }
16
+ }
17
+
18
+ #______________________
19
+ # display intent
20
+ bindir = File.expand_path("../../bin", File.dirname(__FILE__))
21
+ executables = %w{promote evolve devolve mkdeploy}
22
+
23
+ puts("Installing Promotion")
24
+ puts("--------------------")
25
+ puts("This procedure will install the following executables:")
26
+ executables.each { |exe|
27
+ puts(" * #{exe}")
28
+ }
29
+
30
+ #______________________
31
+ # confirm path to install to
32
+ sbindir = "/usr/local/sbin"
33
+ confirmed = false
34
+ begin
35
+ print("Install to path [#{sbindir}]: ")
36
+ answer = gets().chomp()
37
+ if answer == ""
38
+ confirmed = true
39
+ else
40
+ if File.directory?(answer)
41
+ confirmed = true
42
+ sbindir = answer
43
+ else
44
+ puts(" Sorry, the directory #{answer} was not found.\n\n")
45
+ end
46
+ end
47
+ end until confirmed
48
+
49
+ #______________________
50
+ # install the executables
51
+ executables.each { |exe|
52
+ targ = "#{sbindir}/#{exe}"
53
+ FileUtils.cp("#{bindir}/#{exe}", targ)
54
+ FileUtils.chown("root", "wheel", targ)
55
+ FileUtils.chmod(0755, targ)
56
+ puts(" " + `ls -l #{targ}`)
57
+ }
58
+
59
+ #______________________
60
+ # create staging area
61
+ staging = "/var/staging"
62
+ puts("Creating staging area /var/staging")
63
+ FileUtils.mkdir_p(staging)
64
+ puts(" " + `ls -ld #{staging}`)
65
+ puts("Done.")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promotion
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Kernahan
@@ -49,8 +49,8 @@ description: "\t\tThe Promotion tool is designed to make it easy and quick to de
49
49
  email: dev.promotion@finalstep.com.au
50
50
  executables: []
51
51
 
52
- extensions:
53
- - ext/promotion/extconf.rb
52
+ extensions: []
53
+
54
54
  extra_rdoc_files:
55
55
  - README
56
56
  files:
@@ -58,8 +58,8 @@ files:
58
58
  - bin/evolve
59
59
  - bin/devolve
60
60
  - bin/mkdeploy
61
- - ext/promotion/extconf.rb
62
61
  - lib/promotion.rb
62
+ - lib/promotion/install.rb
63
63
  - lib/promotion/application.rb
64
64
  - lib/promotion/config.rb
65
65
  - lib/promotion/enforcer.rb
@@ -70,14 +70,16 @@ files:
70
70
  - lib/promotion/erb/rc.conf.local.erb
71
71
  - lib/promotion/erb/sudoers.erb
72
72
  - .yardopts
73
- - deploy.xml
74
73
  - promotion.xsd
75
74
  - CHANGELOG
76
75
  - README
77
76
  homepage: http://rubygems.org/gems/promotion
78
77
  licenses: []
79
78
 
80
- post_install_message: "\n Executables have been installed in /usr/local/sbin:\n promote\n evolve\n devolve\n mkdeploy\n These are not automatically removed by uninstalling the gem.\n "
79
+ post_install_message: "\n\
80
+ \t\n To install the executables (promote, evolve, devolve, mkdeploy)\n issue the following command:\n\
81
+ \t$ sudo ruby -rubygems -e \"require 'promotion/install'\"\n\
82
+ \t\n "
81
83
  rdoc_options:
82
84
  - --title
83
85
  - Promotion
data/deploy.xml DELETED
@@ -1,35 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" ?>
2
- <Specification Name="promotion" Title="Promotion Manager"
3
- xmlns="http://finalstep.com.au/promotion/v100"
4
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
- xsi:schemaLocation="http://finalstep.com.au/schema/promotion.v100.xsd ../promotion/promotion.xsd">
6
- <Description>
7
- The promotion manager ensures that the environment for an application
8
- is set up correctly, including folder and file permissions and ownership,
9
- startup scripts, sudoers privileges and environment variables.
10
- </Description>
11
- <Folders>
12
- <Folder Mode="0770">/var/staging</Folder>
13
- <Folder Mode="0770">/var/staging/promotion</Folder>
14
- <Folder Clear="true">/usr/local/promotion</Folder>
15
- <Folder>/usr/local/promotion/erb</Folder>
16
- </Folders>
17
- <Files Source="bin" Mode="0755">
18
- <File>/usr/local/sbin/promote</File>
19
- <File>/usr/local/sbin/evolve</File>
20
- <File>/usr/local/sbin/devolve</File>
21
- </Files>
22
- <Files Source="lib/promotion">
23
- <File>/usr/local/promotion/application.rb</File>
24
- <File>/usr/local/promotion/config.rb</File>
25
- <File>/usr/local/promotion/enforcer.rb</File>
26
- <File>/usr/local/promotion/generator.rb</File>
27
- <File>/usr/local/promotion/evolver.rb</File>
28
- </Files>
29
- <Files Source="lib/promotion/erb">
30
- <File>/usr/local/promotion/erb/profile.erb</File>
31
- <File>/usr/local/promotion/erb/rc.conf.local.erb</File>
32
- <File>/usr/local/promotion/erb/sudoers.erb</File>
33
- <File>/usr/local/promotion/erb/crontab.erb</File>
34
- </Files>
35
- </Specification>
@@ -1,25 +0,0 @@
1
- #!/usr/local/bin/ruby
2
- # Working directory is the ext/promotion/ folder
3
-
4
- # generate Makefile to install binaries
5
- # Its a sysadmin tool after all, so we'll pretend not to see Eric Hodel
6
- # frowning on the (ab)use of extconf.rb
7
- source = "../../bin"
8
- target = "/usr/local"
9
- makeContents=<<-EOT
10
- # Makefile for Promotion
11
- .PHONY : all
12
- all :
13
- .PHONY : install
14
- install :
15
- install -m 0750 -o root -g wheel #{source}/promote #{target}/sbin
16
- install -m 0750 -o root -g wheel #{source}/evolve #{target}/sbin
17
- install -m 0750 -o root -g wheel #{source}/devolve #{target}/sbin
18
- install -m 0750 -o root -g wheel #{source}/mkdeploy #{target}/sbin
19
- install -m 0750 -o root -g wheel -d /var/staging
20
- EOT
21
- makefile = File.new("Makefile", "w")
22
- makefile.puts(makeContents)
23
- makefile.close()
24
- # Note that there is no provision for uninstalling these binaries
25
- # If the gem is uninstalled, the binaries need to be deleted manually