6 innate characteristics of Sitecore Install Framework


Sitecore Installation Framework in short SIF is a tool Sitecore released with its latest and greatest version 9.0. In my opinion it is a DevOps tool that can be used by development and operations teams to install and configure Sitecore 9 in various environments either from scratch or to repair.

Although there is a good learning curve when using Sitecore Install Framework for first time, once we become familiar with how it works we can easily build on the core  concepts. It's worth mentioning that my prior experience using Azure ARM templates made it much easier to understand SIF

SIF characteristics
SIF characteristics mindmap


Below are 6 inherent distinctive characteristics that attracted me most

Installation


Up until Sitecore 8.2 all Sitecore developers and operations team used to follow either exe file or zip file for installations. Developers also used to depend on Sitecore Instance Module (SIM) windows application for installations. This tool used to automate lot of manual tasks that are required while installing Sitecore. It is an open source tool which is tested by Sitecore itself.  It is also by far the most recommended tool in the entire Sitecore market place.

With version 9 Sitecore moved towards a more flexible solution through SIF. Though the zip file installation is still available SIF method is more preferred and adopted in the Sitecore community. There are already many blogs written explaining how to use SIF for Sitecore 9 installation. You can read one from me here and you can see some gochas during installation by Bas Lijten here

Most of the Sitecore developers I see today are not very good in PowerShell. Reason could be that Sitecore itself is a huge product. Learning and exploring it itself will require many years of practical experience on the platform. But with SIF Sitecore is making developers get back to PowerShell which can help developers realize the potential of PowerShell for day to day activities and automation.

Coming from windows background I used to envy the Java developers on how they use the command line tools and package managers to make setup and configuration a cakewalk. While windows has Chocolatey, installing and using SIF from PowerShell is effortless.

First register the repository and install the module

Note: You can install multiple versions of module side-by-side

Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2

Install-Module SitecoreInstallFramework

Then import and use
Import-Module SitecoreInstallFramework

As new features and bug fixes are periodically released, it is recommended that you update the Sitecore Installation Framework. It is even easier to update the module to latest version. Simply run in PowerShell command line
Update-Module SitecoreInstallFramework

Structured 


Configurations for SIF are written in JSON format. JSON is a simple text file that carry data. It's already in human readable format and on top of it we can add metadata information to the file to make it more understandable to the readers.

Developers who are familiar with Habitat solution can carry the .json files knowledge to work on the SIF configuration files. The structure of SIF configuration file is pretty simple. By Sitecore definition,


  • Parameters - These are values that may be passed when Install-SitecoreConfiguration is called. They must declare a Type and may declare a DefaultValue and Description and parameters with no DefaultValue are required when Install-SitecoreConfiguration is called.
  • Variables - These are values calculated in a configuration. They can reference Parameters, other Variables, and config functions.
  • Tasks - Tasks are separate units of work in a configuration. Each task is an action that will be completed when Install-SitecoreConfiguration is called. By default, tasks are applied in the order they are declared. Tasks may reference Parameters, Variables, and config functions.
{
"parameters" : {},
"variables" : {},
"Tasks" : {},
"Modules" : {}
}

Any one worked on Azure ARM templates while installing Sitecore PaaS can easily recognize this structure. You can read more about Azure ARM templates from here

Task Based


Tasks are actions that are conducted in sequence when the Install-SitecoreConfiguration cmdlet is called. A task is implemented as a PowerShell cmdlet. As mentioned above, by simply placing the tasks in an order we can easily create a process flow. This feature is particularly useful for DevOps teams as the code itself will describe the process through the sequence of tasks.

Config Functions - An important feature of SIF is Config functions. These allow elements of the configuration to be dynamic by letting calculate values, invoke functions, and pass the values to tasks making the configuration flexible. In the example below, SetLicense is a Copy task that uses 'resolvepath' config function to identify the license file.

"SetLicense": {
            // Copies the license file to the instance data folder.
            "Type": "Copy",
            "Params": {
                "Source": "[resolvepath(parameter('LicenseFile'))]",
                "Destination": "[variable('Site.DataFolder')]"
            }
        }


SIF also allows to skip certain tasks by just passing them as configuration parameters using the -Skip arguments.

Install-SitecoreConfiguration -Path <configurationpath>\sitecore-XP0.json -Skip <taskname>

Extensible 


Benefits of using SIF doesn't stop there. Sitecore team made SIF very extensible by allowing users to create their own tasks and config functions. Sitecore Installation Framework out of the box provides many tasks and config functions. If the out of box task doesn't provide the functionality we require, we can replace it by writing a custom task and replace the Sitecore provided tasks by using the -Force switch


Function Invoke-CopyTask {
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(Mandatory=$true)]

[ValidateScript({ Test-Path $_ })]
[string]$Source,

[Parameter(Mandatory=$true)]
[ValidateScript({ Test-Path $_ -IsValid })]
[string]$Destination
)
# function code
}

Register-SitecoreInstallExtension -Command Invoke-CopyTask -As Copy -Type Task –Force

Similarly, we can create new config functions  and register them to use them in the configuration file just as Sitecore config functions.

Function Invoke-JoinConfigFunction {
param(
[Parameter(Mandatory=$true)]
[psobject[]]$Values = @(),

[Parameter(Mandatory=$false)]
[string]$Delimiter = ","
)
# function code
}

Register-SitecoreInstallExtension -Command Invoke-JoinConfigFunction -As CustomJoin -Type ConfigFunction


While writing this blog, there is a good blog popped up in my twitter account where you can learn more about custom tasks, registrations and using them in modules of custom configuration files. A small snippet from the above blog on hot to use the custom config functions in configuration files using the modules is shown below

"Modules": [
    ]


Repeat 


For the reason SIF is highly configurable and extensible, it can be easily customized for different developers. Examples include developers who use Solr search as their default search instance to developers installing Sitecore commerce. SIF can be extended with various configurations that can make it all easy and streamlined to install by different developers.

Likewise, DevOps team can also use the SIF tool to customize the installation steps and configuration for individual environments like development, testing,  UAT and production where there could be environment specific configuration changes and services to be installed or stopped.

As stated prior, SIF presents a way to us for scripting the process flow as series of tasks. This makes automating deployments uncomplicated and stress-free. More love from process standardization team and predictable results through automation.


Repurpose


Last but not least, since Sitecore Install Framework internally depends on Sitecore Fundamentals modules and there are lot of tasks and config functions which are exposed by both SIF and fundamentals modules which are used in Sitecore install configuration files.

Most of these functions are pretty generic utility functions. This makes it easy to create a totally new configuration file without any traces to Sitecore tasks at all. This in my opinion is a huge win fir SIF as it establishes itself as a reusable framework.

So, those tasks which we used to write in plain PowerShell modules and scripts can now become powerful functions and tasks inside SIF ecosystem. And SIF can be used as a driver to automate those mundane tasks by organizing these tasks in order.

Conclusion

In summary, SIF is a powerful reusable framework. Sitecore developers and partners should start looking it as a bigger investment in their DevOps and process automation projects. In this blog I tried to reflect how I see SIF as a solid framework due to its inbuilt capabilities. If you desire to know more about SIF please follow the link that directs you to dev.sitecore.net. If you are looking for quick knowledge on SIF you can follow the MASTER SITECORE YouTube channel. There is an eight part SIF Fundamentals playlist


Please post your thoughts on the blog. Would love to know more on how you leveraged SIF in powerful ways. 

Comments

Post a Comment