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
  copy:
    src: /tmp/sudoers
    dest: /etc/sudoers
    validate: "visudo -csf %s"

 



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 6c818 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |