Molecule: Failed to connect to the host via ssh: ssh: Could not resolve hostname

Created on 19 Oct 2020  ·  3Comments  ·  Source: ansible-community/molecule




Issue Type

  • Bug report

Molecule and Ansible details

ansible 2.10.2
  config file = None
  configured module search path = ['/Users/wdijkerman/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/wdijkerman/.venv3/lib/python3.8/site-packages/ansible
  executable location = /Users/wdijkerman/.venv3/bin/ansible
  python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]
molecule 3.1.3
   ansible==2.10.2 python==3.8

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

Desired Behavior

When I execute molecule create or molecule converge 1 or more containers are started and the role is executed inside the container,

Actual Behaviour

When I want to converge the Ansible role https://github.com/dj-wasabi/ansible-telegraf I get the following error:

molecule --debug create                                                                                                                                                             (docker-desktop/default)
--> Test matrix

└── default
    ├── dependency
    ├── create
    └── prepare

--> Scenario: 'default'
--> Action: 'dependency'
Skipping, missing the requirements file.
Skipping, missing the requirements file.
--> Scenario: 'default'
--> Action: 'create'
Skipping, create action has no playbook.
--> Scenario: 'default'
--> Action: 'prepare'
DEBUG: ANSIBLE ENVIRONMENT
---
ANSIBLE_COLLECTIONS_PATH: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/collections:/Users/wdijkerman/.ansible/collections:/usr/share/ansible/collections:/etc/ansible/collections
ANSIBLE_CONFIG: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/ansible.cfg
ANSIBLE_FILTER_PLUGINS: /Users/wdijkerman/.venv3/lib/python3.8/site-packages/molecule/provisioner/ansible/plugins/filter:/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/plugins/filter:/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/plugins/filter:/Users/wdijkerman/.ansible/plugins/filter:/usr/share/ansible/plugins/filter
ANSIBLE_LIBRARY: /Users/wdijkerman/.venv3/lib/python3.8/site-packages/molecule/provisioner/ansible/plugins/modules:/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/library:/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/library:/Users/wdijkerman/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
ANSIBLE_ROLES_PATH: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/roles:/Users/wdijkerman/code/dj-wasabi:/Users/wdijkerman/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles

DEBUG: MOLECULE ENVIRONMENT
---
MOLECULE_DEBUG: 'True'
MOLECULE_DEPENDENCY_NAME: galaxy
MOLECULE_DRIVER_NAME: delegated
MOLECULE_ENV_FILE: /Users/wdijkerman/code/dj-wasabi/ansible-telegraf/.env.yml
MOLECULE_EPHEMERAL_DIRECTORY: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default
MOLECULE_FILE: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/molecule.yml
MOLECULE_INSTANCE_CONFIG: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/instance_config.yml
MOLECULE_INVENTORY_FILE: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/inventory/ansible_inventory.yml
MOLECULE_PROJECT_DIRECTORY: /Users/wdijkerman/code/dj-wasabi/ansible-telegraf
MOLECULE_PROVISIONER_NAME: ansible
MOLECULE_SCENARIO_DIRECTORY: /Users/wdijkerman/code/dj-wasabi/ansible-telegraf/molecule/default
MOLECULE_SCENARIO_NAME: default
MOLECULE_STATE_FILE: /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/state.yml
MOLECULE_VERIFIER_NAME: testinfra
MOLECULE_VERIFIER_TEST_DIRECTORY: /Users/wdijkerman/code/dj-wasabi/ansible-telegraf/molecule/default/tests

