Skip to content

Commit

Permalink
Add support for is_authentication_with_ssh_key (#1736)
Browse files Browse the repository at this point in the history
* Add support 'is_authentication_with_ssh_key' to azure_rm_devtestlabvirtualmachine.py

* Update azure_rm_devtestlabvirtualmachine_info.py

* Add constraint
  • Loading branch information
Fred-sun authored Nov 13, 2024
1 parent 5eb7ef9 commit cb8cf33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 16 additions & 2 deletions plugins/modules/azure_rm_devtestlabvirtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
choices:
- standard
- premium
is_authentication_with_ssh_key:
description:
- Indicates whether this virtual machine uses an SSH key for authentication.
- I(is_authentication_with_ssh_key=True) when I(ssh_key) is set for ssh authentication.
type: bool
state:
description:
- Assert the state of the Virtual Machine.
Expand Down Expand Up @@ -322,6 +327,9 @@ def __init__(self):
type='str',
choices=['standard', 'premium']
),
is_authentication_with_ssh_key=dict(
type='bool'
),
state=dict(
type='str',
default='present',
Expand All @@ -330,8 +338,8 @@ def __init__(self):
)

required_if = [
('state', 'present', [
'image', 'lab_subnet', 'vm_size', 'os_type'])
('state', 'present', ['image', 'lab_subnet', 'vm_size', 'os_type']),
('is_authentication_with_ssh_key', True, ['ssh_key'])
]

self.resource_group = None
Expand Down Expand Up @@ -431,6 +439,12 @@ def exec_module(self, **kwargs):
if len(self.lab_virtual_machine.get('artifacts', [])) != old_response['artifact_deployment_status']['total_artifacts']:
self.module.warn("Property 'artifacts' cannot be changed")

if self.lab_virtual_machine.get('is_authentication_with_ssh_key') is not None:
if bool(old_response['is_authentication_with_ssh_key']) != bool(self.lab_virtual_machine['is_authentication_with_ssh_key']):
self.module.warn("Property 'is_authentication_with_ssh_key' cannot be changed")
else:
self.lab_virtual_machine['is_authentication_with_ssh_key'] = old_response['is_authentication_with_ssh_key']

if self.lab_virtual_machine.get('disallow_public_ip_address') is not None:
if old_response['disallow_public_ip_address'] != self.lab_virtual_machine.get('disallow_public_ip_address'):
self.module.warn("Property 'disallow_public_ip_address' cannot be changed")
Expand Down
9 changes: 8 additions & 1 deletion plugins/modules/azure_rm_devtestlabvirtualmachine_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
returned: always
type: str
sample: myVm
is_authentication_with_ssh_key:
description:
- Indicates whether this virtual machine uses an SSH key for authentication.
type: bool
returned: always
sample: False
notes:
description:
- Notes of the virtual machine.
Expand Down Expand Up @@ -314,7 +320,8 @@ def format_response(self, item):
'compute_vm_name': self.parse_resource_to_dict(d.get('compute_id')).get('name'),
'fqdn': d.get('fqdn'),
'provisioning_state': d.get('provisioning_state'),
'tags': d.get('tags', None)
'tags': d.get('tags', None),
'is_authentication_with_ssh_key': d.get('is_authentication_with_ssh_key')
}
return d

Expand Down

0 comments on commit cb8cf33

Please sign in to comment.