mofa 0.5.6 → 0.5.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5efe371265582362dd1c4fe8dd07eda8edb0f30d
4
- data.tar.gz: 54b293d5773089c5af94a3fb583f834dabf76882
3
+ metadata.gz: 26a01d8f8e60b159944a3318a2c76af1d144f808
4
+ data.tar.gz: 4b63d4e1e82902e3e7a08180e1fb696ef5d13617
5
5
  SHA512:
6
- metadata.gz: c23a3c1066f0e4265ed3150bf57b556c8876dfe3d53aab4391c5bcd6c37a51437ec48530c6e3ba808725d61ba179a290c1b851d3888c65c3527777ce6eec8a3f
7
- data.tar.gz: 22481687e449b1c8d25c4f2180c7dd7c91bcda22a147f80fe3626b497dd6198525ed830d86528319f2b8e97773e07a1f8c9e688fcd92d8ca7214e60e0d7a4df2
6
+ metadata.gz: 274f7add3f89c0953f5ba57e4a62dbf93752a40a09b61fa204ea286477da47e7e10815e664106f0a8b28e2baa0aa00fb4a07d1fca56ce13e554e43e91fd4d9c1
7
+ data.tar.gz: 288a9edfaaa95596b4328e5f4dc647777754229438b4a649835fb874c6b7955e6b91aaee0b66565767bab59ad8293c155f0c87533b0fcbd8c924d7831930ef1d
@@ -54,6 +54,7 @@ module Mofa
54
54
 
55
55
  desc 'upload <cookbook>', 'package & upload cookbook into binrepo'
56
56
  method_option :binrepo_host, :type => :string
57
+ method_option :binrepo_sshport, :type => :string
57
58
  method_option :binrepo_ssh_user, :type => :string
58
59
  method_option :binrepo_ssh_keyfile, :type => :string
59
60
 
@@ -68,7 +69,8 @@ module Mofa
68
69
  cmd = UploadCmd.new(token, cookbook)
69
70
 
70
71
  cmd.prepare
71
- cmd.execute
72
+ # FIXME: bring in the ssh-port in a different way
73
+ cmd.execute(22)
72
74
  cmd.cleanup
73
75
  end
74
76
 
@@ -21,7 +21,7 @@ class MofaCmd
21
21
  end
22
22
 
23
23
  # @abstract
24
- def execute(_sshport)
24
+ def execute(_ssh_port)
25
25
  raise RuntimeError, "must be implemented"
26
26
  end
27
27
 
@@ -14,7 +14,7 @@ class ProvisionCmd < MofaCmd
14
14
  cookbook.prepare
15
15
  end
16
16
 
17
- def execute(sshport = 22)
17
+ def execute(ssh_port = 22)
18
18
  cookbook.execute
19
19
 
20
20
  hostlist.retrieve
@@ -30,7 +30,7 @@ class ProvisionCmd < MofaCmd
30
30
 
31
31
  puts "Hostlist after runlist filtering: #{hostlist.list.inspect}"
32
32
 
33
- exit_code = run_chef_solo_on_hosts(sshport)
33
+ exit_code = run_chef_solo_on_hosts(ssh_port)
34
34
 
35
35
  exit_code
36
36
  end
@@ -56,12 +56,12 @@ class ProvisionCmd < MofaCmd
56
56
  host_available
57
57
  end
58
58
 
59
- def prepare_host(hostname, host_index, solo_dir)
59
+ def prepare_host(hostname, host_index, solo_dir, ssh_port = Mofa::Config.config['ssh_port'] )
60
60
  puts
61
61
  puts '----------------------------------------------------------------------'
62
62
  puts "Chef-Solo on Host #{hostname} (#{host_index}/#{hostlist.list.length})"
63
63
  puts '----------------------------------------------------------------------'
64
- Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: Mofa::Config.config['ssh_port'], use_agent: false, verbose: :error) do |ssh|
64
+ Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: ssh_port, use_agent: false, verbose: :error) do |ssh|
65
65
  puts "Remotely creating solo_dir \"#{solo_dir}\" on host #{hostname}"
