0

I'm getting the following when trying to run a playbook using the edgeos_commandmodule:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: ssh connection failed: ssh connect failed: Failed to resolve hostname inventory_hostname (Name or service not known)
fatal: [ADM-TEST]: FAILED! => {
  "changed": false,
  "module_stderr": "...",
  "module_stdout": "",
  "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
  "rc": 1
}

Where module_stderr contains:

Traceback (most recent call last):
  File "/home/lowkeylamb/.ansible/tmp/ansible-local-5582d70859ti/ansible-tmp-1663885370.4466758-5712-173536800348281/AnsiballZ_edgeos_command.py", line 107, in <module>
    _ansiballz_main()
  File "/home/lowkeylamb/.ansible/tmp/ansible-local-5582d70859ti/ansible-tmp-1663885370.4466758-5712-173536800348281/AnsiballZ_edgeos_command.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/lowkeylamb/.ansible/tmp/ansible-local-5582d70859ti/ansible-tmp-1663885370.4466758-5712-173536800348281/AnsiballZ_edgeos_command.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.network.plugins.modules.network.edgeos.edgeos_command', init_globals=dict(_module_fqn='ansible_collections.community.network.plugins.modules.network.edgeos.edgeos_command', _modlib_path=modlib_path),
  File "/usr/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.network.edgeos_command_payload_blc0ytld/ansible_community.network.edgeos_command_payload.zip/ansible_collections/community/network/plugins/modules/network/edgeos/edgeos_command.py", line 172, in <module>
  File "/tmp/ansible_community.network.edgeos_command_payload_blc0ytld/ansible_community.network.edgeos_command_payload.zip/ansible_collections/community/network/plugins/modules/network/edgeos/edgeos_command.py", line 143, in main
  File "/tmp/ansible_community.network.edgeos_command_payload_blc0ytld/ansible_community.network.edgeos_command_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py", line 78, in run_commands
  File "/tmp/ansible_community.network.edgeos_command_payload_blc0ytld/ansible_community.network.edgeos_command_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py", line 44, in get_connection
  File "/tmp/ansible_community.network.edgeos_command_payload_blc0ytld/ansible_community.network.edgeos_command_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py", line 58, in get_capabilities
  File "/tmp/ansible_community.network.edgeos_command_payload_blc0ytld/ansible_community.network.edgeos_command_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
ansible.module_utils.connection.ConnectionError: ssh connection failed: ssh connect failed: Failed to resolve hostname inventory_hostname (Name or service not known)

It's strange because I'm able to ssh into the target device just fine. I started with a simple playbook, and planned to build on it once I tested out the edgeos module

Here is the playbook:

- name: Update External ERX with latest firmware
  hosts: externaledgerouters
  remote_user: BudAdmin
  tasks:
    - name: Update ERX Firmwae
      community.network.edgeos_command:
       commands: show system image

In my ansible.cfg I have inventory pointing to the hosts file

Here's how I formatted my inventory in hosts file:

externaledgerouters:
 hosts:
  ADM-TEST:
   ansible_host: (ipv4 public IP)

Defined variables at the bottom in the same hosts file:

edgerouters:
 vars:
  ansible_user: (user)
  ansible_port: (port)
  ansible_pass: (password)
  ansible_connection: network_cli
  ansible_network_os: edgeos
 children:
  externaledgerouters:

I've tried numerous things to get this to run and I've hit a wall. Any assistance is appreciated.

1
  • 4
    The error message is Failed to resolve hostname inventory_hostname. It looks like you may be using the literal value inventory_hostname where you intend to be using a variable. WIthout seeing your playbook and inventory it's impossible to say where the problem is.
    – larsks
    Sep 23, 2022 at 2:35

1 Answer 1

-1

After sometime, I figured this out. There were a few issues with the .ssh/known_hosts file and running the playbooks for the edge routers

I regenerated the keys for both test hosts ssh-keygen R HOSTNAME - also had to add write permissions to local known_hosts file chmod +w ~/.ssh/known_hosts -- then I was able to run the playbooks without issue

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .