{"id":16632726,"url":"https://github.com/benwebber/ansible-tap","last_synced_at":"2025-10-11T20:14:42.137Z","repository":{"id":149655536,"uuid":"76776829","full_name":"benwebber/ansible-tap","owner":"benwebber","description":":white_check_mark: Test Anything Protocol (TAP) producer callback plugin for Ansible","archived":false,"fork":false,"pushed_at":"2020-08-01T12:29:43.000Z","size":17,"stargazers_count":8,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T13:11:21.818Z","etag":null,"topics":["ansible","callback-plugin","tap","tap-stream","test","test-anything-protocol","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benwebber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-18T10:39:07.000Z","updated_at":"2019-03-18T16:34:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"47867f70-3b53-44c0-ba05-a358fd0e07ac","html_url":"https://github.com/benwebber/ansible-tap","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/benwebber/ansible-tap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fansible-tap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fansible-tap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fansible-tap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fansible-tap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benwebber","download_url":"https://codeload.github.com/benwebber/ansible-tap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benwebber%2Fansible-tap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008578,"owners_count":26084480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","callback-plugin","tap","tap-stream","test","test-anything-protocol","testing"],"created_at":"2024-10-12T05:10:00.983Z","updated_at":"2025-10-11T20:14:42.133Z","avatar_url":"https://github.com/benwebber.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansible-tap\n\n[![Build Status](https://travis-ci.org/benwebber/ansible-tap.svg?branch=master)](https://travis-ci.org/benwebber/ansible-tap) [![Download from Ansible Galaxy](https://img.shields.io/badge/role-benwebber.tap-blue.svg)](https://galaxy.ansible.com/benwebber/tap/)\n\n[Test Anything Protocol (TAP)](https://testanything.org/) producer for Ansible.\n\nThis callback plugin allows you to write TAP test suites as Ansible playbooks. Consider it an Ansible-only alternative to [Serverspec](http://serverspec.org/) and [Testinfra](https://testinfra.readthedocs.io/).\n\n## Requirements\n\n* Ansible 2\n* Python 2.7+\n\n## Install\n\nWhile you can't install this plugin directly using `ansible-galaxy`, you can use `ansible-galaxy` to download it:\n\n```\nansible-galaxy install -p roles/ benwebber.tap\n```\n\nNavigate to the role directory and run `make install`:\n\n```\ncd roles/benwebber.tap\nmake install\n```\n\nThis will copy the plugin to `~/.ansible/plugins/callback`.\n\n## Usage\n\nConfigure Ansible to use this plugin as the standard output callback:\n\n```\nANSIBLE_STDOUT_CALLBACK=tap ansible-playbook -i hosts test.yml -l hostname\n```\n\nYou can also set it to be the default callback in `ansible.cfg`:\n\n```\n[defaults]\nstdout_callback=tap\n```\n\n## Writing Ansible tests\n\nBy default, Ansible will abort the play if any tasks fail. Set `ignore_errors: true` on all tests to disable this behaviour:\n\n```yaml\n- name: check if service is running\n  command: systemctl is-active service\n  register: is_active\n  tags: diagnostic\n\n- name: assert that service is running\n  assert:\n    that: is_active.rc == 0\n  ignore_errors: true\n```\n\nThis will ensure Ansible executes the entire test suite, barring any unexpected failure.\n\nIf you have a lot of tests, you can set `ignore_errors: true` on a `block`:\n\n```yaml\n- name: check if service is running\n  command: systemctl is-active service\n  register: is_active\n  tags: diagnostic\n\n- name: check if service is enabled\n  command: systemctl is-enabled service\n  register: is_enabled\n  tags: diagnostic\n\n- ignore_errors: true\n  block:\n  - name: assert that service is running\n    assert:\n      that: is_active.rc == 0\n\n  - name: assert that service is enabled\n    assert:\n      that: is_enabled.rc == 0\n```\n\nIf a task fails, the plugin will output troubleshooting information as an embedded [YAML document](https://testanything.org/tap-version-13-specification.html#yaml-blocks):\n\n```tap\nnot ok - assert: assert that variable is set\n  ---\n  _ansible_no_log: false\n  _ansible_verbose_always: true\n  assertion: status is defined\n  changed: false\n  evaluated_to: false\n  failed: true\n  invocation:\n    module_args:\n      that: status is defined\n    module_name: assert\n  ...\n```\n\n### Excluding tasks from TAP stream\n\nOften, the result of a test will depend on previous tasks. You will naturally want to exclude these setup tasks from the TAP stream.\n\nTo do so, simply tag setup tasks with the `diagnostic` tag:\n\n```yaml\n- name: set up next test\n  command: 'true'\n  register: true_\n  tags: diagnostic\n\n- name: should always pass\n  assert:\n    that: true_.rc == 0\n  ignore_errors: true\n```\n\nThe callback plugin will print diagnostic lines instead of test lines:\n\n```tap\n# command: set up next test\nok - assert: should always pass\n````\n\nUnlike individual test cases, you probably do not want to ignore errors for this type of task. Failures would represent an error in the test suite and not a test failure.\n\n### Expected failures and unexpected successes\n\nTAP supports a `TODO` directive to ignore tests for features that haven't been implemented yet.\n\nIf a test marked with `TODO` fails, TAP consumers will consider it an expected failure. Similarly, if a test marked with `TODO` passes, TAP consumers will consider it an unexpected success.\n\nTag expected failures with `TODO`:\n\n```yaml\n- name: expected failure\n  assert:\n    that: false\n  ignore_errors: true\n  tags: TODO\n```\n\nThis will output a `# TODO` directive in TAP stream:\n\n```tap\nnot ok - assert: expected failure # TODO\n```\n\nIf the test passes, you'll receive unexpected success output:\n\n```tap\nok - assert: expected failure # TODO\n```\n\n### Skipping tests\n\nTAP also supports a `SKIP` directive to ignore specific tests.\n\nThis callback uses Ansible's `when` statement to control skipped tests:\n\n```yaml\n- name: this is a skipped task\n  assert:\n    that: false\n  ignore_errors: true\n  when: false\n```\n\nThe reason for skipping the test will appear in the test line:\n\n```tap\nok - assert: skipped # SKIP Conditional check failed\n```\n\n## Example\n\nThe [`tests/`](tests/) directory contains an example test suite which produces all possible test results.\n\nAfter installing the plugin, run the test suite with:\n\n```\nANSIBLE_STDOUT_CALLBACK=tap ansible-playbook -i localhost, -c local tests/playbooks/test_multiple_with_failures.yml\n```\n\nYou will receive the following TAP stream. You can pass this to any TAP consumer.\n\n```tap\nTAP version 13\n# command: set up next test\nok - assert: pass\nnot ok - assert: failed\n  ---\n  _ansible_no_log: false\n  _ansible_verbose_always: true\n  assertion: false\n  changed: false\n  evaluated_to: false\n  failed: true\n  invocation:\n    module_args:\n      that: false\n    module_name: assert\n  ...\nnot ok - assert: expected failure # TODO\nok - assert: unexpected pass # TODO\nok - assert: skipped # SKIP Conditional check failed\n1..5\n```\n\n## Caveats\n\nAt present, this plugin only supports running tests against a single host at a time. The TAP specification does not describe a way to combine multiple output streams.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwebber%2Fansible-tap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenwebber%2Fansible-tap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenwebber%2Fansible-tap/lists"}