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,170 points
3,542 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,200 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
2,321 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
520 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,200 points
3,767 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,200 points
717 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
1,125 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,200 points
1,205 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,200 points
5,307 views