Xoá file.
Để xoá một file trong Ansible, chúng ta có thể sử dụng module file với option state=absent. Ví dụ để xoá file /root/.ssh/id_rsa, ta có thể sử dụng playbook như sau:
- name: Remove id_rsa
file:
path: /root/.ssh/id_rsa
state: absentTrong đó:
name: tên của task.file: tên của module sử dụng để thao tác với file.path: đường dẫn tới file cần xoá.state: trạng thái của file, ở đây làabsent.
Lưu ý: để thực hiện được việc xoá file, user thực thi playbook cần phải có quyền để thực hiện thao tác này.
