Parsing and Comparing a text file

Hello,

My requirement is as below:

A text file with configuration contents would be given to us by the product teams.
I will have to compare this file against the one on the remote host , find out the difference, and replace values for the variables where it doesn’t match.
How is this achievable using Ansible.
Kindly suggest a solution.

Thanks in advance,
Mona G

I assume you want to manually control, what the differences are.
Automating this is difficult.

I would use a template task, put the file you just got into your
ansible folder as the template src file and then run the
ansible-playbook command with --check --diff:

# File foobar.yml
- hosts: foobar
  tasks:
  - template:
    src: "file_you_just_got"
    dest: "/path/to/file/on/remote/server"
  check_mode: yes

Then run the playbook foobar.yml like this:

ansible-playbook foobar.yml --check --diff

Johannes

The copy module does this by default, run with --diff --check to see
what 'it would do'