No menu items!
No menu items!
More

    [Ansible] Quản lý file bằng Ansible

    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: absent

    Trong đó:

    • 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.

    Bài viết gần đây

    spot_img

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Đăng ký nhận thông tin bài viết qua email