Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edgeos_config or vyos_config time out #79

Closed
Akasurde opened this issue Jun 24, 2020 · 2 comments · Fixed by #80
Closed

edgeos_config or vyos_config time out #79

Akasurde opened this issue Jun 24, 2020 · 2 comments · Fixed by #80

Comments

@Akasurde
Copy link
Member

From @timpasternak on Jun 24, 2020 09:58

SUMMARY

When using either edgeos_config, vyos_config or vyos_facts, the command timeout gets triggered.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

edgeos_config, vyos_config, vyos_facts

ANSIBLE VERSION
ansible 2.9.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/usr/share/ansible']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
CONFIGURATION
<LEJ-RZW1-RTR-001> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-17044a8euidac `"&& mkdir /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-1ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=3600s -o ServerAliveInterval=25 -o ServerAliveCountMax=20
DEFAULT_ACTION_PLUGIN_PATH(/etc/ansible/ansible.cfg) = ['/usr/share/ansible_plugins/action_plugins']
DEFAULT_CALLBACK_PLUGIN_PATH(/etc/ansible/ansible.cfg) = ['/usr/share/ansible_plugins/callback_plugins']
DEFAULT_CONNECTION_PLUGIN_PATH(/etc/ansible/ansible.cfg) = ['/usr/share/ansible_plugins/connection_plugins']
DEFAULT_FILTER_PLUGIN_PATH(/etc/ansible/ansible.cfg) = ['/usr/share/ansible_plugins/filter_plugins']
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 100
DEFAULT_GATHERING(/etc/ansible/ansible.cfg) = implicit
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/etc/ansible/production']
DEFAULT_LOOKUP_PLUGIN_PATH(/etc/ansible/ansible.cfg) = ['/usr/share/ansible_plugins/lookup_plugins']
DEFAULT_MANAGED_STR(/etc/ansible/ansible.cfg) = This file is managed by Ansible, all changes will be lost.
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = ['/usr/share/ansible']
DEFAULT_POLL_INTERVAL(/etc/ansible/ansible.cfg) = 15
DEFAULT_PRIVATE_KEY_FILE(/etc/ansible/ansible.cfg) = /root/.ssh/id_rsa
DEFAULT_REMOTE_PORT(/etc/ansible/ansible.cfg) = 22
DEFAULT_REMOTE_USER(/etc/ansible/ansible.cfg) = root
DEFAULT_TIMEOUT(/etc/ansible/ansible.cfg) = 10
DEFAULT_TRANSPORT(/etc/ansible/ansible.cfg) = smart
DEFAULT_VARS_PLUGIN_PATH(/etc/ansible/ansible.cfg) = ['/usr/share/ansible_plugins/vars_plugins']
DEFAULT_VAULT_PASSWORD_FILE(/etc/ansible/ansible.cfg) = /root/.vault_pass
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False
DISPLAY_SKIPPED_HOSTS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/etc/ansible/ansible.cfg) = /usr/bin/python
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = False
SYSTEM_WARNINGS(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Ansible Host:
Debian-Version: 10.3
Kernel: 4.19.0-8-amd64

Router:
Ubiquiti Edgerouter 12P
Firmware-Version: v2.0.8-hotfix.1

STEPS TO REPRODUCE

Unbox Edgerouter, configure IP-Adress on eth9 (used here: 10.0.16.129). Add user with username ansible and a random password

- hosts: routers
  tasks:
  - name: set hostname
    edgeos_config:
      lines:
        - set hostname {{ inventory_hostname }}
    vars:
      ansible_command_timeout: 60
EXPECTED RESULTS

Hostname gets set to inventory_hostname and playbooks finishes without errors

ACTUAL RESULTS
<LEJ-RZW1-RTR-001> ESTABLISH LOCAL CONNECTION FOR USER: root
<LEJ-RZW1-RTR-001> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-17044a8euidac `"&& mkdir /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-17062-149925083849496 && echo ansible-tmp-1592990093.6965916-17062-149925083849496="` echo /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-17062-149925083849496 `" ) && sleep 0'
Using module file /usr/local/lib/python3.7/dist-packages/ansible/modules/network/vyos/vyos_facts.py
<LEJ-RZW1-RTR-001> PUT /root/.ansible/tmp/ansible-local-17044a8euidac/tmp680gcymy TO /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-17062-149925083849496/AnsiballZ_vyos_facts.py
<LEJ-RZW1-RTR-001> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-17062-149925083849496/ /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-17062-149925083849496/AnsiballZ_vyos_facts.py && sleep 0'
<LEJ-RZW1-RTR-001> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-17062-149925083849496/AnsiballZ_vyos_facts.py && sleep 0'
<LEJ-RZW1-RTR-001> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-17044a8euidac/ansible-tmp-1592990093.6965916-17062-149925083849496/ > /dev/null 2>&1 && sleep 0'