66
66
  # remotely create the temp folder
67
67
  out = ssh_exec!(ssh, "[ -d #{solo_dir} ] || mkdir #{solo_dir}")
@@ -121,13 +121,13 @@ class ProvisionCmd < MofaCmd
121
121
  end
122
122
  end
123
123
 
124
- def run_chef_solo_on_hosts(sshport = Mofa::Config.config['ssh_port'])
124
+ def run_chef_solo_on_hosts(ssh_port = Mofa::Config.config['ssh_port'])
125
125
  time = Time.new
126
126
  # Create a temp working dir on the target host
127
127
  solo_dir = '/var/tmp/' + time.strftime('%Y-%m-%d_%H%M%S')
128
128
  puts
129
129
  puts 'Chef-Solo Run started at ' + time.strftime('%Y-%m-%d %H:%M:%S')
130
- puts "Will use ssh_user #{Mofa::Config.config['ssh_user']}, ssh_port #{sshport} and ssh_key_file #{Mofa::Config.config['ssh_keyfile']}"
130
+ puts "Will use ssh_user #{Mofa::Config.config['ssh_user']}, ssh_port #{ssh_port} and ssh_key_file #{Mofa::Config.config['ssh_keyfile']}"
131
131
  at_least_one_chef_solo_run_failed = false
132
132
  chef_solo_runs = {}
133
133
  host_index = 0
@@ -144,9 +144,9 @@ class ProvisionCmd < MofaCmd
144
144
  end
145
145
  end
146
146
 
147
- prepare_host(hostname, host_index, solo_dir)
147
+ prepare_host(hostname, host_index, solo_dir, ssh_port)
148
148
 
149
- Net::SFTP.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: sshport, use_agent: false, verbose: :error) do |sftp|
149
+ Net::SFTP.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: ssh_port, use_agent: false, verbose: :error) do |sftp|
150
150
  # remotely creating solo.rb
151
151
  create_solo_rb(sftp, hostname, solo_dir)
152
152
 
@@ -164,7 +164,7 @@ class ProvisionCmd < MofaCmd
164
164
  # Do it -> Execute the chef-solo run!
165
165
  begin
166
166
  begin
167
- Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: sshport, use_agent: false, verbose: :error) do |ssh|
167
+ Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: ssh_port, use_agent: false, verbose: :error) do |ssh|
168
168
  puts "Remotely unpacking Cookbook Package #{cookbook.pkg_name}... "
169
169
  ssh.exec!("cd #{solo_dir}; tar xvfz #{cookbook.pkg_name}") do |_ch, _stream, line|
170
170
  puts line if Mofa::CLI.option_debug
@@ -181,13 +181,13 @@ class ProvisionCmd < MofaCmd
181
181
  raise e
182
182
  end
183
183
  begin
184
- Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: sshport, use_agent: false, verbose: :error) do |ssh|
184
+ Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: ssh_port, use_agent: false, verbose: :error) do |ssh|
185
185
  puts "Remotely running chef-solo -c #{solo_dir}/solo.rb -j #{solo_dir}/node.json"
186
186
  chef_run_exit_code = 0
187
187
  ssh.exec!("sudo chef-solo -c #{solo_dir}/solo.rb -j #{solo_dir}/node.json") do |_ch, _stream, line|
188
188
  puts line if Mofa::CLI.option_verbose || Mofa::CLI.option_debug
189
189
  log_file.write(line)
190
- chef_run_exit_code = 1 if line =~ /Chef run process exited unsuccessfully/
190
+ chef_run_exit_code = 1 if line =~ /Chef run process exited unsuccessfully/ || line =~ /chef-solo: command not found/
191
191
  end
192
192
  raise 'Chef run process exited unsuccessfully' if chef_run_exit_code != 0
193
193
  chef_solo_runs[hostname].store('status', 'SUCCESS')
