Greetings friends, I haven’t written much about Veeam Availability Orchestrator yet, and that’s going to change soon, today I start with an advanced entry and later we’ll come back with the basics.
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:
This will give us a unique code that we will use in the scripts below:
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:
Slack-Plan-Start.ps1
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
Slack-Plan-End.ps1
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
Slack-Plan-VM.ps1
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:
Install-Module PSSlack
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 '2.8.5.201' 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 2.8.5.201 -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
- etc
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%.
The VM Script must have VMIP, VMIPReplica and VMName which must have %current_vm_ip%, %replica_vm_ip% and %source_vm_name% respectively:
In all of them we have the Common Parameters, I like to leave it this way:
Already in our Failover Plan we will add a new step in the pre-failover steps, with our Script:
Similar to post-failover, add a new step with the script: And, inside the VMs:
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:
From Slack we will be able to see the notifications for each VM, besides that the process has begun:
And at the end we will see a complete summary of all the work, in plain text:
Next steps
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.
Michele Domanico says
nice one mate!