Gallery › Compute › Azure Community Policy
Enforce Redhat hybrid use benefit
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy will enforce usage of hybrid use benefit on RedHat bring-your-own-subscription (BYOS) operating systems.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 88 lines
{
"name": "23aee5bc-ea1a-43f5-b5ff-4566562de5ee",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Enforce Redhat hybrid use benefit",
"description": "This policy will enforce usage of hybrid use benefit on RedHat bring-your-own-subscription (BYOS) operating systems.",
"metadata": {
"version": "1.0.0",
"category": "Compute"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"in": [
"Microsoft.Compute/virtualMachines",
"Microsoft.Compute/VirtualMachineScaleSets"
]
},
{
"field": "Microsoft.Compute/imagePublisher",
"equals": "redhat"
},
{
"field": "Microsoft.Compute/imageOffer",
"equals": "rhel-byos"
},
{
"field": "Microsoft.Compute/imageSKU",
"in": [
"rhel-lvm74",
"rhel-lvm75",
"rhel-lvm76",
"rhel-lvm76-gen2",
"rhel-lvm77",
"rhel-lvm77-gen2",
"rhel-lvm78",
"rhel-lvm78-gen2",
"rhel-lvm79",
"rhel-lvm79-gen2",
"rhel-lvm8",
"rhel-lvm8-gen2",
"rhel-lvm81",
"rhel-lvm81-gen2",
"rhel-lvm82",
"rhel-lvm82-gen2",
"rhel-lvm83",
"rhel-lvm83-gen2",
"rhel-lvm84",
"rhel-lvm84-gen2",
"rhel-lvm85",
"rhel-lvm85-gen2",
"rhel-raw-ci76",
"rhel-raw69",
"rhel-raw72",
"rhel-raw75",
"rhel-raw76"
]
},
{
"field": "Microsoft.Compute/licenseType",
"notEquals": "RHEL_BYOS"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw23aee5bc-ea1a-43f5-b5ff-4566562de5ee.bylaw.ps1 · 34 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '23aee5bc-ea1a-43f5-b5ff-4566562de5ee' {
Properties @{
DisplayName = 'Enforce Redhat hybrid use benefit'
Description = 'This policy will enforce usage of hybrid use benefit on RedHat bring-your-own-subscription (BYOS) operating systems.'
Version = '1.0.0'
Category = 'Compute'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource * {
When {
Field type | Must -BeIn @('Microsoft.Compute/virtualMachines', 'Microsoft.Compute/VirtualMachineScaleSets')
Field 'Microsoft.Compute/imagePublisher' | Must -Be 'redhat'
Field 'Microsoft.Compute/imageOffer' | Must -Be 'rhel-byos'
Field 'Microsoft.Compute/imageSKU' | Must -BeIn @('rhel-lvm74', 'rhel-lvm75', 'rhel-lvm76', 'rhel-lvm76-gen2', 'rhel-lvm77', 'rhel-lvm77-gen2', 'rhel-lvm78', 'rhel-lvm78-gen2', 'rhel-lvm79', 'rhel-lvm79-gen2', 'rhel-lvm8', 'rhel-lvm8-gen2', 'rhel-lvm81', 'rhel-lvm81-gen2', 'rhel-lvm82', 'rhel-lvm82-gen2', 'rhel-lvm83', 'rhel-lvm83-gen2', 'rhel-lvm84', 'rhel-lvm84-gen2', 'rhel-lvm85', 'rhel-lvm85-gen2', 'rhel-raw-ci76', 'rhel-raw69', 'rhel-raw72', 'rhel-raw75', 'rhel-raw76')
}
Require 'licenseType is RHEL_BYOS' {
Field 'Microsoft.Compute/licenseType' | Must -Be 'RHEL_BYOS'
}
}
Effect (Param Effect)
}Source: policyDefinitions/Compute/enforce-redhat-hybrid-use-benefit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw