pupcap 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pupcap/action/{cook.rb → apply.rb} +3 -3
- data/lib/pupcap/action/apply/Capfile +35 -0
- data/lib/pupcap/action/{cook/apply.sh.erb → apply/puppet.sh.erb} +1 -1
- data/lib/pupcap/action/init.rb +26 -10
- data/lib/pupcap/action/init/Capfile.erb +3 -0
- data/lib/pupcap/action/init/gitignore +2 -0
- data/lib/pupcap/action/init/{default.pp.erb → site.pp.erb} +0 -0
- data/lib/pupcap/action/noop.rb +9 -0
- data/lib/pupcap/action/prepare.rb +1 -1
- data/lib/pupcap/action/prepare/ubuntu/precise.sh +6 -3
- data/lib/pupcap/action/ssh.rb +1 -1
- data/lib/pupcap/cli.rb +1 -1
- data/lib/pupcap/version.rb +2 -2
- data/pupcap.gemspec +3 -0
- metadata +24 -6
- data/lib/pupcap/action/cook/Capfile +0 -41
- data/lib/pupcap/action/init/Puppetfile.erb +0 -3
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'pupcap/action'
|
2
2
|
require 'pupcap/command'
|
3
3
|
|
4
|
-
class Pupcap::Action::
|
4
|
+
class Pupcap::Action::Apply < Pupcap::Action::Base
|
5
5
|
def initialize
|
6
6
|
check_puppetfile!
|
7
7
|
end
|
8
8
|
|
9
9
|
def start
|
10
10
|
cap = create_cap_for(parsed_options[:file])
|
11
|
-
cap_load_and_run_task(cap, "
|
11
|
+
cap_load_and_run_task(cap, "apply")
|
12
12
|
end
|
13
13
|
|
14
14
|
def parsed_options
|
@@ -42,7 +42,7 @@ class Pupcap::Action::Cook < Pupcap::Action::Base
|
|
42
42
|
|
43
43
|
def default_options
|
44
44
|
{
|
45
|
-
:file => File.expand_path("
|
45
|
+
:file => File.expand_path("Capfile"),
|
46
46
|
:debug => false,
|
47
47
|
:noop => false
|
48
48
|
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
namespace :apply do
|
4
|
+
task :default do
|
5
|
+
rsync
|
6
|
+
puppet
|
7
|
+
cleanup
|
8
|
+
end
|
9
|
+
|
10
|
+
task :rsync do
|
11
|
+
from = "#{local_root}/puppet"
|
12
|
+
to = deploy_to
|
13
|
+
upload(from, to, :recursive => true, :via => :scp)
|
14
|
+
end
|
15
|
+
|
16
|
+
task :puppet do
|
17
|
+
remote_command = "#{deploy_to}/apply.sh"
|
18
|
+
|
19
|
+
puppet = "/usr/local/bin/puppet"
|
20
|
+
modules = "--modulepath=#{deploy_to}/modules:#{deploy_to}/site-modules"
|
21
|
+
nook = pupcap_options[:noop] ? " --noop" : ""
|
22
|
+
debug = pupcap_options[:debug] ? " --debug --verbose" : ""
|
23
|
+
|
24
|
+
erb = ERB.new(File.read("#{pupcap_root}/action/apply/puppet.sh.erb"))
|
25
|
+
rs = erb.result(binding)
|
26
|
+
|
27
|
+
put(rs, remote_command)
|
28
|
+
run("chmod +x #{remote_command}")
|
29
|
+
sudo("#{remote_command} \"$CAPISTRANO:HOSTROLES$\"")
|
30
|
+
end
|
31
|
+
|
32
|
+
task :cleanup do
|
33
|
+
run("rm -rf #{deploy_to}")
|
34
|
+
end
|
35
|
+
end
|
data/lib/pupcap/action/init.rb
CHANGED
@@ -10,8 +10,10 @@ class Pupcap::Action::Init < Pupcap::Action::Base
|
|
10
10
|
def start
|
11
11
|
create_directories
|
12
12
|
create_vagrantfile
|
13
|
-
|
13
|
+
create_capfile
|
14
14
|
create_pp
|
15
|
+
librarian_puppet
|
16
|
+
create_gitignore
|
15
17
|
end
|
16
18
|
|
17
19
|
def create_vagrantfile
|
@@ -20,38 +22,52 @@ class Pupcap::Action::Init < Pupcap::Action::Base
|
|
20
22
|
erb = ERB.new(File.read("#{lib_root}/init/Vagrantfile.erb"))
|
21
23
|
rs = erb.result(binding)
|
22
24
|
File.open(out, "w+"){ |io| io.write rs }
|
25
|
+
puts "\t create Vagrantfile"
|
23
26
|
else
|
24
|
-
puts "
|
27
|
+
puts "\t skip #{out}"
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
28
|
-
def
|
29
|
-
out = "#{work_dir}/
|
31
|
+
def create_capfile
|
32
|
+
out = "#{work_dir}/Capfile"
|
30
33
|
if !File.exists?(out) || force?
|
31
|
-
erb = ERB.new(File.read("#{lib_root}/init/
|
34
|
+
erb = ERB.new(File.read("#{lib_root}/init/Capfile.erb"))
|
32
35
|
rs = erb.result(binding)
|
33
36
|
File.open(out, "w+"){ |io| io.write rs }
|
37
|
+
puts "\t create Capfile"
|
34
38
|
else
|
35
|
-
puts "
|
39
|
+
puts "\t skip #{out}"
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
39
43
|
def create_pp
|
40
|
-
out = "#{work_dir}/puppet/manifests/
|
44
|
+
out = "#{work_dir}/puppet/manifests/site.pp"
|
41
45
|
if !File.exists?(out) || force?
|
42
|
-
erb = ERB.new(File.read("#{lib_root}/init/
|
46
|
+
erb = ERB.new(File.read("#{lib_root}/init/site.pp.erb"))
|
43
47
|
rs = erb.result(binding)
|
44
48
|
File.open(out, "w+"){ |io| io.write rs }
|
49
|
+
puts "\t create puppet/manifests/site.pp"
|
45
50
|
else
|
46
|
-
puts "
|
51
|
+
puts "\t skip #{out}"
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
50
55
|
def create_directories
|
51
56
|
FileUtils.mkdir_p("#{work_dir}/puppet/modules")
|
57
|
+
FileUtils.mkdir_p("#{work_dir}/puppet/site-modules")
|
52
58
|
FileUtils.mkdir_p("#{work_dir}/puppet/manifests")
|
53
|
-
system("touch #{work_dir}/puppet/modules/.gitkeep")
|
54
59
|
system("touch #{work_dir}/puppet/manifests/.gitkeep")
|
60
|
+
system("touch #{work_dir}/puppet/site-modules/.gitkeep")
|
61
|
+
end
|
62
|
+
|
63
|
+
def librarian_puppet
|
64
|
+
Pupcap::Command.run_local("(cd #{work_dir}/puppet && librarian-puppet init)")
|
65
|
+
end
|
66
|
+
|
67
|
+
def create_gitignore
|
68
|
+
unless File.exists?("#{work_dir}.gitignore")
|
69
|
+
FileUtils.copy("#{lib_root}/init/gitignore", "#{work_dir}/.gitignore")
|
70
|
+
end
|
55
71
|
end
|
56
72
|
|
57
73
|
def work_dir
|
File without changes
|
@@ -6,9 +6,10 @@ then
|
|
6
6
|
exit 0
|
7
7
|
fi
|
8
8
|
|
9
|
-
|
9
|
+
CURRENT_LANG=`locale | awk '/LANG=/{ split($1, a, "=") ; print a[2] }'`
|
10
|
+
if test "x${CURRENT_LANG}" != "xen_US.UTF-8"
|
10
11
|
then
|
11
|
-
locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
|
12
|
+
locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
|
12
13
|
fi
|
13
14
|
|
14
15
|
if test -n "${PUPCAP_HOSTNAME}"
|
@@ -21,7 +22,7 @@ SOURCES_LIST=/etc/apt/sources.list
|
|
21
22
|
|
22
23
|
SOURCES_LIST_MD5=`md5sum ${SOURCES_LIST} | awk '{ print $1 }'`
|
23
24
|
|
24
|
-
if test "$SOURCES_LIST_MD5" != "14846cd43a3ef58b204b0807fa4856f8"
|
25
|
+
if test "$SOURCES_LIST_MD5" != "14846cd43a3ef58b204b0807fa4856f8"
|
25
26
|
then
|
26
27
|
|
27
28
|
cp -f ${SOURCES_LIST} ${SOURCES_LIST}.pupcap_back
|
@@ -52,6 +53,8 @@ apt-get install -qy rsync wget rubygems vim git-core build-essential > /dev/null
|
|
52
53
|
apt-get -qy clean
|
53
54
|
|
54
55
|
/usr/bin/gem install -q --no-ri --no-rdoc --version '~> 2.7.1' puppet
|
56
|
+
/usr/bin/gem install -q --no-ri --no-rdoc librarian-puppet
|
57
|
+
|
55
58
|
/usr/sbin/groupadd -f puppet
|
56
59
|
|
57
60
|
touch /root/.pupcap_prepare_ok
|
data/lib/pupcap/action/ssh.rb
CHANGED
data/lib/pupcap/cli.rb
CHANGED
data/lib/pupcap/version.rb
CHANGED
data/pupcap.gemspec
CHANGED
@@ -22,12 +22,15 @@ Gem::Specification.new do |s|
|
|
22
22
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
23
23
|
s.add_runtime_dependency(%q<capistrano>, [">= 2.12.0"])
|
24
24
|
s.add_runtime_dependency(%q<vagrant>, [">= 1.0.0"])
|
25
|
+
s.add_runtime_dependency(%q<librarian-puppet>, [">= 0.9.7"])
|
25
26
|
else
|
26
27
|
s.add_dependency(%q<capistrano>, [">= 2.12.0"])
|
27
28
|
s.add_dependency(%q<vagrant>, [">= 1.0.0"])
|
29
|
+
s.add_dependency(%q<librarian-puppet>, [">= 0.9.7"])
|
28
30
|
end
|
29
31
|
else
|
30
32
|
s.add_dependency(%q<capistrano>, [">= 2.12.0"])
|
31
33
|
s.add_dependency(%q<vagrant>, [">= 1.0.0"])
|
34
|
+
s.add_dependency(%q<librarian-puppet>, [">= 0.9.7"])
|
32
35
|
end
|
33
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pupcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 1.0.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: librarian-puppet
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.9.7
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.7
|
46
62
|
description: under development description
|
47
63
|
email:
|
48
64
|
- dima.exe@gmail.com
|
@@ -58,13 +74,15 @@ files:
|
|
58
74
|
- bin/pupcap
|
59
75
|
- lib/pupcap.rb
|
60
76
|
- lib/pupcap/action.rb
|
61
|
-
- lib/pupcap/action/
|
62
|
-
- lib/pupcap/action/
|
63
|
-
- lib/pupcap/action/
|
77
|
+
- lib/pupcap/action/apply.rb
|
78
|
+
- lib/pupcap/action/apply/Capfile
|
79
|
+
- lib/pupcap/action/apply/puppet.sh.erb
|
64
80
|
- lib/pupcap/action/init.rb
|
65
|
-
- lib/pupcap/action/init/
|
81
|
+
- lib/pupcap/action/init/Capfile.erb
|
66
82
|
- lib/pupcap/action/init/Vagrantfile.erb
|
67
|
-
- lib/pupcap/action/init/
|
83
|
+
- lib/pupcap/action/init/gitignore
|
84
|
+
- lib/pupcap/action/init/site.pp.erb
|
85
|
+
- lib/pupcap/action/noop.rb
|
68
86
|
- lib/pupcap/action/prepare.rb
|
69
87
|
- lib/pupcap/action/prepare/Capfile
|
70
88
|
- lib/pupcap/action/prepare/ubuntu/precise.sh
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
namespace :cook do
|
4
|
-
task :default do
|
5
|
-
rsync
|
6
|
-
apply
|
7
|
-
cleanup
|
8
|
-
end
|
9
|
-
|
10
|
-
task :rsync do
|
11
|
-
find_servers.each do |server|
|
12
|
-
port = Pupcap::Command.server_port(self, server)
|
13
|
-
host = Pupcap::Command.server_host(self, server)
|
14
|
-
ssh_cmd = "-e \"ssh -p #{port} -i #{provision_key}\""
|
15
|
-
rsync_options = "-p --chmod=o+r,g+r -az"
|
16
|
-
cmd = "rsync #{rsync_options} #{ssh_cmd} #{local_root}/puppet/ #{host}:#{deploy_to}"
|
17
|
-
logger.important(cmd)
|
18
|
-
system(cmd)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
task :apply do
|
23
|
-
remote_command = "#{deploy_to}/apply.sh"
|
24
|
-
|
25
|
-
puppet = "/usr/local/bin/puppet"
|
26
|
-
modules = "--modulepath=#{deploy_to}/modules:#{deploy_to}/manifests"
|
27
|
-
nook = pupcap_options[:noop] ? " --noop" : ""
|
28
|
-
debug = pupcap_options[:debug] ? " --debug --verbose" : ""
|
29
|
-
|
30
|
-
erb = ERB.new(File.read("#{pupcap_root}/action/cook/apply.sh.erb"))
|
31
|
-
rs = erb.result(binding)
|
32
|
-
|
33
|
-
put(rs, remote_command)
|
34
|
-
run("chmod +x #{remote_command}")
|
35
|
-
sudo("#{remote_command} \"$CAPISTRANO:HOSTROLES$\"")
|
36
|
-
end
|
37
|
-
|
38
|
-
task :cleanup do
|
39
|
-
run("rm -rf #{deploy_to}")
|
40
|
-
end
|
41
|
-
end
|