How to compare two files using Ansible

0 votes

Hi Guys,

I want to copy some files and also want to see the difference between the files using Ansible playbook. How can I do that?

Sep 17, 2020 in Ansible by akhtar
• 38,260 points
11,496 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the copy module in Ansible. You can use check_mode: yes and diff: yes tasks options to show differences as shown below.

- hosts: localhost
  gather_facts: no
  tasks:
    - name: "Show the difference between files" 
      copy:
        src: file1.txt
        dest: file2.txt
      check_mode: yes
      diff: yes
answered Sep 17, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,680 points
1,158 views
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,649 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,065 views
+2 votes
1 answer
0 votes
1 answer

How to copy files in remote system using Ansible?

Hi@akhtar, You need to use the copy module ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,460 points
2,415 views
0 votes
1 answer

How to copy multiple files to remote system using Ansible Playbook?

Hi@akhtar, You can use the copy module in ...READ MORE

answered Sep 16, 2020 in Ansible by MD
• 95,460 points
11,294 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