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,260 points
3,616 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,460 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 29, 2019 in Ansible by Kavya
4,640 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
3,470 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
1,061 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,460 points
14,478 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,061 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,460 points
4,954 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,460 points
2,416 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP