Find/replace across 100's of servers using automated script
-
Hi, all - new contributor/user here so excuse my ignorance… I’ve done some searching within the forums and have found bits and pieces of what I’m trying to do but, I can’t find an exact(or close to exact) solution.
Here’s my challenge - I have an .ini file that is stored in the same location in 440 separate servers which I have access to via a VPN(these are not all within an AD). I periodically need to add or edit lines within the .ini and now I have the challenge to edit the file across all of the servers. It’s a simple find/replace and easy to do when only 5-10 servers need to be connected to but, 440 makes the challenge exponentially more difficult.
The ideal solution: I can drop a windows scheduled task onto each server easily which would execute a batch or similar file that the necessary NPP scripts would be wrapped into or, I also have an RMM tool that give me access to and allows me to execute procedures against each of the servers that could also be used to execute a script.
I’ve played around with the PythonScript plugin some but that actually seems to be overkill. Has anyone had a similar challenge and, if so, be willing to share your solution? Any help/direction would be much appreciated for this newbie.
-
@Steve-Mueller said in Find/replace across 100’s of servers using automated script:
It’s a simple find/replace and easy to do when only 5-10 servers need to be connected to but, 440 makes the challenge exponentially more difficult.
That is what tools like Chef, Puppet and Ansible are for. I’d start there rather than hacking something in Notepad++ - a text editor.
Cheers.
-
@Michael-Vincent I appreciate the response. I’m familiar with these tools in name only and I don’t really see how they would meet this particular need. Can you point me in the direction of one of their tools that might meet my specific needs?
-
@Steve-Mueller said in Find/replace across 100’s of servers using automated script:
I’m familiar with these tools in name only and I don’t really see how they would meet this particular need. Can you point me in the direction of one of their tools that might meet my specific needs?
If I understand your question and may paraphrase:
“you want to sync a file or files across multiple servers”
If that is correct, I’ll start your homework for you with a quick Google search link:
https://www.google.com/search?q=ansible+sync+files+between+servers
And the first article returned:
Cheers.
-
@Michael-Vincent Thanks, but I guess I wasn’t clear on the need. I need to edit an .ini file across potentially 440 servers. I can’t sync them across all servers as they all could be slightly different depending on the market/region they are located in. So, basically, I want to define which servers need updated(the file path for each server will be static), run the find/replace and then save the edits back onto the source server(s).
-
it would very much surprise me if tools like the ones @Michael-Vincent linked to couldn’t handle differences in the destination file, because I’m sure you aren’t the first to need to deploy similar but not identical across a large network.
if I were solving the problem in the way you suggested, I would use
ssh
to runsed -i
on the remote servers to run regex-based search-and-replace on the files (assuming the remote servers could be accessed with ssh and had sed available)but none of that is on-topic for a Notepad++ forum. You will probably want to find someplace else to research such things – if you have specific questions about “how do I get tool X to perform task Y”, where tool X could be anything from ssh or sed or Ansible / Chef / Puppet, there exists a collection of super users of their computers who might be convinced to explain how to do it, if you form a well-asked question.
-
So you need a local scripting / templating solution that allows you to specify the INI file template and variables and then have a “database” of variable to value mappings for each server. Run a script to create the configs, Ansible to deploy.
There are several templating frameworks out there (Jinja2 and Mako come to mind for Python).
I’m still failing to see how any of this is related to Notepad++ other than using Notepad++ to edit the files / templates and write your scripts.
Cheers.