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.
Working ansible installation 1.9 or above
none
(auto-loaded via requirements.yml)
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 }
You may use this as an auto-loader for all sub-roles for testing or you can load each role as needed individually.
This galaxy test role auto-loader will be controlled as to which versions of sub-modules get loaded. Do what works best for you.
if you want to add a role, feel free to reach out to me for help until I work out some documentation for how to do this effectively.
Please list mandatory fields for each role.
test roles are intended to be part of the _test cycle.
roles should make no changes to system settings and should be read-only
each role will have default parameter of
debug: false
if it is not provided. Setting to true will enable debug.
MIT
This role was created in 2016 by Mike Caspar.