[emacs-berlin] Literate dev-ops

Arne Brasseur arne.brasseur at gmail.com
Fri May 6 14:11:09 UTC 2016


I came across this video of someone using org-mode to do "devops" stuff
(i.e. server maintenance).

It's really good, I'm already using a lot of the ideas in it.

https://www.youtube.com/watch?v=dljNabciEGg

The main idea is that org + org-babel + tramp == solid gold.

- Use tramp syntax to link to common configuration files on the server, so
you can open them instantly with C-c C-o
- Make sh code snippets with :dir set to a tramp string and you can have it
execute on the server. You can also configure this for a group of snippets
under the same heading with a :dir: property.
- When these snippets grow into their own thing you can "tangle" them to a
file, including a remote file

e.g. this is an example of part of my org file that I'm using to deploy new
versions of a Clojure app.

  :PROPERTIES:
  :dir: ~/LambdaIsland/app
  :END:

  #+NAME: current-version
  #+BEGIN_SRC sh
    VERSION=`head -1 project.clj | sed
's/.defproject.lambdaisland."\(.*\)"/\1/'`
    echo $VERSION
  #+END_SRC

  #+NAME: build-new-uberjar
  #+BEGIN_SRC sh :var VERSION=current-version :dir /
ssh:root at lambdaisland.com|sudo:web at lambdaisland.com:/var/web/app :results
scalar
    set -e
    git checkout v$VERSION
    /opt/bin/lein uberjar 2>&1
    mkdir /var/web/deploys/v$VERSION
    cp target/lambdaisland.jar /var/web/deploys/v$VERSION
    cp -r resources/public /var/web/deploys/v$VERSION
  #+END_SRC


-- 
@plexus <https://twitter.com/plexus> | arnebrasseur.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailb.org/pipermail/emacs-berlin/attachments/20160506/bf86a32d/attachment.html>


More information about the emacs-berlin mailing list