DEBUG: SHELL REPLAY
ANSIBLE_COLLECTIONS_PATH=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/collections:/Users/wdijkerman/.ansible/collections:/usr/share/ansible/collections:/etc/ansible/collections ANSIBLE_CONFIG=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/ansible.cfg ANSIBLE_FILTER_PLUGINS=/Users/wdijkerman/.venv3/lib/python3.8/site-packages/molecule/provisioner/ansible/plugins/filter:/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/plugins/filter:/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/plugins/filter:/Users/wdijkerman/.ansible/plugins/filter:/usr/share/ansible/plugins/filter ANSIBLE_LIBRARY=/Users/wdijkerman/.venv3/lib/python3.8/site-packages/molecule/provisioner/ansible/plugins/modules:/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/library:/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/library:/Users/wdijkerman/.ansible/plugins/modules:/usr/share/ansible/plugins/modules ANSIBLE_ROLES_PATH=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/roles:/Users/wdijkerman/code/dj-wasabi:/Users/wdijkerman/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles MOLECULE_DEBUG=True MOLECULE_DEPENDENCY_NAME=galaxy MOLECULE_DRIVER_NAME=delegated MOLECULE_ENV_FILE=/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/.env.yml MOLECULE_EPHEMERAL_DIRECTORY=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default MOLECULE_FILE=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/molecule.yml MOLECULE_INSTANCE_CONFIG=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/instance_config.yml MOLECULE_INVENTORY_FILE=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/inventory/ansible_inventory.yml MOLECULE_PROJECT_DIRECTORY=/Users/wdijkerman/code/dj-wasabi/ansible-telegraf MOLECULE_PROVISIONER_NAME=ansible MOLECULE_SCENARIO_DIRECTORY=/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/molecule/default MOLECULE_SCENARIO_NAME=default MOLECULE_STATE_FILE=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/state.yml MOLECULE_VERIFIER_NAME=testinfra MOLECULE_VERIFIER_TEST_DIRECTORY=/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/molecule/default/tests

DEBUG: COMMAND
/Users/wdijkerman/.venv3/bin/ansible-playbook --skip-tags=molecule-notest,notest --diff --inventory=/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/inventory /Users/wdijkerman/code/dj-wasabi/ansible-telegraf/molecule/default/prepare.yml -vvv

    ansible-playbook 2.10.2
      config file = /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/ansible.cfg
      configured module search path = ['/Users/wdijkerman/.venv3/lib/python3.8/site-packages/molecule/provisioner/ansible/plugins/modules', '/Users/wdijkerman/.cache/molecule/ansible-telegraf/default/library', '/Users/wdijkerman/code/dj-wasabi/ansible-telegraf/library', '/Users/wdijkerman/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
      ansible python module location = /Users/wdijkerman/.venv3/lib/python3.8/site-packages/ansible
      executable location = /Users/wdijkerman/.venv3/bin/ansible-playbook
      python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]
    Using /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/ansible.cfg as config file
    host_list declined parsing /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/inventory/ansible_inventory.yml as it did not pass its verify_file() method
    script declined parsing /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/inventory/ansible_inventory.yml as it did not pass its verify_file() method
    Parsed /Users/wdijkerman/.cache/molecule/ansible-telegraf/default/inventory/ansible_inventory.yml inventory source with yaml plugin
    redirecting (type: modules) ansible.builtin.zypper to community.general.zypper

    PLAYBOOK: prepare.yml **********************************************************
    1 plays in /Users/wdijkerman/code/dj-wasabi/ansible-telegraf/molecule/default/prepare.yml

    PLAY [telegraf] ****************************************************************

    TASK [Gathering Facts] *********************************************************
    task path: /Users/wdijkerman/code/dj-wasabi/ansible-telegraf/molecule/default/prepare.yml:3
    <telegraf-centos8> ESTABLISH SSH CONNECTION FOR USER: None
    <telegraf-centos8> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/Users/wdijkerman/.ansible/cp/%h-%p-%r telegraf-centos8 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
    <telegraf-centos8> (255, b'', b'ssh: Could not resolve hostname telegraf-centos8: nodename nor servname provided, or not known\r\n')
fatal: [telegraf-centos8]: UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname telegraf-centos8: nodename nor servname provided, or not known",
    "unreachable": true
}

    PLAY RECAP *********************************************************************
    telegraf-centos8           : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0

ERROR:

(I had to manually remove the driver, name: docker line in order to get here. I would got this line {'driver': [{'name': ['unallowed value docker']}]})

Installation of both Ansible and Molecule are done in a clean VirtualEnv.

bug

Most helpful comment

@dj-wasabi

This is pending a fix in the documentation - I am also not 100% satisfied with the documentation as far as the driver coverage goes, so I will try to work on that as well

Happy that I could have help

All 3 comments

Hi @dj-wasabi - this is probably due to the recent changes in the molecule core - try to install the molecule-docker driver with pip and return the

driver:
  name: docker

lines

Hi @fourstepper

Thank you, this works! 👍
Seems that I have missed this in the documentation.

Will close this issue, kind regards,
Werner

@dj-wasabi

This is pending a fix in the documentation - I am also not 100% satisfied with the documentation as far as the driver coverage goes, so I will try to work on that as well

Happy that I could have help

Was this page helpful?
0 / 5 - 0 ratings