fulmar 1.7.5 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fulmar/infrastructure/service/ssh_config_service.rb +21 -9
- data/lib/fulmar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d20b737b6af1583286258dc2f016a9e513efb35
|
4
|
+
data.tar.gz: 9b422f9364ec4c4ce227734bf0fb01efe5faf2ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f86764318b194d621a9259ed8b08b39bc647a3a3a7c03e9ea7721829220da70e95d2a36e3f063920890bd39e1b4a8c5a61b45c1bef3ab3a7b0d024122bb46004
|
7
|
+
data.tar.gz: 55a2081e314963646e7c22d4db62d4118b001f3ea6a7643c6dae3364a29fe0a72a4b050840829bfcbdb4bb5fbc5b4eb361f05bdbb971990229333e13344e0a49
|
@@ -7,6 +7,15 @@ module Fulmar
|
|
7
7
|
class SSHConfigService
|
8
8
|
CONFIG_FILE = "#{ENV['HOME']}/.ssh/config"
|
9
9
|
KNOWN_HOST_FILE = "#{ENV['HOME']}/.ssh/known_hosts"
|
10
|
+
CONFIG_MAP = {
|
11
|
+
hostname: 'Hostname',
|
12
|
+
port: 'Port',
|
13
|
+
user: 'User',
|
14
|
+
proxycommand: 'ProxyCommand',
|
15
|
+
checkhostip: 'CheckHostIP',
|
16
|
+
stricthostkeychecking: 'StrictHostKeyChecking',
|
17
|
+
identityfile: 'IdentityFile'
|
18
|
+
}
|
10
19
|
|
11
20
|
def initialize(config)
|
12
21
|
@config = config
|
@@ -21,7 +30,7 @@ module Fulmar
|
|
21
30
|
if host_exists?(data[:hostname])
|
22
31
|
puts "Host #{data[:hostname]} exists, skipping..." if @config[:debug]
|
23
32
|
else
|
24
|
-
add_host(data[:hostname], data)
|
33
|
+
add_host(data[:hostname], data[:ssh_config])
|
25
34
|
end
|
26
35
|
end
|
27
36
|
end
|
@@ -30,7 +39,7 @@ module Fulmar
|
|
30
39
|
input_file = File.open(KNOWN_HOST_FILE, 'r')
|
31
40
|
output_file = File.open(KNOWN_HOST_FILE + '.temp', 'w')
|
32
41
|
while (line = input_file.gets)
|
33
|
-
output_file.puts(line) unless /^\[?#{hostname.gsub('.', '\\.')}(?:\]:\d+)? /.match(line)
|
42
|
+
output_file.puts(line) unless /^\[?#{hostname.gsub('.', '\\.')}(?:\]:\d+)?[ ,]/.match(line)
|
34
43
|
end
|
35
44
|
input_file.close
|
36
45
|
output_file.close
|
@@ -51,17 +60,20 @@ module Fulmar
|
|
51
60
|
end
|
52
61
|
|
53
62
|
# Adds a host to the ssh config file
|
54
|
-
def add_host(hostname,
|
55
|
-
puts "Adding host #{
|
63
|
+
def add_host(hostname, ssh_config = {})
|
64
|
+
puts "Adding host #{hostname}..." if @config[:debug]
|
56
65
|
config_file = File.open(CONFIG_FILE, 'a')
|
57
66
|
|
67
|
+
unless ssh_config[:identityfile].blank? or ssh_config[:identityfile][0, 1] == '/'
|
68
|
+
ssh_config[:identityfile] = @config.base_path + '/' + ssh_config[:identityfile]
|
69
|
+
end
|
70
|
+
|
58
71
|
config_file.puts "\n" # Add some space between this and the second last entry
|
59
72
|
config_file.puts "# Automatically generated by fulmar for project #{@config.project.description}"
|
60
73
|
config_file.puts "Host #{hostname}"
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
config_file.puts " ProxyCommand #{host_config[:config_proxycommand]}" unless host_config[:config_proxycommand].blank?
|
74
|
+
CONFIG_MAP.keys.each do |key|
|
75
|
+
config_file.puts " #{CONFIG_MAP[key]} #{ssh_config[key]}" unless ssh_config[key].blank?
|
76
|
+
end
|
65
77
|
|
66
78
|
config_file.close
|
67
79
|
end
|
@@ -69,7 +81,7 @@ module Fulmar
|
|
69
81
|
private
|
70
82
|
|
71
83
|
def config_valid?(host_config)
|
72
|
-
(!host_config[:hostname].blank? && !host_config[:
|
84
|
+
(!host_config[:hostname].blank? && !host_config[:ssh_config].nil?)
|
73
85
|
end
|
74
86
|
end
|
75
87
|
end
|
data/lib/fulmar/version.rb
CHANGED