Backing up every configuration before any change is a good idea.
With the Git tool, every revision or change can be keep track and changes can be reversed.
However, not everything is in Git. For example, in Linux configuration on /etc configuration or other important location or files is not under Git.
To keep track of the changes, old school method can still be applied.
Making another copy of the file, or just simply commenting every line and adding changes or new configuration after commenting the existing lines or configuration; are forms of backup.
Existing configuration can still be seen, and can put back if there's a need to reverse the configuration.
In an environment where there is hundred or more virtualized machines, Ansible is a way to go.
Ansible can do the task to comment all the existing lines and apply new configurations.
Ansible script below, are references from multiple sources found on the web to create this Ansible script below.
Here's the Ansible, save it as a YAML file. Apply it to a Test Server or VM before deploying to production to make sure the output is the expected result.
---
- hosts: Server-Test-Machine
tasks:
- name: Add # to the start of every line in the file, existing entries will be commented
ansible.builtin.replace:
path: /etc/resolv.conf
regexp: '^(.*)$'
replace: '#\1'
vars:
lines_to_add:
- "First Test line to add."
- "Second Test line to add."
- "nameserver 8.8.8.8"
tasks:
- name: Add above multiple lines to a file using lineinfile, or add the new entries
ansible.builtin.lineinfile:
path: /etc/resolv.conf
line: "{{ item }}"
state: present
loop: "{{ lines_to_add }}"
That's it, it will simplify the task of backing up existing configuration and also making or applying new changes to the configuration. Modify it for any use cases that the Ansible script can be applied.
Stay safe! and Keep things up!
Do ASAP, Always Say A Prayer...
Practice O.T.G. = Obedience To God
Make time for Prayer and Meditation.
================================
Free Android Apps:
Click links below to find out more:
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Heaven's Dew Fall Prayer app for Android :
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
Divine Mercy Chaplet Guide (A Powerful prayer) BFF = Be Filled Faith:
Comments
Post a Comment