One of the amazing things Veeam Availability Orchestrator allows us is to include additional steps in our Disaster Recovery plan. Talking to a customer I said to him if he would like to receive Slack notifications when a job is running, and have a brief summary in Slack too once the job finishes, of course he loved the idea, today we’ll see the steps necessary to get it up and running.
How to activate an Incoming WebHook in Slack to send simple notifications
Depending on the amount of WebHooks you have available in your Slack channels, this will work or give you an error, simply go to this link:
And we will appear something similar to this, we will select the channel where we want to send alerts:
Preparing Powershell Scripts for VAO
I have three different scripts, one when the work starts and another for later, I also have a script that is processed with each VM, they are very simple, let’s see both:
param([string]$PlanName, [string]$PlanState) Import-Module PSSlack $Uri = "YOURWEBHOOKURLYOUJUSTCREATED" $Channel = "vao-test" [string]$Message = "+----------------------------------------------------------------------------+" $Message += "" | Out-String $Message += $PlanName + ' has been changed the status to ' + $PlanState Send-SlackMessage -Uri $Uri ` -Channel $Channel ` -Parse full ` -Text $Message
param([string]$PlanSummary) Import-Module PSSlack $Uri = "YOURWEBHOOKURLYOUJUSTCREATED" $Channel = "vao-test" [string]$Message = $PlanSummary $Message += "+----------------------------------------------------------------------------+" Send-SlackMessage -Uri $Uri ` -Channel $Channel ` -Parse full ` -Text $Message
param([string]$VMName, [string]$VMIP, [string]$VMIPReplica) Import-Module PSSlack $Uri = "YOURWEBHOOKURLYOUJUSTCREATED" $Channel = "vao-test" $Message = '' + $VMName + ' with IP ' + $VMIP + ' and Replica IP ' + $VMIPReplica + ' has started a DR' Send-SlackMessage -Uri $Uri ` -Channel $Channel ` -Parse full ` -Text $Message
Very simple for now, we will improve them in the future.
How to Install the PSSlack module on the Veeam Availability Orchestrator and Veeam Backup & Replication servers.
Open a Powershell with Administrator permissions and launch the following command to install the PowerShell to Slack module:
We may not have the latest version of NuGet that is needed, so we’ll say AND here:
NuGet provider is required to continue PowerShellGet requires NuGet provider version '126.96.36.199' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\Administrator\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 188.8.131.52 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
And finally we will say A in this question of whether we trust the module:
Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
We already have our VAO and our VBR, ready to launch PowerShell to Slack Scripts.
How to Create custom scripts in Veeam Availability Orchestrator
Now that we have everything almost ready, it’s time to go to Veeam Availability Orchestrator and create custom scripts, in my case are these of Slacks, in yours can be:
- Configurations of Routers or Switches
- Public DNS configuration, e.g. Amazon Route 53
We will go to the configuration of Veeam Availability Orchestrator and on Plan Steps, we will be able to add the three different custom scripts:
For example, the custom script for when we start work, and select the script on our PC:We’ll tell him to be available for all Sites: Within the Script, in particular this of starting the work, we have to have two parameters, PlanName and PlanState, and these must have as default Value %plan_name% and %plan_state% respectively:Finish Script must have a new parameter called PlanSummary with value %plan_summary%.
Executing a Failover Plan and displaying the notifications in Slack
With everything ready, we will be able to launch our Failover, which will show us something similar to this in Scripts:
This project is a v0.1 without a doubt, it works, but notifications can be better, using icons and colors, apart from tables with information. Surely you have time before the end of the year to leave everything much more perfect, but at least and for now you can receive notifications in Slack.