
Bashible: An Ansible-inspired deployment/automation tool written in Bash DSL - vitro
https://github.com/mig1984/bashible
======
klysm
Portability is pretty important in the deployment/automation space and it's
hard to beat bash in that capacity. It just sucks that bash sucks so much.

~~~
yjftsjthsd-h
Ansible already is pretty portable/flexible on target systems (the joys of
being agentless and working mostly over SSH). You tend to need python and
sometimes some specific modules (python-apt, for instance) on the target, but
that's hardly a burden.

~~~
gautamdivgi
I think the Ansible modules can be executable binaries as well. I have heard
of modules written in go.

~~~
yjftsjthsd-h
Having written Ansible modules in POSIX sh, I can assure you that this is
absolutely the case:) Internally, Ansible modules are just normal executables
that expect a very specific set of parameters and return a very specific JSON-
encoded format. I believe there's also a newer pure-Python API, but I ignored
it after realizing that it was much easier to just use the old one. (... and,
of course, I really enjoyed the notion of writing a module in shell)

------
travbrack
I’m surprised there’s no explanation of why Bash was chosen for this.

~~~
_frkl
I'd imagine it's because it's available everywhere (even openwrt routers and
those things), and it's easier to get away with not having to use sudo
(depending on the task you are doing, of course). With Ansible, you almost
always need python installed on the target host. Which, in 95% of cases is not
a problem. It's not ideal to install a system package just because you want to
do some provisioning (there are ways around that, but it gets hacky pretty
quick...).

I haven't looked at this yet, but I really like the idea. Always wanted to
have something like this for a few special cases. And if it's well designed,
it could be a nice, lightweight and portable solution to do server
provisioning, development project setups, use in Docker builds, etc.

~~~
yjftsjthsd-h
> it's available everywhere (even openwrt routers and those things)

BASH itself? Or a Bourne-family shell? I thought most embedded systems were
shipping busybox's ash as /bin/sh

~~~
travbrack
Most *nix server and cloud nodes use bash for the shell. You're right about
embedded systems but they're not usually the target platform for a config
management system like this one or Ansible.

~~~
yjftsjthsd-h
Yeah, I was mostly thrown by the reference to openwrt. I'm sure most/all _GNU_
/Linux systems ship BASH.

~~~
shakna
Debian ship's dash for /bin/sh doesn't it?

~~~
detaro
but also ships bash for interactive use, so #!/bin/bash will just work, which
you should be doing anyways in scripts that want bash.

~~~
mdaniel
If you use `env` instead, it'll pick up more recent versions of bash available
on the path, such as the one installed by homebrew

    
    
        #!/usr/bin/env bash

------
cfgmaster2
How about this? Show HN: Posixcube, a shell script automation framework
alternative to Ansible (github.com)
[https://news.ycombinator.com/item?id=13378852](https://news.ycombinator.com/item?id=13378852)

------
AzzieElbab
Full circle DevOps. Nice :)

------
zenlot
No more DSLs for deployment/config management tasks please. Too many already.

~~~
nightfly
I'd rather more DSLs than more things with complex logic encoded into YAML.

~~~
yjftsjthsd-h
I'd argue that Ansible _is_ using a DSL, just one that happens to be expressed
in YAML. I mean, it has loops, conditionals, various forms of subroutines
(roles, plays that can be included)... I don't think that using a YAML format
rather than being C-shaped makes it any less a DSL.

~~~
swiley
At that point you should at least use something elegant like s-expressions.

There are so many things I hate about ansible.

~~~
bogomipz
Could you elaborate on how and why s-expression solve address the issues of
yaml-based DSL? Thanks

~~~
nightfly
S-expressions have keywords, and don't require commas between list elements.
That alone goes a _long_ways towards making s-expression based languages way
more readable/writable than a similar datastructure encoded in something like
JSON or YAML.

Here's an example of a JSON coded query taken from a PuppetDB tutorial
(PuppetDB uses a very lispy query language):

    
    
      ["and",
        ["=", "type", "User"],
        ["=", "title", "nick"]]
    

