cronicle 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/README.md +8 -0
- data/lib/cronicle/cli.rb +10 -3
- data/lib/cronicle/client.rb +4 -0
- data/lib/cronicle/ext/sshkit_ext.rb +1 -1
- data/lib/cronicle/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33a76397600f6b7c1dc022459638a2fa110e8fb
|
4
|
+
data.tar.gz: be4c62e61702f516a1c0fa1092d4db59d63eb9e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db4e5c51f3742cbb08a974fb9beac13aa9507a6a05d72827891dfa22b277968602a7ea48d8c4a684df2f44b3e391be3789a2cc3077bdf4f32badc6f4091a693e
|
7
|
+
data.tar.gz: 897f0d4f90395b938e06be90bed3cc8cd5df90cfaf5e1fe57dcf057d7818503c5ef2c19c56706bc21f72a0708de99039d4f55610bb37557e43944a8d10810f80
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -35,9 +35,11 @@ Options:
|
|
35
35
|
-h, [--hosts=HOSTS] # Hosts definition file
|
36
36
|
-r, [--target-roles=one two three] # Target host role list
|
37
37
|
-p, [--sudo-password=SUDO-PASSWORD] # Sudo password
|
38
|
+
[--ssh-user=SSH-USER] # SSH login user
|
38
39
|
[--ask-pass], [--no-ask-pass] # Ask sudo password
|
39
40
|
[--dry-run], [--no-dry-run] # Do not actually change
|
40
41
|
-c, [--ssh-config=SSH-CONFIG] # OpenSSH configuration file
|
42
|
+
# Default: ~/.ssh/config
|
41
43
|
[--ssh-options=SSH-OPTIONS] # SSH options (JSON)
|
42
44
|
[--connection-timeout=N] # SSH connection timeout
|
43
45
|
[--concurrency=N] # SSH concurrency
|
@@ -78,6 +80,12 @@ $ ssh your_hostname 'cat /var/lib/cronicle/libexec/ec2-user/my_job'
|
|
78
80
|
puts "hello"
|
79
81
|
```
|
80
82
|
|
83
|
+
## Environment variables
|
84
|
+
|
85
|
+
* CRONICLE_SSH_USER
|
86
|
+
* CRONICLE_SSH_OPTIONS
|
87
|
+
* CRONICLE_SSH_CONFIG
|
88
|
+
|
81
89
|
## Jobfile example
|
82
90
|
|
83
91
|
```ruby
|
data/lib/cronicle/cli.rb
CHANGED
@@ -5,10 +5,11 @@ class Cronicle::CLI < Thor
|
|
5
5
|
class_option 'hosts', :aliases => '-h', :desc => 'Hosts definition file'
|
6
6
|
class_option 'target-roles', :aliases => '-r', :desc => 'Target host role list', :type => :array
|
7
7
|
class_option 'sudo-password', :aliases => '-p', :desc => 'Sudo password'
|
8
|
+
class_option 'ssh-user', :desc => 'SSH login user', :default => ENV['CRONICLE_SSH_USER']
|
8
9
|
class_option 'ask-pass', :desc => 'Ask sudo password', :type => :boolean, :default => false
|
9
10
|
class_option 'dry-run', :desc => 'Do not actually change', :type => :boolean, :default => false
|
10
|
-
class_option 'ssh-config', :aliases => '-c', :desc => 'OpenSSH configuration file', :default =>
|
11
|
-
class_option 'ssh-options', :desc => 'SSH options (JSON)', :default =>
|
11
|
+
class_option 'ssh-config', :aliases => '-c', :desc => 'OpenSSH configuration file', :default => (ENV['CRONICLE_SSH_CONFIG'] || '~/.ssh/config')
|
12
|
+
class_option 'ssh-options', :desc => 'SSH options (JSON)', :default => ENV['CRONICLE_SSH_OPTIONS']
|
12
13
|
class_option 'connection-timeout', :desc => 'SSH connection timeout', :type => :numeric, :default => nil
|
13
14
|
class_option 'concurrency', :desc => 'SSH concurrency', :type => :numeric, :default => Cronicle::Client::DEFAULTS[:concurrency]
|
14
15
|
class_option 'libexec', :desc => 'Cronicle libexec path', :default => Cronicle::Client::DEFAULTS[:libexec]
|
@@ -82,6 +83,7 @@ class Cronicle::CLI < Thor
|
|
82
83
|
def client_options
|
83
84
|
client_opts = {
|
84
85
|
:sudo_password => options['sudo-password'],
|
86
|
+
:ssh_user => options['ssh-user'],
|
85
87
|
:concurrency => options['concurrency'],
|
86
88
|
:libexec => options['libexec'],
|
87
89
|
:dry_run => options['dry-run'],
|
@@ -112,7 +114,12 @@ class Cronicle::CLI < Thor
|
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
115
|
-
|
117
|
+
ssh_config = options['ssh-config']
|
118
|
+
|
119
|
+
if ssh_config
|
120
|
+
ssh_config = File.expand_path(ssh_config)
|
121
|
+
ssh_options[:config] = ssh_config if File.exist?(ssh_config)
|
122
|
+
end
|
116
123
|
|
117
124
|
SSHKit::Backend::Netssh.configure do |ssh|
|
118
125
|
ssh.connection_timeout = conn_timeout if conn_timeout
|
data/lib/cronicle/client.rb
CHANGED
@@ -25,6 +25,10 @@ class Cronicle::Client
|
|
25
25
|
end
|
26
26
|
|
27
27
|
parallel_each(jobs_by_host) do |host, jobs_by_user|
|
28
|
+
if @options[:ssh_user] and host !~ /@/
|
29
|
+
host = @options[:ssh_user] + '@' + host
|
30
|
+
end
|
31
|
+
|
28
32
|
run_driver(host) do |driver|
|
29
33
|
jobs_by_user.each do |user, jobs|
|
30
34
|
driver.execute_job(user, jobs)
|
@@ -7,7 +7,7 @@ class SSHKit::Backend::Netssh
|
|
7
7
|
def sudo(command, *args)
|
8
8
|
opts = args.last.kind_of?(Hash) ? args.pop : {}
|
9
9
|
|
10
|
-
retval = with_sudo_password(host.options[:sudo_password]) do
|
10
|
+
retval = with_sudo_password(host.options[:sudo_password] || '') do
|
11
11
|
with_sudo = [:sudo, '-p', SUDO_PROMPT, '-S']
|
12
12
|
with_sudo << '-u' << opts[:user] if opts[:user]
|
13
13
|
with_sudo.concat(args)
|
data/lib/cronicle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronicle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sourcify
|