cheftacular 2.0.7 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3685f590daa72f5455eb81a3c70148ed502e2260
4
- data.tar.gz: dde96719a915f11f60fadfa4b7959d65c8d14600
3
+ metadata.gz: dab07a85b0c1c0d66ad4c40632410460e12cb085
4
+ data.tar.gz: 0ea6a7fd5c2cc3ec3599b96dae67aa6124db2645
5
5
  SHA512:
6
- metadata.gz: 8f591cb44744dca95f25434c5f8bcfc3ad6b92521cdcedd287c6a23907c6774eebfd206da369feb0951ae7eaf0365f1631becc81d324870f8b8844ae5855ad94
7
- data.tar.gz: 0816925f0b578665398228834f802f975b4d3349f7939b19d55f529fd8857100873f43b27b112bea5db7f0e197405138fd4ef0a9b8e31540890d5b1bb898f300
6
+ metadata.gz: 30c885801868c04eb02fc1679457c35ad755b785c74a906ac44e98fc60c9e01e27af59d01561204fb9e156dadd4d5c66953edfa46d78e44141ea751d29c8fda6
7
+ data.tar.gz: 4aa577cba2465797c2a1991868e54e5559cb92bbab65dca30ac544a637543252d6f72fceebfaa7f1caaa1934cfde2be1613ddbb5243922fa3e264ea05fad70a1
@@ -36,8 +36,8 @@ class Cheftacular
36
36
 
37
37
  puts("Beginning log fetch run for #{ n.name } (#{ n.public_ipaddress }) on role #{ options['role'] }") unless options['quiet']
38
38
 
39
- if getter.get_current_stack.nil?
40
- start_log_role_map( name, n.public_ipaddress, getter.get_current_role_map['log_location'], options, locs, cheftacular, passwords)
39
+ if has_run_list_in_role_map?(n.run_list, cheftacular['role_maps'])
40
+ start_log_role_map( n.name, n.public_ipaddress, getter.get_current_role_map(n.run_list)['log_location'], options, locs, cheftacular, passwords)
41
41
  else
42
42
  self.send("start_log_fetch_#{ getter.get_current_stack }", n.name, n.public_ipaddress, n.run_list, options, locs, cheftacular, passwords)
43
43
  end
@@ -26,9 +26,8 @@ class Cheftacular
26
26
  nodes.each do |n|
27
27
  puts("Beginning tail run for #{ n.name } (#{ n.public_ipaddress }) on role #{ @options['role'] }") unless @options['quiet']
28
28
 
29
-
30
- if @config['getter'].get_current_stack.nil?
31
- start_tail_role_map( n.public_ipaddress )
29
+ if @config['dummy_sshkit'].has_run_list_in_role_map?(n.run_list, @config['cheftacular']['role_maps'])
30
+ start_tail_role_map( n.public_ipaddress, n.run_list )
32
31
  else
33
32
  self.send("start_tail_#{ @config['getter'].get_current_stack }", n.public_ipaddress, n.run_list )
34
33
  end
@@ -37,8 +36,8 @@ class Cheftacular
37
36
 
38
37
  private
39
38
 
40
- def start_tail_role_map ip_address
41
- log_loc = @config['getter'].get_current_role_map['log_location'].split(',').first
39
+ def start_tail_role_map ip_address, run_list
40
+ log_loc = @config['getter'].get_current_role_map(run_list)['log_location'].split(',').first.gsub('|current_repo_location|', "#{ @config['cheftacular']['base_file_path'] }/#{ @options['repository'] }/current")
42
41
 
43
42
  `ssh -oStrictHostKeyChecking=no -tt deploy@#{ ip_address } "#{ @config['helper'].sudo(ip_address) } tail -f #{ log_loc }" > /dev/tty`
44
43
  end
@@ -103,9 +103,9 @@ class Cheftacular
103
103
  end
104
104
  end
105
105
 
106
- def get_current_role_map ret=""
106
+ def get_current_role_map run_list, ret={}
107
107
  @config['cheftacular']['role_maps'].each_pair do |main_role, role_hash|
108
- ret = role_hash if role_hash['role_name'] == @options['role']
108
+ ret = role_hash if run_list.include?("role[#{ role_hash['role_name'] }]")
109
109
  end
110
110
 
111
111
  ret
@@ -1,5 +1,5 @@
1
1
  class Cheftacular
2
2
  #major_version.minor_version.bugfixes
3
- VERSION = "2.0.7"
3
+ VERSION = "2.0.8"
4
4
  RUBY_VERSION = "2.2.2"
5
5
  end
@@ -5,23 +5,24 @@ module SSHKit
5
5
  log_loc, timestamp = set_log_loc_and_timestamp(locs)
6
6
  log_cmnd, log_lines = get_log_command_and_lines(options)
7
7
 
8
- if !test("[ -e #{ target_log_loc }]") #true if file exists
9
- puts "#{ name } (#{ ip_address }) does not have a log file for #{ options['env'] } at the moment..."
8
+
9
+ puts "Fetching log file(s) for #{ name } (#{ ip_address }). Outputting to #{ log_loc } with timestamp: #{ timestamp }"
10
10
 
11
- else
12
- puts "Fetching log file(s) for #{ name } (#{ ip_address }). Outputting to #{ log_loc }/#{ name }-#{ options['role'] }-log-#{ timestamp }.txt"
11
+ target_log_loc.split(',').each do |parsed_log_loc|
12
+ parsed_log_loc = parsed_log_loc.gsub('|current_repo_location|', "#{ cheftacular['base_file_path'] }/#{ options['repository'] }/current")
13
13
 
14
- target_log_loc.split(',').each do |parsed_log_loc|
15
- parsed_log_loc = parsed_log_loc.gsub('|current_repo_location|', "#{ cheftacular['base_file_path'] }/#{ options['repository'] }/current")
14
+ if parsed_log_loc != '/var/log/syslog' && !test("[ -e #{ parsed_log_loc }]") #true if file exists ()
15
+ puts "#{ name } (#{ ip_address }) does not have a #{ parsed_log_loc } log file for #{ options['env'] } at the moment..."
16
+ else
16
17
  if log_lines.nil?
17
18
  out << sudo_capture(passwords[ip_address], log_cmnd.to_sym, parsed_log_loc)
18
19
 
19
20
  else
20
21
  out << sudo_capture(passwords[ip_address], log_cmnd.to_sym, log_lines, parsed_log_loc)
21
22
  end
22
- end
23
23
 
24
- ::File.open("#{ log_loc }/#{ name }-#{ options['role'] }-log-#{ timestamp }.txt", "w") { |f| f.write(out.scrub_pretty_text) } unless options['no_logs']
24
+ ::File.open("#{ log_loc }/#{ name }-#{ parsed_log_loc.split('/').last.split('.').first }-#{ timestamp }.txt", "w") { |f| f.write(out.scrub_pretty_text) } unless options['no_logs']
25
+ end
25
26
  end
26
27
  end
27
28
 
@@ -8,6 +8,14 @@ module SSHKit
8
8
  def sudo_capture pass, *args
9
9
  capture :echo, pass, :|, :sudo, '-S', *args
10
10
  end
11
+
12
+ def has_run_list_in_role_map? run_list, role_map_hash
13
+ role_map_hash.each_value do |map_hash|
14
+ return true if run_list.include?("role[#{ map_hash['role_name'] }]")
15
+ end
16
+
17
+ false
18
+ end
11
19
  end
12
20
  end
13
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheftacular
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Alridge