How to remove old file using Ansible

0 votes

Hi Guys,

I have copied some files to the remote systems using Ansible Playbook. Now I want to remove those files using Ansible. How can I do that?

Sep 17, 2020 in Ansible by akhtar
• 38,170 points
229 views

1 answer to this question.

0 votes

Hi@akhtar,

You can remove your files using Ansible. In Ansible you will find the file module which is used to handle the file-related task. To remove files you can see the below code.

- name: Remove old files foo
  file: 
    path: /path/to/foo 
    state: absent
answered Sep 17, 2020 by MD
• 95,060 points

Related Questions In Ansible

0 votes
1 answer

How to remove cron using Ansible

Hey @Likhit, You could use something like ...READ MORE

answered Jan 28, 2019 in Ansible by Kavya
1,718 views
0 votes
1 answer

How to encrypt and existing file using Ansible Vault?

Hey @Kyraa, to encrypt an existing file ...READ MORE

answered Jan 29, 2019 in Ansible by Kavya
1,733 views
0 votes
1 answer

How to create a new encrpted file using Ansible Vault?

If you are creating a new file ...READ MORE

answered Jan 29, 2019 in Ansible by Kyraa
219 views
0 votes
1 answer

How to overwrite the content of a file in remote systems using Ansible playbook?

Hi@akhtar, You can find one argument in the ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,060 points
2,174 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
954 views
+2 votes
1 answer
0 votes
1 answer

How to remove duplicate entries from a file using Ansible?

Hi@akhtar, You can use the shell module to do your ...READ MORE

answered Sep 17, 2020 in Ansible by MD
• 95,060 points
508 views
+1 vote
1 answer

How to deploy war file into the Websphere using ansible playbook

Hi@M, You can use the below-given example. - name: ...READ MORE

answered Jun 29, 2020 in Ansible by MD
• 95,060 points
522 views