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.
- add latest version to you project, start a repl
- the function
le-guin
takes a path to playbook and executes in on the host(s) defined by callinggenerate-inventory
for example, using an included examplele-guin.core> (generate-inventory ["myhost2.domain.com" "myhost2.domain.com"]) nil le-guin.core> (le-guin "./playbooks/use-method.yml")
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:
- natural language description of the command
- 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
- [ ] 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