MikeCaspar / playbook_test_framework

ansible test playbook framework to be used with _test/_maintain loop
MIT License
1 stars 1 forks source link

playbook_test_framework

playbook_test_framework (experimental)

Wiki and documentation available at https://github.com/MikeCaspar/playbook_test_framework/wiki

This role is intended to be used with the maintain / test loop presented at AnsibleFest 2016 in SFO

This role is a role used to automatically download all testing roles used in the framework.

You have the option to specific individual test roles or to simply use this to download them all

The original slides for the test/maintain loop can be read about here.

Tests during this part of the loop are created via a _test.yml file that can be separately executed from _maintain playbooks.

This allows a test first/test parallel type approach with the ability to also use _test.yml as a form of governance check.

To provide samples to those that wish to use this approach, I decided it was a good idea to share pre-defined exmaple roles for those that wish to take this approach and do not want to start from scratch.

The intent is to allow teams working on infrastructure to use existing ansible yaml syntax without having to learn python development.

Requirements

Working ansible installation 1.9 or above

Role Variables

none

Dependencies

(auto-loaded via requirements.yml)

To load the framework

ansible-galaxy install MikeCaspar.playbook_test_framework

This will download a bootstrap or startup dependency list that will automatically load all sub-testing dependency roles from galaxy. Once installed, to download all the testing roles, execute the following command:

ansible-galaxy install -r requirements.yml

A sample _test playbook ( note that different test roles are used )

# playbook:  application1_proxy_test.yml

- hosts: servers
  roles:
     - { role: MikeCaspar.testForFolder, path:"/etc" , expected: present}
     - { role: MikeCaspar.testForFolder, path:"/badfolder" , expected: absent}

     - { role: MikeCaspar.testForTimezone, timezoneCity:"America/Toronto" }

     - { role: MikeCaspar.testForGroup, name: "docker" }
     - { role: MikeCaspar.testForGroup, name: "specialgroup" , expected: absent }

     - { role: MikeCaspar.testCommandResponse, command: "cat /etc/hosts", expected: "localhost" }

     - { role: MikeCaspar.testForPackage, name: "pythomjs" , expected: present }

quick notes if you are into trying things out already

Design guidelines

if it is not provided. Setting to true will enable debug.

The test/maintain loop

https://raw.githubusercontent.com/wiki/MikeCaspar/playbook_test_framework/images/TestMaintainLoop.png

License

MIT

Author Information

This role was created in 2016 by Mike Caspar.