Skip to main content

No project description provided

Project description

Ansible test

Make testinfra easier with ansible repository.

Write your test directly in your roles

purpose of ansible-tests

I want to be able to write testinfra tests in my role and use my inventories and my playbooks to run them


ansible-tests --file-name tests.yml --inventory inventory/dev.ini

Test your ansible roles

Your tests should be in test directory inside your role :

    ├── defaults
    │   └── main.yml
    ├── handlers
    │   └── main.yml
    ├── tasks
    │   └── main.yml
    └── tests

Example of test file :

# tests/

def test_check_nginx_is_installed(host):
  nginx = host.package('nginx')
  assert nginx.is_installed

def test_nginx_is_running(host):
  nginx = host.service('nginx')
  assert nginx.is_running

Example of corersponding task file :

# tasks/main.yml
- name: install nginx
    name: nginx
    state: present

- name: start nginx
    name: nginx
    state: started

Configure ansible-test

To run ansible test, you have to respect this requirements:

  • your roles must be in roles directory
  • you must have a playbook or a file to describe the matching between tests and servers

tests.yml supported formats

- hosts: bdd
  roles: postgres
- hosts: all
  roles: secu
- hosts: all
    - base
    - secu
- hosts:
  - bdd
  - web-app
  - role: secu
  - role: users
- hosts: bdd:web-app
  - role: secu

You should be able to use directly your playbook if you don't use stuff like !group to exclude some group

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ansible-tests, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size ansible_tests-0.0.4-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ansible-tests-0.0.4.tar.gz (2.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page