Skip to content

Commit

Permalink
Add notes to azure_rm_lock.py (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred-sun authored Mar 30, 2023
1 parent 0e1fba3 commit e973c58
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions plugins/modules/azure_rm_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
- Mutually exclusive with I(managed_resource_id).
- If neither I(managed_resource_id) or I(resource_group) are specified, manage a lock for the current subscription.
type: str
notes:
description:
- Notes about the lock. Maximum of 512 characters.
type: str
state:
description:
- State of the lock.
Expand Down Expand Up @@ -79,6 +83,7 @@
azure_rm_lock:
resource_group: myResourceGroup
name: myLock
notes: description_lock
level: read_only
- name: Create a lock for a subscription
Expand Down Expand Up @@ -113,6 +118,7 @@ def __init__(self):
state=dict(type='str', default='present', choices=['present', 'absent']),
resource_group=dict(type='str'),
managed_resource_id=dict(type='str'),
notes=dict(type='str'),
level=dict(type='str', choices=['can_not_delete', 'read_only'])
)

Expand All @@ -131,6 +137,7 @@ def __init__(self):
self.state = None
self.level = None
self.resource_group = None
self.note = None
self.managed_resource_id = None

super(AzureRMLock, self).__init__(self.module_arg_spec,
Expand All @@ -152,11 +159,17 @@ def exec_module(self, **kwargs):
lock_level = getattr(self.lock_models.LockLevel, self.level)
if not lock:
changed = True
lock = self.lock_models.ManagementLockObject(level=lock_level)
elif lock.level != lock_level:
self.log('Lock level changed')
lock.level = lock_level
changed = True
lock = self.lock_models.ManagementLockObject(level=lock_level, notes=self.notes)
else:
if lock.level != lock_level:
self.log('Lock level changed')
lock.level = lock_level
changed = True
if lock.notes != self.notes:
self.log('Lock notes changed')
lock.notes = self.notes
changed = True

if not self.check_mode:
lock = self.create_or_update_lock(scope, lock)
self.results['id'] = lock.id
Expand Down

0 comments on commit e973c58

Please sign in to comment.