4 ms·
If you like this - Fabric is awesome. https://www.fabfile.org/ https://www.fabfile.org/ Use python over SSH. Super fast to begin, if you can ssh into the serv
by tony 6y ago
If you like this - Fabric is awesome.
https://www.fabfile.org/ https://www.fabfile.org/
Use python over SSH. Super fast to begin, if you can ssh into the server, you can run the equivalent of shell commands (subprocess calls in python) remotely. With python, you can abstract and reuse, with the scriptability of bash, but higher level niceties of the language, libraries and toolchain (linting, formatting, autocompletion, imports).
Can it pull the latest version of your app, build it on your server? Yep. Restart daemons? Update libraries (npm, python, etc)? Update system packages? All work fine.
Can it configure a vanilla server from scratch? Yes, it's helpful to bring in a higher level reusable library like https://github.com/fabtools/fabtools https://github.com/fabtools/fabtools helps with that.
When does it hit limitations? More complex orchestration where you have multiple servers (and variations of them) with configuration to talk to each other over networks. Eventually you get to the kind of setup where having a tool like Ansible / Salt / Puppet / etc. makes sense.
For a basic PHP/python/ruby/node site that's just running on a single cloud server? A declarative config manager would be overkill for me.
- linuxftw 6y ago> Use python over SSH. Super fast to begin, if you can ssh into the server, you can run the equivalent of shell commands (subprocess calls in python) remotely. This literally describes ansible. In fact, ansible one-ups this because you can specify raw commands if python is not installed remotely [1]. Ansible provides lots of modules, you don't have to use any of them. I have plenty of 1-off ansible playbooks that I don't care about idempotency that are just a bunch of 'cmd' statements. It's a very flexible tool. 1: https://docs.ansible.com/ansible/latest/modules/raw_module.html https://docs.ansible.com/ansible/latest/modules/raw_module.h...
- maxmalysh 6y agoNot really. Ansible is a complex DSL based on YAML. Fabric is really simple and uses real Python.
- llama052 6y agoCan't say I've ever really thought of YAML as complex. Especially when the Ansible modules are translating things so you can just define the action you want to take, and each module is very well documented.
- dnautics 6y agoEmbedding python in yaml has a ton of gotchas for cases where string processing doesn't quite line up with the way yaml wants things. Variable interpolation is also a real mess.
- geerlingguy 6y agoTypically the recommendation is to write your own python plugin/filter/test if you find yourself writing a lot of python in yaml, that way the yaml stays sane and readable, and just has some light Jinja.
- Izkata 6y ago> In fact, ansible one-ups this because you can specify raw commands if python is not installed remotely GP's description of fabric is slightly wrong - it's not python over ssh, it's ssh in python. You only need python locally, fabric runs shell commands remotely.
- muhmud 6y agoThis is my main issue with Ansible: as soon as you run a single raw shell command, haven't the main benefits of Ansible just disappeared? And wouldn't it be likely that you'll probably need to do this pretty regularly? Some of the modules seem pretty pointless as well, like the synchronize files one; why not just use rsync directly? And while you're at it, just SSH to servers from shell! Sure, you would need something similar to the inventory, but that wouldn't be too difficult to come up with... I think investing time in building a library of idempotent shell scripts instead is the way to go personally.
- curryst 6y agoYou can have your shell commands be idempotent. For instance, I have a number of places where I trigger a shell command only if an Ansible managed file changes. It's only non-idempotent if the shell command runs every time, and the shell command itself isn't idempotent. The reason for some of the "pointless" modules is that they integrate into Ansible better. I.e. for synchronize, you can run Ansible with the "--check" option, which won't change anything, but will report back what would be changed if you actually executed it. Running rsync in a shell command doesn't have that option because Ansible has no idea what that command does. My bigger issue with Ansible is that the YAML is annoying. The looping behavior is frustrating, variable precedence is weird, IDE autocompletion is generally lacking. I wish they had designed a sane way to just write Python code.
- strig 6y agoI really hate that fabric got rid of roles in the new version. I want to be able to still do "fab task -R prod".
- maxmalysh 6y agoTry fab-classic: https://github.com/ploxiln/fab-classic https://github.com/ploxiln/fab-classic We decided that migrating to Fabric 2.0 doesn't worth it.
- darkteflon 6y agoWhat’s the status of the fabtools project? It supports up to Ubuntu 14.04 (as in, 2014) and has very little commit activity. Without fabtools, fabric operates at a much lower level of abstraction than Ansible.