Molecule GCE plugin - use existing private key

I want to set the SSH private key that Molecule GCE plugin uses.

Even though at molecule-gce/src/molecule_gce/driver.py at main · ansible-community/molecule-gce · GitHub states “This driver assumes the developer has deployed project wide ssh key”. However at molecule-gce/src/molecule_gce/playbooks/tasks/create_linux_instance.yml at main · ansible-community/molecule-gce · GitHub a new SSH key is created and written to "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key".

How can I provide the path to the SSH private key and username that Molecule should use?

If I add something like the following to molecule.yml, then run molecule create && molecule converge , SSH authentication using the provided keyfile works. However with molecule test, SSH authentication fails.

provisioner:
  connection_options:
    ansible_ssh_common_args: '-J jumphost'
    ansible_private_key_file: /host-home-folder/.ssh/id_rsa_jenkins
    ansible_user: jenkins
1 Like

were you able to figure a workaround? i’m encountering the same issue

I didn’t find one that worked in my environment.