lex-ssh 0.1.0 → 0.2.1
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 +4 -4
- data/.github/workflows/ci.yml +16 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +48 -0
- data/CHANGELOG.md +21 -0
- data/CLAUDE.md +73 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +77 -0
- data/Rakefile +8 -0
- data/lex-ssh.gemspec +33 -0
- data/lib/legion/extensions/ssh/client.rb +27 -0
- data/lib/legion/extensions/ssh/helpers/connection.rb +33 -0
- data/lib/legion/extensions/ssh/runners/command.rb +35 -0
- data/lib/legion/extensions/ssh/runners/state.rb +30 -0
- data/lib/legion/extensions/ssh/version.rb +9 -0
- data/lib/legion/extensions/ssh.rb +15 -0
- metadata +44 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c32f876a224526e915ee6576cc5f15ac6c9d8cf5a1baf10d98a1eafaeaf867f8
|
|
4
|
+
data.tar.gz: ec41166e39202820862faa03e98fd738de9bfb55c549620d1a5bc662d30a0099
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5644622ea45307993be446f6e4ef78b12f020154651324ed7d4f3083919b5eb4acb8ace68f046ff24c508d0e5f12d70e4f0f11047a5ae42b2b03a2955b58f2d0
|
|
7
|
+
data.tar.gz: 07a56ceb7eed940b5eb743debbadf1fa102e4b373bb1d7c25edafc841f254071d59d3230ffb4bcdf8e2db65f266a563636b051264bf429d149eb3cd0a896c2e9
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ci:
|
|
9
|
+
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
|
+
|
|
11
|
+
release:
|
|
12
|
+
needs: ci
|
|
13
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
14
|
+
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
15
|
+
secrets:
|
|
16
|
+
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
6
|
+
Layout/LineLength:
|
|
7
|
+
Max: 160
|
|
8
|
+
|
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
+
EnforcedStyle: space
|
|
11
|
+
|
|
12
|
+
Layout/HashAlignment:
|
|
13
|
+
EnforcedHashRocketStyle: table
|
|
14
|
+
EnforcedColonStyle: table
|
|
15
|
+
|
|
16
|
+
Metrics/MethodLength:
|
|
17
|
+
Max: 50
|
|
18
|
+
|
|
19
|
+
Metrics/ClassLength:
|
|
20
|
+
Max: 1500
|
|
21
|
+
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Max: 1500
|
|
24
|
+
|
|
25
|
+
Metrics/BlockLength:
|
|
26
|
+
Max: 40
|
|
27
|
+
|
|
28
|
+
Metrics/AbcSize:
|
|
29
|
+
Max: 60
|
|
30
|
+
|
|
31
|
+
Metrics/CyclomaticComplexity:
|
|
32
|
+
Max: 15
|
|
33
|
+
|
|
34
|
+
Metrics/PerceivedComplexity:
|
|
35
|
+
Max: 17
|
|
36
|
+
|
|
37
|
+
Style/Documentation:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
Style/SymbolArray:
|
|
41
|
+
Enabled: true
|
|
42
|
+
|
|
43
|
+
Style/FrozenStringLiteralComment:
|
|
44
|
+
Enabled: true
|
|
45
|
+
EnforcedStyle: always
|
|
46
|
+
|
|
47
|
+
Naming/FileName:
|
|
48
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.1] - 2026-03-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Added `logger` gem as runtime dependency for Ruby 4.0 compatibility (removed from default gems)
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2026-03-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Standalone `Client` class including all runner modules
|
|
12
|
+
- `run_multiple` alias for `run_mulitple` (typo preserved for backward compat)
|
|
13
|
+
- Runner and client specs
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- `opts.key(:timeout)` -> `opts.key?(:timeout)` in Helpers::Connection (was calling wrong Hash method)
|
|
17
|
+
|
|
18
|
+
## [0.1.1] - 2026-03-13
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- Initial release
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# lex-ssh: SSH Remote Command Extension for LegionIO
|
|
2
|
+
|
|
3
|
+
**Repository Level 3 Documentation**
|
|
4
|
+
- **Parent**: `/Users/miverso2/rubymine/legion/extensions-other/CLAUDE.md`
|
|
5
|
+
- **Grandparent**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Legion Extension that executes remote SSH commands and controls remote server state. Provides runners for running arbitrary commands on remote hosts and triggering reboot/shutdown via Net::SSH.
|
|
10
|
+
|
|
11
|
+
**Version**: 0.2.0
|
|
12
|
+
**GitHub**: https://github.com/LegionIO/lex-ssh
|
|
13
|
+
**License**: MIT
|
|
14
|
+
|
|
15
|
+
## Architecture
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
Legion::Extensions::Ssh
|
|
19
|
+
├── Runners/
|
|
20
|
+
│ ├── Command # run, run_multiple - execute commands via SSH exec!
|
|
21
|
+
│ └── State # reboot, shutdown - system state via SSH
|
|
22
|
+
├── Helpers/
|
|
23
|
+
│ └── Connection # Net::SSH session factory (password, key_data, keys, passphrase auth)
|
|
24
|
+
└── Client # Standalone client class (includes all runners)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Key Files
|
|
28
|
+
|
|
29
|
+
| Path | Purpose |
|
|
30
|
+
|------|---------|
|
|
31
|
+
| `lib/legion/extensions/ssh.rb` | Entry point, extension registration |
|
|
32
|
+
| `lib/legion/extensions/ssh/runners/command.rb` | `run`, `run_multiple` (and `alias run_multiple run_mulitple` for typo compat) |
|
|
33
|
+
| `lib/legion/extensions/ssh/runners/state.rb` | `reboot(server:, user:, delay:)`, `shutdown(server:, user:, delay:)` |
|
|
34
|
+
| `lib/legion/extensions/ssh/helpers/connection.rb` | `session(server:, user:, **opts)` — Net::SSH.start wrapper |
|
|
35
|
+
| `lib/legion/extensions/ssh/client.rb` | Standalone `Client` class for use outside Legion framework |
|
|
36
|
+
|
|
37
|
+
## Runner Methods
|
|
38
|
+
|
|
39
|
+
**Command**
|
|
40
|
+
- `run(command:, server:, user: 'root')` — execute a single command, returns exit status + output
|
|
41
|
+
- `run_multiple(commands:, server:, user: 'root')` — execute multiple commands sequentially; also aliased as `run_mulitple` for backward compatibility
|
|
42
|
+
|
|
43
|
+
**State**
|
|
44
|
+
- `reboot(server:, user: 'root', delay: 0)` — reboot via `shutdown -r`; `delay` adds minutes
|
|
45
|
+
- `shutdown(server:, user: 'root', delay: 0)` — halt via `shutdown -h`; `delay` adds minutes
|
|
46
|
+
|
|
47
|
+
**Connection auth** (pass as task kwargs): `password:`, `key_data:`, `keys:`, `passphrase:`, `non_interactive:`, `timeout:` (default: 5s)
|
|
48
|
+
|
|
49
|
+
## Bug Fixes (v0.2.0)
|
|
50
|
+
|
|
51
|
+
- Fixed `opts.key(:timeout)` typo in `Helpers::Connection` — corrected to `opts.key?(:timeout)`. The old code always returned the key object (truthy) instead of checking presence, so `timeout` was never read from opts.
|
|
52
|
+
|
|
53
|
+
## Dependencies
|
|
54
|
+
|
|
55
|
+
| Gem | Purpose |
|
|
56
|
+
|-----|---------|
|
|
57
|
+
| `net-ssh` (>= 7.0) | SSH client |
|
|
58
|
+
| `ed25519` | Ed25519 key support |
|
|
59
|
+
| `bcrypt_pbkdf` | Bcrypt key derivation (OpenSSH private key format) |
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
9 specs total across `spec/legion/extensions/ssh/client_spec.rb`, `runners/command_spec.rb`, and `runners/state_spec.rb`.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
bundle install
|
|
67
|
+
bundle exec rspec
|
|
68
|
+
bundle exec rubocop
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
**Maintained By**: Matthew Iverson (@Esity)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Esity
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# lex-ssh
|
|
2
|
+
|
|
3
|
+
SSH remote command execution for [LegionIO](https://github.com/LegionIO/LegionIO). Run commands on remote servers and trigger reboot or shutdown via Net::SSH from within task chains.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gem install lex-ssh
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or add to your Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'lex-ssh'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Runners
|
|
18
|
+
|
|
19
|
+
### Command
|
|
20
|
+
|
|
21
|
+
| Method | Parameters | Description |
|
|
22
|
+
|--------|-----------|-------------|
|
|
23
|
+
| `run` | `command:`, `server:`, `user:` (default: `'root'`) | Execute a single command via SSH |
|
|
24
|
+
| `run_multiple` | `commands:`, `server:`, `user:` (default: `'root'`) | Execute multiple commands sequentially |
|
|
25
|
+
|
|
26
|
+
Returns `{ success:, results:, server: }` per command.
|
|
27
|
+
|
|
28
|
+
### State
|
|
29
|
+
|
|
30
|
+
| Method | Parameters | Description |
|
|
31
|
+
|--------|-----------|-------------|
|
|
32
|
+
| `reboot` | `server:`, `user:` (default: `'root'`), `delay:` (default: `0`) | Reboot the server via `shutdown -r` |
|
|
33
|
+
| `shutdown` | `server:`, `user:` (default: `'root'`), `delay:` (default: `0`) | Halt the server via `shutdown -h` |
|
|
34
|
+
|
|
35
|
+
`delay` is the number of minutes to wait (0 = immediate).
|
|
36
|
+
|
|
37
|
+
### Authentication
|
|
38
|
+
|
|
39
|
+
Pass authentication kwargs alongside other parameters:
|
|
40
|
+
|
|
41
|
+
| Parameter | Description |
|
|
42
|
+
|-----------|-------------|
|
|
43
|
+
| `password` | Password authentication |
|
|
44
|
+
| `key_data` | Inline key data |
|
|
45
|
+
| `keys` | Array of key file paths |
|
|
46
|
+
| `passphrase` | Key passphrase |
|
|
47
|
+
| `timeout` | Connection timeout in seconds (default: 5) |
|
|
48
|
+
|
|
49
|
+
## Standalone Client
|
|
50
|
+
|
|
51
|
+
Use `Legion::Extensions::Ssh::Client` outside the full LegionIO framework.
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
require 'legion/extensions/ssh'
|
|
55
|
+
client = Legion::Extensions::Ssh::Client.new(host: 'server.example.com', user: 'deploy', keys: ['~/.ssh/id_ed25519'])
|
|
56
|
+
result = client.run(command: 'uptime')
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
- Ruby >= 3.4
|
|
62
|
+
- [LegionIO](https://github.com/LegionIO/LegionIO) framework
|
|
63
|
+
- SSH server access
|
|
64
|
+
- `net-ssh` >= 7.0
|
|
65
|
+
- `ed25519` — Ed25519 key support
|
|
66
|
+
- `bcrypt_pbkdf` — OpenSSH private key format support
|
|
67
|
+
|
|
68
|
+
## Changelog
|
|
69
|
+
|
|
70
|
+
### v0.2.0
|
|
71
|
+
|
|
72
|
+
- Added standalone `Client` class.
|
|
73
|
+
- Fixed `opts.key?(:timeout)` in `Helpers::Connection` — the previous `opts.key(:timeout)` always returned a truthy key object, so the `timeout` option was never read from task kwargs.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
data/Rakefile
ADDED
data/lex-ssh.gemspec
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/legion/extensions/ssh/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'lex-ssh'
|
|
7
|
+
spec.version = Legion::Extensions::Ssh::VERSION
|
|
8
|
+
spec.authors = ['Esity']
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'LEX::SSH'
|
|
12
|
+
spec.description = 'LEX::SSH'
|
|
13
|
+
spec.homepage = 'https://github.com/LegionIO/lex-ssh'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 3.4'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-ssh'
|
|
19
|
+
spec.metadata['documentation_uri'] = 'https://github.com/LegionIO/lex-ssh'
|
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-ssh'
|
|
21
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/LegionIO/lex-ssh/issues'
|
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
spec.require_paths = ['lib']
|
|
28
|
+
|
|
29
|
+
spec.add_dependency 'bcrypt_pbkdf'
|
|
30
|
+
spec.add_dependency 'ed25519'
|
|
31
|
+
spec.add_dependency 'logger'
|
|
32
|
+
spec.add_dependency 'net-ssh', '>= 7.0'
|
|
33
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/connection'
|
|
4
|
+
require_relative 'runners/command'
|
|
5
|
+
require_relative 'runners/state'
|
|
6
|
+
|
|
7
|
+
module Legion
|
|
8
|
+
module Extensions
|
|
9
|
+
module Ssh
|
|
10
|
+
class Client
|
|
11
|
+
include Helpers::Connection
|
|
12
|
+
include Runners::Command
|
|
13
|
+
include Runners::State
|
|
14
|
+
|
|
15
|
+
attr_reader :opts
|
|
16
|
+
|
|
17
|
+
def initialize(server:, user: 'root', **extra)
|
|
18
|
+
@opts = { server: server, user: user, **extra }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def session(**override)
|
|
22
|
+
super(**@opts, **override)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'net/ssh'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Ssh
|
|
8
|
+
module Helpers
|
|
9
|
+
module Connection
|
|
10
|
+
def session(server:, user: 'root', **opts)
|
|
11
|
+
hash = {}
|
|
12
|
+
if opts.key? :password
|
|
13
|
+
hash[:password] = opts[:password]
|
|
14
|
+
elsif opts.key? :key_data
|
|
15
|
+
hash[:key_data] = opts[:key_data]
|
|
16
|
+
elsif opts.key? :keys
|
|
17
|
+
hash[:keys] = opts[:keys]
|
|
18
|
+
end
|
|
19
|
+
hash[:non_interactive] = opts.key?(:non_interactive) ? opts[:non_interactive] : true
|
|
20
|
+
hash[:passphrase] = opts[:passphrase] if opts.key? :passphrase
|
|
21
|
+
hash[:timeout] = opts.key?(:timeout) ? opts[:timeout] : 5
|
|
22
|
+
|
|
23
|
+
Net::SSH.start(server, user, **hash)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def detect_os(session)
|
|
27
|
+
session.exec!('lsb_release -a')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Ssh
|
|
6
|
+
module Runners
|
|
7
|
+
module Command
|
|
8
|
+
include Legion::Extensions::Ssh::Helpers::Connection
|
|
9
|
+
|
|
10
|
+
def run(command:, server:, user: 'root', **)
|
|
11
|
+
session = session(server: server, user: user, **)
|
|
12
|
+
results = session.exec!(command)
|
|
13
|
+
{ success: results.exitstatus.zero?, results: results, server: server }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run_mulitple(commands:, server:, user: 'root', **)
|
|
17
|
+
session = session(server: server, user: user, **)
|
|
18
|
+
final_results = []
|
|
19
|
+
|
|
20
|
+
commands.each do |command|
|
|
21
|
+
results = session.exec!(command)
|
|
22
|
+
final_results.push({ success: results.exitstatus.zero?, results: results })
|
|
23
|
+
end
|
|
24
|
+
final_results
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
alias run_multiple run_mulitple
|
|
28
|
+
|
|
29
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
30
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Ssh
|
|
6
|
+
module Runners
|
|
7
|
+
module State
|
|
8
|
+
include Legion::Extensions::Ssh::Helpers::Connection
|
|
9
|
+
|
|
10
|
+
def reboot(server:, user: 'root', delay: 0, **)
|
|
11
|
+
session = session(server: server, user: user, **)
|
|
12
|
+
command = delay.zero? ? 'shutdown -r now' : "shutdown -r +#{delay}"
|
|
13
|
+
results = session.exec!(command)
|
|
14
|
+
{ success: results.exitstatus.zero?, results: results, server: server, delay: delay }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def shutdown(server:, user: 'root', delay: 0, **)
|
|
18
|
+
session = session(server: server, user: user, **)
|
|
19
|
+
command = delay.zero? ? 'shutdown -h now' : "shutdown -h +#{delay}"
|
|
20
|
+
results = session.exec!(command)
|
|
21
|
+
{ success: results.exitstatus.zero?, results: results, server: server, delay: delay }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
25
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/ssh/version'
|
|
4
|
+
require 'legion/extensions/ssh/helpers/connection'
|
|
5
|
+
require 'legion/extensions/ssh/runners/command'
|
|
6
|
+
require 'legion/extensions/ssh/runners/state'
|
|
7
|
+
require 'legion/extensions/ssh/client'
|
|
8
|
+
|
|
9
|
+
module Legion
|
|
10
|
+
module Extensions
|
|
11
|
+
module Ssh
|
|
12
|
+
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-ssh
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bcrypt_pbkdf
|
|
@@ -39,7 +38,7 @@ dependencies:
|
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: logger
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - ">="
|
|
@@ -52,23 +51,54 @@ dependencies:
|
|
|
52
51
|
- - ">="
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: net-ssh
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '7.0'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '7.0'
|
|
55
68
|
description: LEX::SSH
|
|
56
69
|
email:
|
|
57
70
|
- matthewdiverson@gmail.com
|
|
58
71
|
executables: []
|
|
59
72
|
extensions: []
|
|
60
73
|
extra_rdoc_files: []
|
|
61
|
-
files:
|
|
62
|
-
|
|
74
|
+
files:
|
|
75
|
+
- ".github/workflows/ci.yml"
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- ".rubocop.yml"
|
|
79
|
+
- CHANGELOG.md
|
|
80
|
+
- CLAUDE.md
|
|
81
|
+
- Gemfile
|
|
82
|
+
- LICENSE.txt
|
|
83
|
+
- README.md
|
|
84
|
+
- Rakefile
|
|
85
|
+
- lex-ssh.gemspec
|
|
86
|
+
- lib/legion/extensions/ssh.rb
|
|
87
|
+
- lib/legion/extensions/ssh/client.rb
|
|
88
|
+
- lib/legion/extensions/ssh/helpers/connection.rb
|
|
89
|
+
- lib/legion/extensions/ssh/runners/command.rb
|
|
90
|
+
- lib/legion/extensions/ssh/runners/state.rb
|
|
91
|
+
- lib/legion/extensions/ssh/version.rb
|
|
92
|
+
homepage: https://github.com/LegionIO/lex-ssh
|
|
63
93
|
licenses:
|
|
64
94
|
- MIT
|
|
65
95
|
metadata:
|
|
66
|
-
homepage_uri: https://
|
|
67
|
-
source_code_uri: https://
|
|
68
|
-
documentation_uri: https://
|
|
69
|
-
changelog_uri: https://
|
|
70
|
-
bug_tracker_uri: https://
|
|
71
|
-
|
|
96
|
+
homepage_uri: https://github.com/LegionIO/lex-ssh
|
|
97
|
+
source_code_uri: https://github.com/LegionIO/lex-ssh
|
|
98
|
+
documentation_uri: https://github.com/LegionIO/lex-ssh
|
|
99
|
+
changelog_uri: https://github.com/LegionIO/lex-ssh
|
|
100
|
+
bug_tracker_uri: https://github.com/LegionIO/lex-ssh/issues
|
|
101
|
+
rubygems_mfa_required: 'true'
|
|
72
102
|
rdoc_options: []
|
|
73
103
|
require_paths:
|
|
74
104
|
- lib
|
|
@@ -76,15 +106,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
76
106
|
requirements:
|
|
77
107
|
- - ">="
|
|
78
108
|
- !ruby/object:Gem::Version
|
|
79
|
-
version:
|
|
109
|
+
version: '3.4'
|
|
80
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
111
|
requirements:
|
|
82
112
|
- - ">="
|
|
83
113
|
- !ruby/object:Gem::Version
|
|
84
114
|
version: '0'
|
|
85
115
|
requirements: []
|
|
86
|
-
rubygems_version: 3.
|
|
87
|
-
signing_key:
|
|
116
|
+
rubygems_version: 3.6.9
|
|
88
117
|
specification_version: 4
|
|
89
118
|
summary: LEX::SSH
|
|
90
119
|
test_files: []
|