Reputation: 63
I am trying to delete files in a directory that match a particular pattern. Tried using the below code.
- name: Find the machine yaml files
file:
paths: "{{ workdir }}/openshift/"
patterns: "99_openshift-cluster-api_{{ item }}-machine*.yaml"
state: absent
with_items:
- master
- worker
However, when I try the above code, I get the following error:
TASK [ocp-config : Find the machine yaml files] ***********************************************************************************************************************
failed: [ash-test-bb8b-bastion-0] (item=master) => {"ansible_loop_var": "item", "changed": false, "item": "master", "msg": "Unsupported parameters for (file) module: paths, patterns Supported parameters include: _diff_peek, _original_basename, access_time, access_time_format, attributes, backup, content, delimiter, directory_mode, follow, force, group, mode, modification_time, modification_time_format, owner, path, recurse, regexp, remote_src, selevel, serole, setype, seuser, src, state, unsafe_writes"}
failed: [ash-test-bb8b-bastion-0] (item=worker) => {"ansible_loop_var": "item", "changed": false, "item": "worker", "msg": "Unsupported parameters for (file) module: paths, patterns Supported parameters include: _diff_peek, _original_basename, access_time, access_time_format, attributes, backup, content, delimiter, directory_mode, follow, force, group, mode, modification_time, modification_time_format, owner, path, recurse, regexp, remote_src, selevel, serole, setype, seuser, src, state, unsafe_writes"}
What Am I missing here?
Upvotes: 0
Views: 325
Reputation: 12063
It seems you are mixing up parameters from different modules. The find
_module has parameters like paths
and patterns
, whereby the module file
hasn't.
The message just reports the syntax error
Unsupported parameters for (file) module: paths, patterns
and guides already to the correct one
Supported parameters include: ... path, recurse, regexp
So you may have a look into Manage files and file properties and the Examples.
Upvotes: 1