lineinfile module in Ansible

0 votes

I have a file with has the following content


I want to uncomment it. How do I write a playbook for the following requirement?

Jan 16 in Ansible by Derryl

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

You can use the lineinfile module for this purpose. This module will search a file for a line, and ensure that it is present or absent. This is useful when you want to change a single line in a file only.

Something like this should work:

- name: test lineinfile
  lineinfile: backup=yes state=present dest=/etc/foo.txt
answered Jan 16 by Emily

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

Using lxc_container module in ansible

This mostly happens when you've not installed ...READ MORE

answered Aug 10, 2018 in Ansible by DareDev
• 6,560 points
0 votes
1 answer

Role of subelement module in an Ansible playbook

Hey @Rahul thanks for a better question ...READ MORE

answered Jan 16 in Ansible by Emily
0 votes
1 answer

Issue while using lineinfile module - Ansible

The lineinfile task has to match both the ...READ MORE

answered Jan 16 in Ansible by Lavanya
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Add a node in Ansible

Follow these steps @Ruth: Generate ssh key ssh-keygen Check the ...READ MORE

answered Jan 8 in Ansible by Haider

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.