-
Notifications
You must be signed in to change notification settings - Fork 169
Description
My SSH username on JunOS devices is different from my laptop username. My ~/.ssh/config file contains a User entry to set the correct username - this works correctly for SSH sessions, the ansible junipernetworks.junos collection, and Python code calling PyEZ device directly.
Attempting to use the collection juniper.device, the SSH username from the ssh config file is not passed and instead my laptop username is passed (as the default username of the user running the Ansible).
tasks:
- name: "Get facts"
juniper.device.facts:
register: response
and the output shows:
ssh_config: null
ssh_private_key_file: null
timeout: 10
user: <wrong username>
msg: 'Unable to make a PyEZ connection: ConnectAuthError(<hostname>)'
The docs for the module say the user parameter has to be specified - This option is required, but does not have to be specified explicitly by the user due to the algorithm for determining the default value.. This explains the behaviour I'm seeing (and why running PyEZ from python works as expected) but means it's never possible to use the ssh_config.
Where it is reasonable and valid to have PyEZ identify the correct username from the ssh_config file, it feels wrong to enforce specifying a user within the Ansible and not being able to override this. Explicitly setting user to None gives an error missing required arguments: user.