Closed TheSpy0 closed 2 weeks ago
@TheSpy0 Sorry for the trouble, this is a bug, if you need ssh authorization login, you need to set I(is_authentication_with_ssh_key=True), this parameter has been added in #1736. Thank you!
sample as:
- name: Create a VM within the lab
azure.azcollection.azure_rm_devtestlabvirtualmachine:
name: "{{ vm_name }}"
lab_name: "{{ lab_name }}"
resource_group: "{{ resource_group_name }}"
notes: Virtual machine notes
os_type: linux
vm_size: Standard_A2_v2
user_name: dtladmin
password: Th!s1saP@ssw0rd
ssh_key: "contents of ssh key" # Also tried "{{ lookup('file', '/path/to/pub/key.pub') }}"
lab_subnet:
virtual_network_name: "{{ vn_name }}"
name: "{{ vn_name }}Subnet"
disallow_public_ip_address: false
is_authentication_with_ssh_key: True
image:
offer: RHEL
publisher: RedHat
sku: 8-lvm
os_type: Linux
version: latest
allow_claim: false
@Fred-sun Thank you. To be able to test this parameter, I just need to clone your repository in the project directory and use the Add-support-is_authentication_with_ssh_key
branch, correct?
Yes! Please!
It works for me when using your updated collection. Thank you!
SUMMARY
When creating a virtual machine inside a DevTest Lab, an SSH public key is not added to the
authorized_keys
file when thessh_key
parameter is set using either a path to the public key, the contents of the key (have tried as a string and using a file lookup), or the name of an SSH key stored in Azure. The module documentation was not clear on how it is supposed to be set.ISSUE TYPE
COMPONENT NAME
azure_rm_devtestlabvirtualmachine
moduleANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Fedora release 39 (Thirty Nine)
STEPS TO REPRODUCE
Run a playbook with the task below defined, using either the contents of the SSH key, or a lookup plugin with the file path to the key.
EXPECTED RESULTS
Expecting there to be a public key in
~/.ssh/authorized_keys
file.ACTUAL RESULTS
The
~/.ssh/authorized_keys
file is present but empty.