This example only runs when /path/to/database doesn't exist:
# You can also use the 'args' form to provide the options.
- name: This command will change the working directory to somedir/ and will only run when /path/to/database doesn't exist.
command: /usr/bin/make_database.sh arg1 arg2
args:
chdir: somedir/
creates: /path/to/database
but why is it listed under args:?
And what's the args: setting for?
args is used to explicitly pass named parameters to actions that support "free form" parameter – additional word args is required because in YAML (language used for Ansible playbooks) you can't assign string value for "root" key of a dictionary.
# here `command` is a string
command: /bin/echo ok
# here `user` is a dict
user:
name: john
And because command is a string, you use args to pass additional parameters (like chdir, creates, etc). Whereas user is a dict, so you can add parameters straight in there (like name, uid, etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With