Command line option --check can be used to perform a task or run a playbook in dry run mode, meaning that no changes will be made on the manage nodes (e.g. target systems). For example, here is how to use the --check option with the ansible-playbook command.
ansible-playbook foo.yml --check
Or, the check_mode module can be used to determine if a task would have been successful.