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 option can be used to determine if a task would have been successful. In this example, check mode is used to determine if foo.txt can be copied.
- name: "copy foo.txt" copy: src: "/tmp/foo.txt" dest: "/tmp/foo.txt" check_mode: "yes"