0

I have three CentOS servers in the Azure environment that needs a bunch of software and configuration done to them (i.e. adding users, adding permissions, etc.) Unfortunately I can't just do it to one server and replicate the servers. Does there exist a way where I can do this to one server and it replicates across the other two so I only have to do this once?

5

This is what configuration management tools are designed to achieve so I recommend you take a look at one or more of these:

  • Chef
  • Puppet
  • Ansible
  • Salt

These tools will allow you to define a machine configuration in a file or files, and then apply it to multiple machines and ensure they are in the state you define. Most of these have a free open source version that you can get started with.

2

I would suggest reading and learning about parallel ssh, cluster and configuration management tools. The idea is you run the command once from a central server and it pushes to the rest the of the servers in your group or cluster. In order for this to work you need some way for a central server to talk to the rest of the servers (one simple way is via ssh and using keys). For configuration management there are options such as chef, Puppet, Ansible etc.

2

Would suggest that you check out the AzureRmVMRunCommand, allows you to execute a PowerShell / Shell Script on any server in Azure. With a small loop you could execute any changes you need easily across any servers.

PowerShell

Invoke-AzureRmVMRunCommand -ResourceGroupName 'rgname' -Name 'vmname' -CommandId 'RunPowerShellScript' -ScriptPath 'sample.ps1' -Parameter @{"arg1" = "var1";"arg2" = "var2"}

Bash

az vm run-command invoke -g MyResourceGroup -n MyVm --command-id RunShellScript --scripts 'echo $0 $1' --parameters hello world

Note: It's also possible to execute PowerShell / Shell Script in both those commands above. They are cross platform.

See Invoke-AzureRmVMRunCommand and az vm run-command.

2

For small isolated environments, config management can potentially be overkill. More importantly, implementing CM in tiny stand-alone stacks can easily create more work and more issues than simply not using it at all, especially if the admin staff on hand has none to minimal experience with CM.

For managing platform-homogeneous stacks of around three nodes or less that don't already use CM and that one doesn't expect to make many changes to in the course of their lifetime beyond a few blanket tasks, management via tmux is fast and effective.

There is already extensive documentation and guides on how to use tmux, but for the sake of direction it's a terminal multiplexer. tmux will allow you to not only open multiple simultaneous interactive sessions using SSH or similar to remote or local instance(s), but will also allow you to send commands and view shell output to all active sessions at once in real time.

Beware that while tmux performs beautifully as a terminal window manager and command multiplexer, it doesn't scale well in large environments that require lots of sessions. You'll have a hard time trying to manage fifteen servers in even multiple windows (a window is like a tab in a browser), and God forbid half of them didn't run the command you wanted correctly, requiring moving focus to them one by one and fixing the issue to get everything back in sync. Raging out over this is exactly what turned me on to SaltStack and CM in general.

A straightforward guide to tmux

0

Can you make a shell script of all these settings? If yes then make one script and roll it out to all the server using linux customScriptExtensions

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/extensions-customscript

I do the same for various environments in windows but above should work for linux too. I tie it up with my ARM template that rolls out the VMs. So If i later have to do some settings changes, i can control all via ARM templates itself.

Not the answer you're looking for? Browse other questions tagged or ask your own question.