Most playbooks in this repo contain automated tests implemented using Molecule.
Use Makefile provided in this directory to launch tests.
For example:
$ make
..Execute automated tests for all roles..
$ make test ANSIBLE_ROLE=../roles/motd
..Execute tests for a single role at provided path..
$ make login ANSIBLE_ROLE=../roles/motd
..Provision Docker container, apply the role and start interactive shell..
Refer to make help
and read the Makefile for more information.
Timeout is not implemented in Ansible, but we can use GNU Timeout, e.g.
$ timeout 5m sleep 10m
Exit code: 124 (after 5 minutes)
$ timeout 10m sleep 5m
Exit code: 0 (after /bin/sleep terminates)
platforms:
- name: debian10-docker
image: potyarkin/molecule:debian-10-systemd
pre_build_image: true
command: /sbin/init
capabilities:
- SYS_ADMIN
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /lib/modules:/lib/modules:ro
tmpfs:
- /run
- /tmp
See roles/transmission
for example.
Useful modules:
- assert
- command
- fail
- package_facts
- ping
- service_facts
- wait_for
Useful techniques:
- Early exit: failed_when
Links: