file module

The module that makes sure a file, directory or link exists or is absent, with the owner and permissions you ask for.

In more detail

With state set to directory it creates the directory if missing and reports ok if it is already there, which makes it the idempotent replacement for mkdir -p. Its mode argument sets permissions, and should be quoted, such as "0755", so YAML does not read it as a number.

Example

ansible all -m file -a "path=demo state=directory"

Related terms

Taught in

References

Certification courses