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 in Ansible by akhtar
• 27,980 points
63 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 by MD
• 64,820 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
1,638 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
179 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 in Ansible by MD
• 64,820 points
92 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 in Ansible by MD
• 64,820 points
29 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
719 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 in Ansible by MD
• 64,820 points
365 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 in Ansible by MD
• 64,820 points
133 views