Skip to main content

Posts

Showing posts with the label YAML

How to uncomment a conf file in Linux via ansible

How to uncomment or enable a setting in a config file in Linux using Ansible? Ansible is quite a good tool,  as it helps to make a lot of changes on a few servers with a minimal effort. Of course, the challenge is you need to know what you want. And also create an Ansible yaml file that will accomplish the task. Example YAML file for Ansible below is able to make some changes on the Linux logrotate.conf file. On Linux logrotate.conf, it has some text like the string below. Note this is just an example and you can tweak it to other settings as desired. # uncomment this if you want your log files compressed #compress The logrotate.conf file, the compress setting is commented. To enable the setting the # or the comment key must be removed. How to remove the comment in order to enable the setting? Well, if there's only a single server do it the simple way. Login to the server and edit the file using vim or nano or other text editor. However, if there are quite a few servers. Ansible ...