pupcap 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pupcap/action/apply.rb +5 -1
- data/lib/pupcap/action/apply/Capfile +5 -2
- data/lib/pupcap/action/init.rb +21 -7
- data/lib/pupcap/action/init/Pupcapfile.erb +3 -1
- data/lib/pupcap/action/{prepare/ubuntu/precise.sh → init/prepare.sh.erb} +9 -0
- data/lib/pupcap/action/prepare.rb +10 -3
- data/lib/pupcap/action/prepare/Capfile +11 -10
- data/lib/pupcap/version.rb +1 -1
- metadata +3 -3
data/lib/pupcap/action/apply.rb
CHANGED
@@ -15,7 +15,7 @@ class Pupcap::Action::Apply < Pupcap::Action::Base
|
|
15
15
|
unless @parsed_options
|
16
16
|
options = default_options.dup
|
17
17
|
OptionParser.new do |opts|
|
18
|
-
opts.banner = "Usage: #{File.basename($0)}
|
18
|
+
opts.banner = "Usage: #{File.basename($0)} apply [options] <tasks>"
|
19
19
|
|
20
20
|
opts.on("-f", "--file FILE", "A recipe file to load") do |file|
|
21
21
|
options[:file] = File.expand_path(file)
|
@@ -33,6 +33,10 @@ class Pupcap::Action::Apply < Pupcap::Action::Base
|
|
33
33
|
opts.on("-n", "--noop", "Noop") do |file|
|
34
34
|
options[:noop] = true
|
35
35
|
end
|
36
|
+
|
37
|
+
opts.on("-w", "--without-librarian-puppet", "Deploy without librarian-puppet") do
|
38
|
+
options[:without_librarian_puppet] = true
|
39
|
+
end
|
36
40
|
end.parse!
|
37
41
|
options[:tasks] = ARGV
|
38
42
|
@parsed_options = options
|
@@ -2,8 +2,11 @@ require 'erb'
|
|
2
2
|
|
3
3
|
namespace :deploy do
|
4
4
|
task :finalize_update do
|
5
|
-
|
6
|
-
|
5
|
+
if !pupcap_options[:without_librarian_puppet]
|
6
|
+
debug = pupcap_options[:debug] ? " --verbose" : ""
|
7
|
+
run("ln -sf #{shared_path}/librarian-puppet-cache #{release_path}/puppet/.tmp")
|
8
|
+
run("cd #{release_path}/puppet && test -f #{release_path}/puppet/Puppetfile && /usr/local/bin/librarian-puppet install #{debug}; true")
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
task :restart do
|
data/lib/pupcap/action/init.rb
CHANGED
@@ -14,6 +14,17 @@ class Pupcap::Action::Init < Pupcap::Action::Base
|
|
14
14
|
create_pp
|
15
15
|
librarian_puppet
|
16
16
|
create_gitignore
|
17
|
+
create_prepare_script
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_prepare_script
|
21
|
+
out = "#{work_dir}/prepare.sh.erb"
|
22
|
+
if !File.exists?(out) || force?
|
23
|
+
FileUtils.copy("#{lib_root}/init/prepare.sh.erb", "#{work_dir}/prepare.sh.erb")
|
24
|
+
puts "create prepare.sh.erb"
|
25
|
+
else
|
26
|
+
puts "skip prepare.sh.erb"
|
27
|
+
end
|
17
28
|
end
|
18
29
|
|
19
30
|
def create_vagrantfile
|
@@ -22,9 +33,9 @@ class Pupcap::Action::Init < Pupcap::Action::Base
|
|
22
33
|
erb = ERB.new(File.read("#{lib_root}/init/Vagrantfile.erb"))
|
23
34
|
rs = erb.result(binding)
|
24
35
|
File.open(out, "w+"){ |io| io.write rs }
|
25
|
-
puts "
|
36
|
+
puts "create Vagrantfile"
|
26
37
|
else
|
27
|
-
puts "
|
38
|
+
puts "skip #{out}"
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
@@ -34,9 +45,9 @@ class Pupcap::Action::Init < Pupcap::Action::Base
|
|
34
45
|
erb = ERB.new(File.read("#{lib_root}/init/Pupcapfile.erb"))
|
35
46
|
rs = erb.result(binding)
|
36
47
|
File.open(out, "w+"){ |io| io.write rs }
|
37
|
-
puts "
|
48
|
+
puts "create Capfile"
|
38
49
|
else
|
39
|
-
puts "
|
50
|
+
puts "skip #{out}"
|
40
51
|
end
|
41
52
|
end
|
42
53
|
|
@@ -46,9 +57,9 @@ class Pupcap::Action::Init < Pupcap::Action::Base
|
|
46
57
|
erb = ERB.new(File.read("#{lib_root}/init/site.pp.erb"))
|
47
58
|
rs = erb.result(binding)
|
48
59
|
File.open(out, "w+"){ |io| io.write rs }
|
49
|
-
puts "
|
60
|
+
puts "create puppet/manifests/site.pp"
|
50
61
|
else
|
51
|
-
puts "
|
62
|
+
puts "skip #{out}"
|
52
63
|
end
|
53
64
|
end
|
54
65
|
|
@@ -65,8 +76,11 @@ class Pupcap::Action::Init < Pupcap::Action::Base
|
|
65
76
|
end
|
66
77
|
|
67
78
|
def create_gitignore
|
68
|
-
|
79
|
+
if !File.exists?("#{work_dir}.gitignore")
|
69
80
|
FileUtils.copy("#{lib_root}/init/gitignore", "#{work_dir}/.gitignore")
|
81
|
+
puts "create .gitignore"
|
82
|
+
else
|
83
|
+
puts "skip .gitignore"
|
70
84
|
end
|
71
85
|
end
|
72
86
|
|
@@ -6,18 +6,27 @@ then
|
|
6
6
|
exit 0
|
7
7
|
fi
|
8
8
|
|
9
|
+
#
|
10
|
+
# fix may be broken locale
|
11
|
+
#
|
9
12
|
CURRENT_LANG=`locale | awk '/LANG=/{ split($1, a, "=") ; print a[2] }'`
|
10
13
|
if test "x${CURRENT_LANG}" != "xen_US.UTF-8"
|
11
14
|
then
|
12
15
|
locale-gen en_US.UTF-8 && update-locale LANG=en_US.UTF-8
|
13
16
|
fi
|
14
17
|
|
18
|
+
#
|
19
|
+
# set hostname
|
20
|
+
#
|
15
21
|
if test -n "${PUPCAP_HOSTNAME}"
|
16
22
|
then
|
17
23
|
echo ${PUPCAP_HOSTNAME} > /etc/hostname
|
18
24
|
cat /etc/hosts | grep ${PUPCAP_HOSTNAME} || echo "127.0.0.1 ${PUPCAP_HOSTNAME}" >> /etc/hosts && /usr/sbin/service hostname start
|
19
25
|
fi
|
20
26
|
|
27
|
+
#
|
28
|
+
# update sources.list
|
29
|
+
#
|
21
30
|
SOURCES_LIST=/etc/apt/sources.list
|
22
31
|
|
23
32
|
SOURCES_LIST_MD5=`md5sum ${SOURCES_LIST} | awk '{ print $1 }'`
|
@@ -5,16 +5,22 @@ require 'pupcap/lsb_release'
|
|
5
5
|
class Pupcap::Action::Prepare < Pupcap::Action::Base
|
6
6
|
def initialize
|
7
7
|
check_puppetfile!
|
8
|
+
check_prepare_script!
|
8
9
|
end
|
9
10
|
|
10
11
|
def start
|
11
12
|
cap = create_cap_for(parsed_options[:file])
|
12
|
-
lsb = Pupcap::LsbRelease.new(cap)
|
13
|
-
prepare_proc = lambda{ "#{lib_root}/prepare/#{lsb.name.downcase}/#{lsb.codename.downcase}.sh" }
|
14
|
-
cap.set :pupcap_prepare_command, prepare_proc
|
13
|
+
#lsb = Pupcap::LsbRelease.new(cap)
|
15
14
|
cap_load_and_run_task(cap, "prepare")
|
16
15
|
end
|
17
16
|
|
17
|
+
def check_prepare_script!
|
18
|
+
unless File.exists?(parsed_options[:script])
|
19
|
+
$stderr.puts "File #{parsed_options[:script]} does not exists"
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
18
24
|
def parsed_options
|
19
25
|
unless @parsed_options
|
20
26
|
options = default_options.dup
|
@@ -47,6 +53,7 @@ class Pupcap::Action::Prepare < Pupcap::Action::Base
|
|
47
53
|
def default_options
|
48
54
|
{
|
49
55
|
:file => File.expand_path("Pupcapfile"),
|
56
|
+
:script => File.expand_path("prepare.sh.erb"),
|
50
57
|
:force => false,
|
51
58
|
:upgrade => false
|
52
59
|
}
|
@@ -36,16 +36,17 @@ namespace :prepare do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
task :run_script do
|
39
|
-
|
39
|
+
template = pupcap_options[:script]
|
40
|
+
prepare_script = ERB.new(File.read template).result(binding)
|
41
|
+
|
40
42
|
set :use_sudo, true
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
43
|
+
|
44
|
+
remote_script_name = "/tmp/pupcap_prepare.sh"
|
45
|
+
put(prepare_script, remote_script_name)
|
46
|
+
run("chmod 0755 #{remote_script_name}")
|
47
|
+
force = pupcap_options[:force] ? "1" : "0"
|
48
|
+
hostname = pupcap_options[:hostname] ? " PUPCAP_HOSTNAME=#{pupcap_options[:hostname]}" : ""
|
49
|
+
sudo("env PUPCAP_FORCE=#{force}#{hostname} #{remote_script_name}")
|
50
|
+
run("rm #{remote_script_name}")
|
50
51
|
end
|
51
52
|
end
|
data/lib/pupcap/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -97,11 +97,11 @@ files:
|
|
97
97
|
- lib/pupcap/action/init/Pupcapfile.erb
|
98
98
|
- lib/pupcap/action/init/Vagrantfile.erb
|
99
99
|
- lib/pupcap/action/init/gitignore
|
100
|
+
- lib/pupcap/action/init/prepare.sh.erb
|
100
101
|
- lib/pupcap/action/init/site.pp.erb
|
101
102
|
- lib/pupcap/action/noop.rb
|
102
103
|
- lib/pupcap/action/prepare.rb
|
103
104
|
- lib/pupcap/action/prepare/Capfile
|
104
|
-
- lib/pupcap/action/prepare/ubuntu/precise.sh
|
105
105
|
- lib/pupcap/action/ssh.rb
|
106
106
|
- lib/pupcap/action/ssh/Capfile
|
107
107
|
- lib/pupcap/cli.rb
|