Skip to content

MikeCaspar/testForPackage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

testForPackage

testForPackage (test/confirm package installed or not)

Build Status

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

  • test roles are intended to run in read only (to confirm a negative or positive test state)

  • Should you try this role on another platform, please either do a Pull Request for the new platform or feel free to email me to ask that it be added.

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 example 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

  • name: (string) - Mandatory
  • expected: (string) - Mandatory - 'present' or 'absent'
  • debug: (true/false) - Optionally shows debug of vars as it proceeds (defaults to false)
  • immediate_exit_on_fail: (true/false) - Optionally fails immediately on fail (defaults to false)

Dependencies

no dependencies

Example Playbook

test/confirm that package "phantomjs" exists

# playbook:  application1_proxy_test.yml

- hosts: servers
  roles:
     - { role: MikeCaspar.testForPackage, name: "phantomjs", state: "absent" }

License

MIT

Author Information

This role was created in 2016 by Mike Caspar.

testForPackage

About

ansible test role to be used with _test/_maintain loop

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages