ansible-community / molecule-plugins

Collection on molecule plugins
MIT License
101 stars 67 forks source link

SSH into EC2 instance fails with permission error #152

Open nandac opened 1 year ago

nandac commented 1 year ago

Dear Folks,

I am new to molecule and I am trying my hand at using the ec2 driver plugin.

I am able to create the EC2 instance and the required security group but have not been able to successfully login into the machine.

I keep getting the following error message when running molecule create. fatal: [molecule-instance]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Waiting on browser...\nBrowser step completed successfully.\nerror: Could not resolve: REDACTED: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).", "unreachable": true}

I have only made minimal customizations such as disabling the creation of a public IP so that I may use a private IP instead.

I have pasted the settings I have in my molecule.yml file below:

---
dependency:
  name: galaxy
driver:
  name: ec2
platforms:
  - name: molecule-instance
    assign_public_ip: false
    connection_options:
      ansible_python_interpereter: /usr/bin/python
    image_name: "<REDACTED>"
    image_owner: ["<REDACTED>"]
    instance_type: t3.micro
    region: "<REDACTED>"
    ssh_user: ec2-user
    vpc_id: "<REDACTED>"
    vpc_subnet_id: "<REDACTED>"
    tags:
      Name: molecule-instance
provisioner:
  name: ansible
verifier:
  name: ansible

I know that this issue probably relates more to the Linux AMI I am using which is a slightly customized version of Amazon Linux 2 but I hope you may be able to shed some light.

I tried both the ec2 and cloud-init for the key_inject_methods field but the SSH login does not work.

I look forward to your reply.

Many thanks.

zhan9san commented 7 months ago

@nandac

Would you mind providing more detailed log of molecule create?