Name: train
Owner: Chef Partners
Description: Transport Interface to unify communication over SSH, WinRM, and friends.
Created: 2018-04-12 14:24:06.0
Updated: 2018-04-12 14:24:08.0
Pushed: 2018-04-25 08:13:40.0
Homepage: null
Size: 700
Language: Ruby
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Train lets you talk to your local or remote operating systems and APIs with a unified interface.
It allows you to:
run_command
file
os
Train supports:
Local
ire 'train'
n = Train.create('local')
SSH
ire 'train'
n = Train.create('ssh',
st: '1.2.3.4', port: 22, user: 'root', key_files: '/vagrant')
If you don't specify the key_files
and password
options, SSH agent authentication will be attempted. For example:
ire 'train'
n = Train.create('ssh', host: '1.2.3.4', port: 22, user: 'root')
WinRM
ire 'train'
n = Train.create('winrm',
st: '1.2.3.4', user: 'Administrator', password: '...', ssl: true, self_signed: true)
Docker
ire 'train'
n = Train.create('docker', host: 'container_id...')
AWS
To use AWS API authentication, setup an AWS client profile to store the Access Key ID and Secret Access Key.
ire 'train'
n = Train.create('aws', region: 'us-east-2', profile: 'my-profile')
You may also use the standard AWS CLI environment variables, AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
and AWS_REGION
.
ire 'train'
n = Train.create('aws')
To get a list of available options for a plugin:
Train.options('ssh')
This will provide all configuration options:
ost => { :required => true},
ort => { :default => 22, :required => true},
ser => { :default => "root", :required => true},
eys => { :default => nil},
assword => { :default => nil},
.
art or reuse a connection
= train.connection
n a command on Linux/Unix/Mac
conn.run_command('whoami').stdout
t OS info
conn.os[:family]
conn.os[:release]
cess files
conn.file('/proc/version').content
cess specific API client functionality
client = train.connection.aws_client(Aws::EC2::Client)
ec2_client.describe_instances
ose the connection
.close
We perform unit
, integration
and windows
tests.
unit
tests ensure the intended behaviour of the implementationintegration
tests run against VMs and docker containerswindows
tests that run on appveyor for windows integration testsle exec ruby -W -Ilib:test/unit test/unit/extras/stat_test.rb
n windows tests
le exec rake test:windows
n single tests
le exec ruby -I .\test\windows\ .\test\windows\local_test.rb
Train is heavily based on the work of:
by Adam Jacob, Chef Software Inc. and a great community of contributors
We also want to thank halo who did a great contribution by handing over the train
gem name.
| Author: | Dominik Richter (drichter@chef.io)
| Author: | Christoph Hartmann (chartmann@chef.io)
| Copyright: | Copyright (c) 2015 Chef Software Inc.
| Copyright: | Copyright (c) 2015 Vulcano Security GmbH.
| License: | Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.