How to remove duplicate entries from a file using Ansible

0 votes

Hi Guys,

I have one file in Ansible node. I want to remove the duplicate entries from this file and upload the file in the remote systems using Ansible Playbook. How can I do that?

Sep 17, 2020 in Ansible by akhtar
• 38,260 points
4,957 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the shell module to do your task. But shell module doesn't have the capability to remove duplicate entries. You need to do some tricks as shown below.

 - name: Find uniqe entries
   shell: cat Mergedfile | sort -u | uniq -u > hosts
answered Sep 17, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
4,184 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,063 views
0 votes
1 answer

How to add multiple lines in a file using Ansible playbook?

Hi@akhtar, You can update your file using lineinfile ...READ MORE

answered Sep 16, 2020 in Ansible by MD
• 95,460 points
26,723 views
0 votes
1 answer

How to remove old file using Ansible?

Hi@akhtar, You can remove your files using Ansible. ...READ MORE

answered Sep 17, 2020 in Ansible by MD
• 95,460 points
3,619 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,062 views
+2 votes
1 answer
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,485 views
0 votes
1 answer

How to remove a role from Ansible Galaxy?

Hi@akhtar, You need to log in to your ...READ MORE

answered Aug 28, 2020 in Ansible by MD
• 95,460 points
10,539 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