This Ansible guide discusses several approaches on how to set different
role default variables
based / depending on the host operating system aka ansible_distribution
/
ansible_facts.distribution
or other variables. For example, a role
variable image_uri
should point to the latest cloud image for the host.
For CentOS 8
or Red Hat Enterprise Linux (RHEL) 8
the default value
should be:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host 'throw' | |
try | |
{ | |
try | |
{ | |
throw "exception" | |
} | |
catch | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -RunAsAdministrator | |
function Uninstall-Pester ([switch]$All) { | |
if ([IntPtr]::Size * 8 -ne 64) { throw "Run this script from 64bit PowerShell." } | |
#Requires -RunAsAdministrator | |
$pesterPaths = foreach ($programFiles in ($env:ProgramFiles, ${env:ProgramFiles(x86)})) { | |
$path = "$programFiles\WindowsPowerShell\Modules\Pester" | |
if ($null -ne $programFiles -and (Test-Path $path)) { | |
if ($All) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Binary search algorithm with O(logn) complexity written in PowerShell | |
function Invoke-BinarySearch { | |
[CmdletBinding()] | |
[OutputType([int])] | |
param ( | |
# Array which contains value to search, needs to be sorted | |
[Parameter(Mandatory)] | |
[int[]] | |
$Numbers, |