@@ -207,7 +207,7 @@ class ProvisionCmd < MofaCmd
207
207
  log_file.write('chef-solo run: FAIL')
208
208
  puts "ERRORS detected while provisioning #{hostname} (#{e.message})."
209
209
  end
210
- Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: sshport, use_agent: false, verbose: :error) do |ssh|
210
+ Net::SSH.start(hostname, Mofa::Config.config['ssh_user'], keys: [Mofa::Config.config['ssh_keyfile']], port: ssh_port, use_agent: false, verbose: :error) do |ssh|
211
211
  snapshot_or_release = cookbook.is_a?(SourceCookbook) ? 'snapshot' : 'release'
212
212
  out = ssh_exec!(ssh, "sudo chown -R #{Mofa::Config.config['ssh_user']}.#{Mofa::Config.config['ssh_user']} #{solo_dir}")
213
213
  puts "ERROR (#{out[0]}): #{out[2]}" if out[0] != 0
@@ -65,16 +65,20 @@ class ReleasedCookbook < Cookbook
65
65
 
66
66
  # Sync in mofa_secrets
67
67
  if override_mofa_secrets
68
- if File.directory?("#{override_mofa_secrets}/#{name}/cookbooks")
69
- run "rsync -vr #{override_mofa_secrets}/#{name}/cookbooks/ #{pkg_dir}/tmp/cookbooks/"
70
- if File.file?("#{override_mofa_secrets}/#{name}/.mofa.local.yml")
71
- FileUtils.cp "#{override_mofa_secrets}/#{name}/.mofa.local.yml", "#{pkg_dir}/tmp/cookbooks/#{name}/"
72
- end
73
- if File.file?("#{override_mofa_secrets}/#{name}/.mofa.yml")
74
- FileUtils.cp "#{override_mofa_secrets}/#{name}/.mofa.yml", "#{pkg_dir}/tmp/cookbooks/#{name}/"
68
+ if File.directory?("#{override_mofa_secrets}/#{name}")
69
+ if File.directory?("#{override_mofa_secrets}/#{name}/cookbooks")
70
+ run "rsync -vr #{override_mofa_secrets}/#{name}/cookbooks/ #{pkg_dir}/tmp/cookbooks/"
71
+ if File.file?("#{override_mofa_secrets}/#{name}/.mofa.local.yml")
72
+ FileUtils.cp "#{override_mofa_secrets}/#{name}/.mofa.local.yml", "#{pkg_dir}/tmp/cookbooks/#{name}/"
73
+ end
74
+ if File.file?("#{override_mofa_secrets}/#{name}/.mofa.yml")
75
+ FileUtils.cp "#{override_mofa_secrets}/#{name}/.mofa.yml", "#{pkg_dir}/tmp/cookbooks/#{name}/"
76
+ end
77
+ else
78
+ run "rsync -vr #{override_mofa_secrets}/#{name}/ #{pkg_dir}/tmp/cookbooks/#{name}/"
75
79
  end
76
80
  else
77
- run "rsync -vr #{override_mofa_secrets}/#{name}/ #{pkg_dir}/tmp/cookbooks/#{name}/"
81
+ say "Skipping non-existant mofa-secrets folder #{override_mofa_secrets}/#{name}"
78
82
  end
79
83
  end
80
84
 
@@ -15,7 +15,7 @@ class UploadCmd < MofaCmd
15
15
  cookbook.prepare
16
16
  end
17
17
 
18
- def execute(_sshport)
18
+ def execute(_ssh_port)
19
19
  cookbook.execute
20
20
  upload_cookbook_pkg
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module Mofa
2
- VERSION = '0.5.6'
2
+ VERSION = '0.5.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Birk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-09 00:00:00.000000000 Z
11
+ date: 2019-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  version: '0'
247
247
  requirements: []
248
248
  rubyforge_project: mofa
249
- rubygems_version: 2.6.11
249
+ rubygems_version: 2.5.2.3
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: a lightweight remote chef-solo runner