Re-mote operations using SSH and Re-gent
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
dev
src/re_mote
test/re_mote/test/repl
.gitignore
.travis.yml
Dockerfile
Dockerize.md
LICENSE-2.0.txt
README.md
project.clj

README.md

Intro

Re-mote is a REPL driven environment for performing remote operations using SSH and Re-gent.

It is a part of the Re-ops project that offers a live coding environment for configuration management.

Follow the official docs for more information on how to install and use.

Build Status

Basic Usage

re-mote-gif

Overview

We define pipelines (plain functions), the results of operations are threaded through:

(defn listing [hs]
  (run (ls hs "/" "-la") | (pretty)))

An operation is a part of a protocol extending Hosts:

; re-mote.repl.base
(defrecord Hosts [auth hosts]
  Shell
  (ls [this target flags]
    [this (run-hosts this (script ("ls" ~target ~flags)))])

It returns the hosts operated upon and the result, thus enabling pipelines.

We can persist results to Elasticsearch and view them in Kibana/Grafana:

(defn #^{:category :stats} cpu-persist
  "CPU usage and idle stats collection and persistence"
  [hs]
  (run (cpu hs) | (enrich "cpu") | (persist)))

Schedule them:

; every 5 seconds, check re-mote.repl.schedule for more options
(defn stats-jobs [hs]
  (watch :ram (seconds 5) (fn [] (ram-persist hs)))
  (watch :net (seconds 5) (fn [] (net-persist hs)))
  (watch :cpu (seconds 5) (fn [] (cpu-persist hs)))
  )

The Reloaded workflow is used to re-eval functions on the go, stop restart and refresh can be used for bigger changes:

; we want to stop all components
user=> (stop)
; usually re-eval a single function is enough, refresh is re-load all!
user=> (refresh)
; back into action again, no restart!
user=> (go)

Copyright and license

Copyright [2018] [Ronen Narkis]

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.