Ansible - validate parameter

The validate parameter can be used to determine if a certain task will be successful or fail without actually performing the task. Only certain modules can use this parameter.

For example, let's say you are using the copy module to copy a file. In this example, the validate parameters is used. The visudo command with the -csf options validates the /etc/sudoers file. %s represents the destination file (/etc/sudoers).

- name: copy sudoers file, validating the sudoers file using visudo -csf
    src: /tmp/sudoers
    dest: /etc/sudoers
    validate: "visudo -csf %s"


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 56531 in the box below so that we can be sure you are a human.