Description
Choose the Ansible lock level can_not_delete to prevent registry deletion, or read_only to block management changes as well. Resources inherit locks from their resource group and subscription.
Potential impact
Registry deletion or a configuration change can interrupt image pulls. A read-only lock applied to the whole group can also block routine updates to its other resources.
Remediation
Check the locks the registry already inherits and apply the required level at the narrowest suitable scope. Verify the effective lock after applying it. Use image attributes and access permissions separately to control image creation, overwriting and deletion.
Examples
Use a globally unique registry name in the existing myResourceGroup. Install azure.azcollection. For the short module names shown, include it in the play’s collections or use the fully qualified module names.
Before
- name: Create an azure container registry
azure_rm_containerregistry:
name: myRegistry
location: eastus
resource_group: myResourceGroup
admin_user_enabled: true
sku: Premium
After
- name: Create an azure container registry
azure_rm_containerregistry:
name: myRegistry
location: eastus
resource_group: myResourceGroup
admin_user_enabled: true
sku: Premium
- name: Create a lock for a resource group
azure_rm_lock:
resource_group: myResourceGroup
name: myLock
level: read_only
The second task sets myLock on myResourceGroup. The registry and the group’s other resources all inherit read_only.