3 ms·
Personally the best use case for docker I have at the moment is for the testing of chef cookbooks with the Chef Test Kitchen Docker driver - https://github.com/
by bitcointicker 11y ago
Personally the best use case for docker I have at the moment is for the testing of chef cookbooks with the Chef Test Kitchen Docker driver - https://github.com/portertech/kitchen-docker https://github.com/portertech/kitchen-docker
I can write my cookbooks and almost instantly test them inside a container. You can even test on multiple platforms at the same time (Debian,Rhel etc) in parallel. You can perform integration testing using serverspec once the container has converged to the required state - http://serverspec.org/ http://serverspec.org/
- iheartmemcache 11y agoI've struggled to find a place to use Docker for ages simply because between LXC/VMs/BSD jails, Docker just seemed like some pretty paint on top of what I was already doing. Serverspec is _real_ interesting. Do you have more resources about how it's used, incrementally adjusted, etc?
- bitcointicker 11y agoThis is a nice article which describes how it is used in detail and the general workflow: http://dustinrcollins.com/chef-integration-testing-with-serverspec http://dustinrcollins.com/chef-integration-testing-with-serv... If you use it in a pipeline and it reports no errors, you can then upload your cookbook changes to chef server and bump the version. Obviously it relies on cookbook writers being disciplined, to make sure they add tests for new features they have added, but even a simple test to make sure a service is up and running and listening on a port can be enough to make sure a commit has not broken a cookbook. Opscode recently announced chef compliance which appears to build on serverspec, it is more geared towards auditing and security. https://www.chef.io/solutions/audit-compliance/ https://www.chef.io/solutions/audit-compliance/
- bazfoo 11y agoI found myself doing the same thing for Ansible. The problem I ran into was where I wanted to test service restarting in a systemd based environment. Older releases using sysvinit work perfectly fine.
- eropple 11y agoThis is a major problem with the now-in-vogue use of Docker for testing this sort of thing, yes. They aren't replacements for a virtual machine, and testing against something that doesn't even resemble the deployment environment is wacky to me.
- arianvanp 11y agoThis is why you should check out systemd-nspawn. It was designed especially for this use case. Also. If you're on upstart, give lxc a shot. We currently test our ansible scripts by deploying to lxc by giving each container a static IP in a bridged network to simulate our production environment. Just swap ansible inventory files. Works like a charm.
- glenjamin 11y agoThis gist works with test-kitchen to run systemd in a centos 7-based container. It should be simple enough to adjust to run ansible. https://gist.github.com/glenjamin/2d04e9c2a163c7848173 https://gist.github.com/glenjamin/2d04e9c2a163c7848173
- geerlingguy 11y agoI'm doing something similar using Docker to run tests on Ansible roles on Ubuntu 12/14 and CentOS 6/7 in parallel within Travis CI: https://github.com/geerlingguy/ansible-role-apache/blob/master/.travis.yml https://github.com/geerlingguy/ansible-role-apache/blob/mast... I've been playing around with the technique a while, but a different contributor ultimately did the final work for me, and he wrote up a great blog post on the process: http://bertvv.github.io/notes-to-self/2015/12/13/testing-ansible-roles-with-travis-ci-part-2-multi-platform-tests/ http://bertvv.github.io/notes-to-self/2015/12/13/testing-ans... While I'm yet to find a compelling reason for me to use Docker for my production environments (though the is one SaaS service I run which may benefit as Docker's warts have become much more manageable), it's excellent in a CI environment!