Testing with Ansible
IEEE Spectrum has recently posted an article about Yahoo resigning from the QA team. After that maneuver quality of the final product not only didn’t degrade but actually improved. Of course, if we delve deeper into the article we will realize that the products got better after continuous delivery introduction (image credit towww.cloudofit.com) and the QA team wasn’t entirely to blame. However, that’s a clear signal to old school testers that programming/scripting skills are now necessary.
One of my favorite tools that support Continuous Delivery (or Deployment if we assume what deploy to production is automatic) is Ansible. This simple automation agent allows us to execute commands on external hosts via plays, which can later be organized to playbooks (list of plays). This is how example playbook looks like:
What is this playbook doing?
a) it checks hosts file for
[droplets] string and connects to IP addresses below. Hosts file example:
b) apt-get update is called (
apt-get install nginx is called with automatic confirmation (
d) nginx service is started
With very few lines we were able to install the necessary applications on two hosts. Imagine how much time you’ll save if the number of machines would be bigger. Probably you have already realized how powerful Ansible can it be to testing, but let me give you a few more examples:
- Environment setup (see example above)
- Updating app configuration on all testing servers
- Jenkins / Selenium Grid / Selenium nodes auto-configuration
- Smoke tests after prod deployment
- Running commands and checking the output