Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support is authentication with ssh key #1736

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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