Ansible - validate parameter
by
Jeremy Canfield |
Updated: January 04 2021
| 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
copy:
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