TASK [ubiquiti_router : Gather facts] **********************************************************************************************************************************************************************
task path: /etc/ansible/roles/ubiquiti_router/tasks/main.yml:2
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_vyos_facts_payload_jlmD_n/ansible_vyos_facts_payload.zip/ansible/module_utils/network/vyos/vyos.py", line 113, in run_commands
    response = connection.run_commands(commands=commands, check_rc=check_rc)
  File "/tmp/ansible_vyos_facts_payload_jlmD_n/ansible_vyos_facts_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [LEJ-RZW1-RTR-001]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "gather_network_resources": null,
            "gather_subset": [
                "all"
            ],
            "host": null,
            "password": null,
            "port": null,
            "provider": null,
            "ssh_keyfile": null,
            "timeout": null,
            "username": null
        }
    },
    "msg": "command timeout triggered, timeout value is 60 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."
}

Copied from original issue: ansible/ansible#70257

@timpasternak
Copy link
Contributor

Some more insight. I tried around a bit and found the following things:

when doing only edgeos_facts, the module works and returns valid values:

ok: [LEJ-RZW1-RTR-001] => {
    "TEST_VAR": {
        "ansible_facts": {
            "ansible_net_gather_subset": [
                "neighbors",
                "default"
            ],
            "ansible_net_hostname": "\u001b=\nEdgeRouter-12\u001b[m",
            "ansible_net_model": "EdgeRouter 12",
            "ansible_net_serialnum": "<redacted>\u001b[m",
            "ansible_net_version": "2.0.8-hotfix.1\u001b[m"
        },
        "changed": false,
        "failed": false
    }
}

As soon as I add config as subset, it fails. In my eyes, it's the show configuration commands thats breaking everything.
Reason:

When entering this command manually into the EdgeOS Shell, the following command gets spawned:

ansible   3051  0.0  0.0   2388   460 pts/1    S+   07:22   0:00 less --buffers=64 --auto-buffers --no-lessopen --QUIT-AT-EOF --quit-if-one-screen --RAW-CONTROL-CHARS --squeeze-blank-lines --no-init

When executing the ansible playbook with the block:

- name: Gather facts
  edgeos_facts:
    gather_subset: all

There is the same process:

ansible   3941  0.0  0.0   2388   472 pts/2    S+   07:37   0:00 less --buffers=64 --auto-buffers --no-lessopen --QUIT-AT-EOF --quit-if-one-screen --RAW-CONTROL-CHARS --squeeze-blank-lines --no-init

Atleast for edgeos_facts, I could circumvent the issue by changing the following line:
https://github.com/ansible-collections/community.network/blob/master/plugins/modules/network/edgeos/edgeos_facts.py#L143

If you set COMMANDS to:

    COMMANDS = [
        'show configuration commands',
        'show system commit',
    ]

atleast edgeos_facts works.
See here

With the following diff, even edgeos_config works:
master...timpasternak:master

I'm not sure whether or not this is an acceptable solution (the diff with simply adding |cat) and will try to test it against 1.9.7

@timpasternak
Copy link
Contributor

Sadly, I can't test against version 1.9.7. But with version 1.10.5 it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants