Skip to content

vxe/le-guin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

le-guin

Hastily written library originally intended to implement Brendan Gregg’s USE method as ansible playbooks. Now evolving into a libray for calling ansible from clojure.

https://circleci.com/gh/vxe/le-guin.svg?style=svg

Overview

Installation

Usage

playbook execution from the repl

  • the function le-guin takes a path to playbook and executes in on the host(s) defined by calling generate-inventory for example, using an included example
    le-guin.core>  (generate-inventory ["myhost2.domain.com" "myhost2.domain.com"])
    nil
    le-guin.core> (le-guin "./playbooks/use-method.yml")
        

‘runbook’ language for specifying shell commands sequences

Very often all that is needed is to run a sequence of shell commands on a host or set of hosts. For this case yaml is cumbersome. Runbooks are plaintext CSVs files which consist of:

  1. natural language description of the command
  2. shell command
check the date, date +%F
check the uptime, uptime

putting the above in a file called troublshoot-host, execution would be performed as follows

le-guin.core>  (generate-inventory ["myhost.domain.com"])
nil
le-guin.core>  (execute-runbook "troubleshoot-host")

PLAY [troubleshoot-host] *******************************************************

TASK [Gathering Facts] *********************************************************
ok: [myhost.domain.com]

TASK [check the date------> date +%F] ******************************************
changed: [myhost.domain.com]

TASK [debug] *******************************************************************
ok: [myhost.domain.com] => {
    "ZRXCNAXZTQ.stdout_lines": [
        "2018-08-12"
    ]
}

TASK [check the uptime------> uptime] ******************************************
changed: [myhost.domain.com]

TASK [debug] *******************************************************************
ok: [myhost.domain.com] => {
    "CLNJFRRVXC.stdout_lines": [
        " 09:57:09 up 86 days,  6:12,  1 user,  load average: 1.97, 1.72, 1.57"
    ]
}

PLAY RECAP *********************************************************************
myhost.domain.com : ok=5    changed=2    unreachable=0    failed=0   

Extending

  • [ ] expose more ansible functionality
  • [X] generate playbooks on the fly
  • [ ] find a less hacky when to generate the inventory, perhaps using this
  • [ ] compojure and ring are included in the project, ‘ansible as a service’ is a possibility

About

Run ansible playbooks from the repl

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published