How to overwrite the content of a file in remote systems using Ansible playbook

0 votes

Hi Guys,

I am new in Ansible. I want to replace the content of a file in my remote systems using Ansible playbook. How can I do that?

Aug 2, 2020 in Ansible by akhtar
• 38,230 points
13,073 views

1 answer to this question.

0 votes

Hi@akhtar,

You can find one argument in the copy module named content. It allows us to overwrite the content of a file using Ansible playbook. I have attached one example below for your reference. 

copy: 
  content: '# This file was moved to /etc/mine.conf' 
  dest: /etc/mine.conf
answered Aug 2, 2020 by MD
• 95,440 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
3,834 views
0 votes
2 answers

How to create a directory in remote nodes using Ansible-Playbook?

You can read install and setup apache ...READ MORE

answered Aug 23, 2020 in Ansible by anonymous
• 160 points
3,551 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,440 points
24,729 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,440 points
2,016 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
3,439 views
+2 votes
1 answer
0 votes
1 answer

How to find the memory of remote systems using the setup module in Ansible?

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

answered Aug 10, 2020 in Ansible by MD
• 95,440 points
5,292 views
0 votes
1 answer

How to capture the output of a task in Ansible Playbook?

Hi@akhtar, Ansible registers module used to capture/store the ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,440 points
14,289 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