Bootstrap FreeKB - Ansible - validate parameter
Ansible - validate parameter

Updated:   |  Ansible articles

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

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