mofa 0.3.30 → 0.3.31

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mofa/cli.rb CHANGED
@@ -22,6 +22,7 @@ module Mofa
22
22
  method_option :runlist, :type => :string, :aliases => '-o'
23
23
  method_option :attributes, :type => :string, :aliases => '-j'
24
24
  method_option :service_hostlist_url, :type => :string
25
+ method_option :override_mofa_secrets, :type => :string, :aliases => '-S'
25
26
 
26
27
  def provision(cookbook_name_or_path)
27
28
  set_verbosity
@@ -34,7 +35,7 @@ module Mofa
34
35
  token = MofaCmd.generate_token
35
36
 
36
37
  hostlist = Hostlist.create(target_filter, options[:service_hostlist_url], options[:concrete_target])
37
- cookbook = Cookbook.create(cookbook_name_or_path, token)
38
+ cookbook = Cookbook.create(cookbook_name_or_path, token, options[:override_mofa_secrets])
38
39
  runlist_map = RunlistMap.create(cookbook, hostlist, token, options[:runlist])
39
40
  attributes_map = AttributesMap.create(cookbook, hostlist, token, options[:runlist], options[:attributes])
40
41
 
data/lib/mofa/cookbook.rb CHANGED
@@ -18,15 +18,16 @@ class Cookbook
18
18
  attr_accessor :mofa_yml
19
19
  attr_accessor :mofa_yml_local
20
20
  attr_accessor :token
21
-
22
- def self.create(cookbook_name_or_path, token)
21
+ attr_accessor :override_mofa_secrets
22
+
23
+ def self.create(cookbook_name_or_path, token, override_mofa_secrets = nil)
23
24
  cookbook = nil
24
25
  begin
25
26
  case
26
27
  when cookbook_name_or_path.match(/@/)
27
28
  fail "Did not find released Cookbook #{cookbook_name_or_path}!" unless ReleasedCookbook.exists?(cookbook_name_or_path)
28
29
 
29
- cookbook = ReleasedCookbook.new(cookbook_name_or_path)
30
+ cookbook = ReleasedCookbook.new(cookbook_name_or_path, override_mofa_secrets)
30
31
 
31
32
  else
32
33
  cookbook = SourceCookbook.new(cookbook_name_or_path)
@@ -14,11 +14,12 @@ class ReleasedCookbook < Cookbook
14
14
  RestClient.head(url)
15
15
  end
16
16
 
17
- def initialize(cookbook_name_or_path)
17
+ def initialize(cookbook_name_or_path, override_mofa_secrets = nil)
18
18
  super()
19
19
  nv = ReleasedCookbook.get_name_and_version(cookbook_name_or_path)
20
20
  @name = nv['name']
21
21
  @version = nv['version']
22
+ @override_mofa_secrets = override_mofa_secrets
22
23
  end
23
24
 
24
25
  # ------------- Interface Methods
@@ -62,6 +63,19 @@ class ReleasedCookbook < Cookbook
62
63
  FileUtils.cp_r "#{pkg_dir}/tmp/cookbooks/#{name}/recipes", pkg_dir
63
64
  end
64
65
 
66
+ # Sync in mofa_secrets
67
+ if override_mofa_secrets
68
+ run "rsync -avx #{override_mofa_secrets}/ #{pkg_dir}/tmp/cookbooks/#{name}/"
69
+ end
70
+
71
+ if File.exist?("#{pkg_dir}/tmp/cookbooks/#{name}/.mofa.yml")
72
+ FileUtils.cp "#{pkg_dir}/tmp/cookbooks/#{name}/.mofa.yml", pkg_dir
73
+ end
74
+
75
+ if File.exist?("#{pkg_dir}/tmp/cookbooks/#{name}/.mofa.local.yml")
76
+ FileUtils.cp "#{pkg_dir}/tmp/cookbooks/#{name}/.mofa.local.yml", pkg_dir
77
+ end
78
+
65
79
  run "cd #{pkg_dir}/tmp/;tar c#{tar_verbose}fz #{pkg_dir}/#{pkg_name}.new ."
66
80
  run "rm #{pkg_dir}/#{pkg_name}"
67
81
  run "mv #{pkg_dir}/#{pkg_name}.new #{pkg_dir}/#{pkg_name}"
@@ -69,11 +83,11 @@ class ReleasedCookbook < Cookbook
69
83
  end
70
84
 
71
85
  def load_mofa_yml
72
- @mofa_yml = MofaYml.load_from_file(".mofa.yml", self)
86
+ @mofa_yml = MofaYml.load_from_file("#{pkg_dir}/.mofa.yml", self)
73
87
  end
74
88
 
75
89
  def load_mofa_yml_local
76
- @mofa_yml_local = MofaYml.load_from_file(".mofa.local.yml", self)
90
+ @mofa_yml_local = MofaYml.load_from_file("#{pkg_dir}/.mofa.local.yml", self)
77
91
  end
78
92
 
79
93
  # ------------- /Interface Methods
data/lib/mofa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mofa
2
- VERSION = "0.3.30"
2
+ VERSION = "0.3.31"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.30
4
+ version: 0.3.31
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: