puppet-pssh 0.1.2 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/puppet-pssh.rb +24 -6
  2. metadata +1 -1
data/lib/puppet-pssh.rb CHANGED
@@ -7,7 +7,7 @@ require 'colored'
7
7
 
8
8
  module PuppetPSSH
9
9
 
10
- VERSION = "0.1.2"
10
+ VERSION = "0.2"
11
11
 
12
12
  if !defined? Log or Log.nil?
13
13
  Log = Logger.new($stdout)
@@ -86,8 +86,16 @@ module PuppetPSSH
86
86
  option "--[no-]host-key-verify", :flag, "Verify SSH host key", :default => true
87
87
  option "--threads", "THREADS", "Use up to N threads", :default => 40
88
88
  option "--cached-hostlist", :flag, "Use cached hostlist", :default => false
89
+ option ["-s","--splay"], :flag, "Wait a random piece of time", :default => false
90
+ option ["-e","--extra-args"], "EXTRA_ARGS", "parallel-ssh extra arguments"
91
+ option ["-l","--user"], "USER", "SSH user (parallel-ssh -l argument)", :default => 'root'
89
92
 
90
93
  def execute
94
+
95
+ Log.info "SSH user: #{user}"
96
+ Log.info "Node log output path: #{node_output_path}"
97
+ Log.info "Max threads: #{threads}"
98
+
91
99
  unless File.exist?(pssh_path)
92
100
  Log.error "parallel-ssh command not found in #{pssh_path}."
93
101
  Log.error "Install it or use --pssh-path argument."
@@ -129,7 +137,7 @@ module PuppetPSSH
129
137
  unless nameserver.nil?
130
138
  address = res.query(i).answer.first.address rescue next
131
139
  end
132
- f.puts "#{address} root"
140
+ f.puts "#{address}"
133
141
  end
134
142
  end
135
143
  else
@@ -137,16 +145,26 @@ module PuppetPSSH
137
145
  end
138
146
 
139
147
  $stdout.sync = true
140
- command = "sleep `echo $[ ( $RANDOM % 30 ) + 1 ]`;" + command_list.join(' ')
141
- Log.info "Node log output path: #{node_output_path}"
148
+ if splay?
149
+ Log.info "Using 30s splay"
150
+ command = "sleep `echo $[ ( $RANDOM % 30 ) + 1 ]`;" + command_list.join(' ')
151
+ else
152
+ command = command_list.join(' ')
153
+ end
142
154
  Log.info "Running command '#{command}' with parallel-ssh..."
143
- Log.info "Max threads: #{threads}"
144
155
  ssh_opts = ''
156
+ extra_opts = "-l #{user} "
157
+ if extra_args
158
+ Log.info "Extra pssh arguments: #{extra_args}"
159
+ extra_opts << extra_args
160
+ end
145
161
  unless host_key_verify?
146
162
  Log.warn 'Disabled host key verification'
147
163
  ssh_opts = '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
148
164
  end
149
- system "#{pssh_path} -p #{threads} -o #{node_output_path} -t 300 -h #{hostlist_path} -x '#{ssh_opts}' " + "'#{command} 2>&1'"
165
+ full_cmd = "#{pssh_path} #{extra_opts} -p #{threads} -o #{node_output_path} -t 300 -h #{hostlist_path} -x '#{ssh_opts}' " + "'#{command} 2>&1'"
166
+ Log.debug full_cmd
167
+ system full_cmd
150
168
  end
151
169
  end
152
170
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-pssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: