4 ms·
Pretty much. I've been using Ansible with Docker Compose since 2015. I can set up a full server with all of the bells and whistles in about 20 lines of invento
by nickjj 4y ago
Pretty much.
I've been using Ansible with Docker Compose since 2015. I can set up a full server with all of the bells and whistles in about 20 lines of inventory configuration. Behind the scenes there's a bunch of portable and generic roles that work for baseline "server level" components. I've done this now for dozens of companies, it's a tried and true model with an easy way to customize things if needed.
Ansible sets up the server, Docker Compose runs the apps (stand alone `docker compose` commands, not the Ansible module) and git is used to deploy everything.
- asar 4y agoIs there a repo you could share for such a setup? Currently looking at similar options for self hosting web apps on cloud providers.
- nickjj 4y agoNot for all of the Ansible bits but for the Docker Compose apps I do have up to date repos for Flask, Rails, Django, Node and Phoenix[0]. All of those example apps are deployable to production (and can be used in development) once your server has Docker installed. [0]: https://github.com/nickjj?tab=repositories&q=docker-*-example&type=&language=&sort= https://github.com/nickjj?tab=repositories&q=docker-*-exampl...
- cheshire_cat 4y agoDo your examples support zero downtime deployment and zero downtime rollback? If so, could you please point to the relevant sections? I couldn't figure it out from the READMEs.
- nickjj 4y ago> Do your examples support zero downtime deployment and zero downtime rollback? Those examples are for running your app, not deploying it. Zero downtime is also a loaded term. MRSK isn't zero downtime in a way that's commonly described as zero downtime. MRSK uses Traefik's built in functionality to queue requests so if your back-end is down it won't respond with a 502. Instead the user will see a busy mouse cursor until your back-end is up. A user will be able to automatically "resume" their request after your app reloaded which is nice, it saves them from having to see a 502 and manually reload the browser but if you have a Rails app that takes 27 seconds to boot up then the user will be waiting for 27 seconds with no feedback. You could make a case the UX there is worse than a user explicitly seeing a custom 502 page that mentions to reload in a bit. That's much different than a true zero downtime rolling update that something like Kubernetes will give you, or if you rolled your own solution to do it without Kubernetes. I don't know if MRSK will handle that, given the direction it's going it's quite possible DHH will implement that behavior in which case that would be very useful. Rollback is also tricky once you start introducing database migrations. I personally always roll forward.
- AlexITC 4y agoFor the Ansible stuff, I have these scripts: https://github.com/wiringbits/scala-webapp-template/tree/master/infra https://github.com/wiringbits/scala-webapp-template/tree/mas... While these are used to deploy a Scala backend and a Scala.js frontend, I have adapted them many times to work with other backends and js frontends, the logic is the same, the build scripts is what needs to be updated.
- jillesvangurp 4y agoIt's my go to solution as well. If I can't get a reasonable docker capable host out of the box (which you'd get in AWS and gcloud), use ansible to create one. I had to do this in Telekom cloud last year and dusted off some ansible stuff I had from previous projects and got it done. I sometimes combine it with using packer for building vm images. That avoids repeated overhead of having to run ansible, which can be a bit slow. For application deployment, I use simple scripts that restart docker compose via shh that we can run from Github actions. Ansible is overkill for that.
- CoolCold 4y agoside question - do you plan to revive podcasting, Running In Production in particular or is it RIP? It has some eye-opening episodes for me
- nickjj 4y agoHi, Thanks. I made a video and blog post on why I stopped recording it here: https://nickjanetakis.com/blog/taking-an-indefinite-break-from-the-running-in-production-podcast https://nickjanetakis.com/blog/taking-an-indefinite-break-fr... The state of the show hasn't changed since then, it's RIP'd for now. I still have the urge to do the recording bits tho, it's a cruel world!
- pxtail 4y agoCan you elaborate a bit more on why are you preferring standalone commands instead of going all-ansible? I was considering switch to ansible module for myself but I'm hesitating, I feel like this could produce quite complex, intricate setup since docker compose itself has many specific stuff like .env files, .env.local files, docker-compose.yml environment specific override files, environment variables and many more so I have mixed feelings when thoughts about intertwining it with ansible arrives.
- nickjj 4y ago> Can you elaborate a bit more on why are you preferring standalone commands instead of going all-ansible? I very strongly believe: - Ansible is a great tool for setting up a server to get it to the point where you can run / deploy applications - Docker Compose is a great tool for running your app - Git is a pretty good tool for initiating deployments In my opinion these are 3 distinct things. Trying to make Ansible do everything gets messy, you also lose feedback. For example if you git push, a post receive hook will stream the response back to your terminal but Ansible will only show output when a task is complete. Using the raw Docker Compose commands also keeps things more consistent between dev, CI and prod. You run basically the same thing in all environments.
- htamas 4y agoHow do you use Git to deploy things? Sorry if it's a dumb question, I'm unfamiliar with Ansible.
- nickjj 4y agoA git post receive hook. You can set up a bare git repo which lets you push code to it. Then when you push to it, the post receive hook runs which can be any script you want. In this case you can run the commands to restart your containers or whatever else you need to do.