And the same code as you could write it in native s-expressions:

    
    
      (and
        (= :type "user")
        (= :title "nick"))
    

...and one way you could encode it in yaml...

    
    
      - and:                                                                                                                      
          - =:                                                                                                                    
              - type                                                                                                              
              - user                                                                                                              
          - title:                                                                                                                
              - title                                                                                                             
              - nick

~~~
411111111111111
why are you encapsulating everything in lists for your yaml example? you arent
in your other examples either?

    
    
        - filters:
            - operant: =
              type: user
            - operant: =
              title: nick
    

if the module author wants to, he could even remove the secondary list because
its the same operator, making this

    
    
          - filters:
            - operant: =
              type: user
              title: nick
    

thats just as readable as your other examples imo. yaml doesnt have to be an
unreadable mess. its just possible to make bad apis, which remains true for
yaml just as for any other format.

------
decasia
Are there any other Ansible alternatives that avoid the whole YAML mess?

~~~
divbzero
Idempotency and reusability are what I like about Ansible. YAML is a
dependency I could do without.

Maybe what we need is a set of CLI commands that mirror Ansible modules in
performing idempotent operations through SSH and APIs.

~~~
dnautics
Is ansible really reusible? We had an ansible deploy for bringing up MySQL
database. I stopped using the codebase and came back to it months later; and I
spent two days trying to get it to work (it was an unholy combination of local
and community yaml) and eventually just rewrote the damn thing as a bare
sequence on literal MySQL (in 20 minutes I might add) and disabled
verification - definitely worst practices - to get it to deploy.

Maybe the problem is that I'm not an ansible professional.

~~~
rmrfrmrf
Some of that could be due to versioning... Ansible's releases always have
breaking changes, so you can get into trouble if your setup is vastly
different from when the playbooks were created. I think this is part of the
point of a dedicated control machine, but unfortunately the documentation
(last I checked) seems to neglect the importance of it.

Along the same lines, there are also .cfg files and roles that can live
outside the root directory.

I've been able to get decent reusability out of roles, but that's mostly
because I can live with my servers all being deployed the same way (e.g. they
all have the same nginx config with minimal customization points and share the
same certificates).

~~~
folmar
> the point of a dedicated control machine

Usually virtualenv + requirements.txt + all configuration inside playbook
repository should make for a painless experience without one (save for speed).

------
_frkl
Exciting, very nice idea, I'll keep my eyes on this. It happened more than
once that I had need for something like this, and I stewed over how to
implement it for quite a while now. Haven't looked at it in detail yet, but
from a first glance it looks well thought through.

------
seemslegit
Bash should be recognized as the tech equivalent of asbestos.

~~~
kohtatsu
Y'all just have bias against the string system.

Writing decent code in bash is just as possible as any other language.

I stick to POSIX sh but same difference.

~~~
unixhero
Why POSIX sh? Bash is everywhere. I once in my career had access to and needed
jobs performed on a mainframe with AIX running. It had bash, it had ruby, it
had day, it had fish shell. I couldn't and can't understand why people insist
on asceticism (Korn shell, POSIX sh) when nicer options are available.

~~~
kohtatsu
Eh, I simply don't need bash.

Every few dozen scripts or so I'll change the shebang to bash to have more
than 1 array, but other than that I seldom pine anything that it has to offer.
I believe it's a bloated mess along with most GNU utils, so avoiding it is
partially out of spite, but I wouldn't impair my code to do so.

------
nicey
NIH If you are looking for a DSL that uses shell: [https://www.cdi.st/cdist-
why.html](https://www.cdi.st/cdist-why.html)

It's already mature and used in production at various places/datacenters.

~~~
akavel
_" cdist is written in Python"_ \- that's a significant difference

~~~
pas
In my experience, Python is just as brittle, because it just as much lacks
static checking. (Though of course mypy helps with the basics, and there ought
to be a test or dry-run mode in every "devops" system, but I have no idea what
cdist does.)

~~~
akavel
Uh, so, my thought behind that comment was that writing in bash has an
advantage over Python, as no extra runtime environment is required in case of
bash... sorry for not being clear enough in the comment, I now see I wrote it
too vaguely...

