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

Usages

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

Test your ansible roles

Your tests should be in test directory inside your role :

nginx
    ├── defaults
    │   └── main.yml
    ├── handlers
    │   └── main.yml
    ├── tasks
    │   └── main.yml
    └── tests
        └── test_nginx.py

Example of test file :

# tests/test_nginx.py

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
  package:
    name: nginx
    state: present

- name: start nginx
  service:
    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
  roles:
    - base
    - secu
- hosts:
  - bdd
  - web-app
  roles:
  - role: secu
  - role: users
- hosts: bdd:web-app
  roles:
  - 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.

Source Distribution

ansible-tests-0.0.3.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansible_tests-0.0.3-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file ansible-tests-0.0.3.tar.gz.

File metadata

  • Download URL: ansible-tests-0.0.3.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2

File hashes

Hashes for ansible-tests-0.0.3.tar.gz
Algorithm Hash digest
SHA256 abe581a3eb9104e68f540b70e673542ffc03089514d585ec2cf92617bfc9806b
MD5 d255b42b2e1b755cb2669eadde120d28
BLAKE2b-256 6bd3cc60dd3a2b733882a1a29bc3af7cd066eea01a4881d6cc0e4652cbf16ff2

See more details on using hashes here.

File details

Details for the file ansible_tests-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: ansible_tests-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2

File hashes

Hashes for ansible_tests-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2da8154ef2b63e127b237962c9e00f5b82d9dd8aa8922865a30b3347aa4de5f8
MD5 58f60390c90709af75de7ba4d7bea706
BLAKE2b-256 564242d0d63dedf1c5fc64c9289ee5ffc79f46d27fee3e254ecd34417a056da7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page