yaowst v0.1.1
Yet another OpsWorks ssh Tool (YaOWsT)
A faster way to open a ssh connection to an OpsWorks instance
Table of Contents
Installation
$ npm install yaowst -g
$ yaowst
YaOWsT run the first time
Creating the config file and backup the existing OpenSSH config file
YaOWsT init complete, now you can edit the config file "~/.yaowst"Usage
$ yaowst --help
Yet another OpsWorks ssh Tool
Usage: yaowst [options]
options
-c, --config-file The location of the YaOWsT config file
-o, --ssh-config-file The location of the OpenSSH config file
-s, --save-mode 24/7 or all, 24/7 store no instances that started by auto scalingExamples
Shell Commands
$ yaowst
Get running OpsWorks instances and store the hosts to the OpenSSH config file
The OpenSSH config file successful updated
4 Entries updated (instances and base config)
$ ssh opsworks_one_1
$ scp example.txt opsworks_one_1:/tmp/Config
{
"sshOptions": {
"StrictHostKeyChecking": "no",
"UserKnownHostsFile": "~/.ssh/opsworks_known_hosts",
"IdentitiesOnly": "yes",
"User": "yaowst"
},
"opsWorks": {
"accessKeyId": "MAIN_KEY",
"secretAccessKey": "MAIN_SECRET",
"region": "OPSWORKS_REGION"
},
"stacks": [
{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"sshOptions": {
"IdentityFile": "~/.ssh/opsworks_yaowst.pem"
}
},
{
"sshOptions": {
"IdentityFile": "~/.ssh/opsworks_yaowst_1.pem"
},
"layers": [
{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"alias": "opsworks_one-"
},
{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"alias": "opsworks_two-"
}
]
},
{
"accessKeyId": "ANOTHER_KEY",
"secretAccessKey": "ANOTHER_SECRET",
"sshOptions": {
"IdentityFile": "~/.ssh/opsworks_yaowst_2.pem"
},
"layers": [
{
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"alias": "opsworks_three-"
}
]
}
]
}Config
After the first run, YaOWsT create a config file with basic settings.
The location is ~/.yaowst and has the permission 0600.
Base Config
{
"opsWorks": {
"region": "us-east-1"
},
"sshOptions": {
"StrictHostKeyChecking": "no",
"UserKnownHostsFile": "/dev/null",
"IdentitiesOnly": "yes"
},
"stacks": []
}Config with all possible settings
{
"opsWorks": {
"accessKeyId": "<Access Key ID>",
"secretAccessKey": "<Secret Access Key>",
"region": "<OpsWorks Region>"
},
"sshConfigFile": {
"file": null,
"saveMode": "24/7"
},
"sshOptions": {
"StrictHostKeyChecking": "no",
"UserKnownHostsFile": "/dev/null",
"IdentitiesOnly": "yes"
},
"stacks": [
{
"id": "<OpsWorks Stack ID>",
"accessKeyId": "<Access Key ID>",
"secretAccessKey": "<Secret Access Key>",
"region": "<OpsWorks Region>",
"prefix": "aws-",
"sshOptions": {},
"layers": [
{
"id": "<OpsWorks Layer ID>",
"alias": "layer-1-",
"prefix": "aws-layer-1-",
"sshOptions": {}
}
]
}
]
}Config description
{object} opsWorksthe default IAM credentials for all stacks{string} accessKeyIdthe access key id{string} secretAccessKeythe secret access key{string} regionthe default OpsWork region
{object} sshConfigFileOpenSSH config file settings{string|null} fileifnullthen YaOWsT use~/.ssh/configas OpenSSH config file else YaOWsT use this path{string} saveMode24/7orall,24/7store only instances that run 24/7 (no time- or load-based instances)
{object} sshOptionssee the OpenSSH client config manual{object[]} stacksthis array has all stacks{string} idthe OpsWorks Stack ID, if you use the layers option then you can skip this option{string} [accessKeyId]overwrite the default access key id{string} [secretAccessKey]overwrite the default secret access key{string} [region]overwrite the default OpsWorks region{string} [prefix]add this prefix to all instances in this stack, only if the layer as no alias{object} [sshOptions]overwrite existing options and merge the another options{object} [layers]if this option not exists then YaOWsT check all instances in this stack{string} idthe OpsWorks layer ID{string} [alias]if the instance name has numbers then YaOWsT replace eventing before the number, if the instance name has no number then the alias value will added as prefix to the instance name{string} [prefix]add this prefix to all instances in this stack, only if the layer as no alias{object} [sshOptions]overwrite existing options and merge the another options
API
Class: Yaowst
new Yaowst(options, callback)
options
{string} configFileThe location of the YaOWsT config file{object} sshConfigFile{string} fileThe location of the OpenSSH config file{string} saveMode24/7orall,24/7store only instances that run 24/7
yaowst.firstInit(option, callback)
Create the YaOWsT config file and backup the existing OpenSSH config file
option
{boolean} forceoverwrite the YaOWsT config file
yaowst.save(option, callback)
Store the instances in the OpenSSH config file
option
{string} saveMode24/7orall,24/7store no instances that started by auto scaling
Tests
The tests are with and without AWS API request, per default the tests are without API requests.
Test with API Requests
For the Tests with API Requests you must create as new OpsWorks Stack and copy some files.
The OpsWorks Stack
The Stack structure
- The Stack need 2 Layers
- in the first Layer one instance is online
- in the second Layer two instances are online
The Files
Copy Files and add your IAM credentials and Ids, the files are in resources/test/
configOpsWorksLayer.json.default->configOpsWorksLayer.jsonconfigOpsWorksStack.json.default->configOpsWorksStack.jsonconfigYaowst.json.default->configYaowst.json
Single test
npm testCross node version testing
Run tests for all relevant versions of io.js/node.js
Install nvm and all relevant versions
$ git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
$ echo "source ~/.nvm/nvm.sh" >> ~/.bashrc
$ nvm install 0.10
$ nvm install 0.12
$ nvm install 4
$ nvm install 6Run the test
./resources/tools/cross-test.shCross OS and cross node version testing
For the cross os tests you can use vagrant-yaowst
Uninstall
If you uninstall yaowst then you must also delete the yaowst section form the ssh config file, everything between ## yaowst begin ## and ## yaowst end ##