From 1dd5e71cff1573b9c6fd946f9cbacf25ff12331d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Oliveira?= Date: Sat, 23 Jan 2021 11:45:28 +0100 Subject: [PATCH] lldp - use get_bin_path to locate the lldpctl executable (#1643) * lldp - use get_bin_path to locate the lldpctl executable * This prevents failed executions FAILED! => {"changed": false, "cmd": "lldpctl -f keyvalue", "msg": "[Errno 2] No such file or directory", "rc": 2} on hosts (servers and switches) with lldpd installed and running. * Update changelogs/fragments/lldp-use-get_bin_path-to-locate-the-lldpctl-executable.yaml Specify pull request id and minor formatting tweaks Co-authored-by: Felix Fontein * Update changelogs/fragments/lldp-use-get_bin_path-to-locate-the-lldpctl-executable.yaml Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../lldp-use-get_bin_path-to-locate-the-lldpctl-executable.yaml | 2 ++ plugins/modules/net_tools/lldp.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/lldp-use-get_bin_path-to-locate-the-lldpctl-executable.yaml diff --git a/changelogs/fragments/lldp-use-get_bin_path-to-locate-the-lldpctl-executable.yaml b/changelogs/fragments/lldp-use-get_bin_path-to-locate-the-lldpctl-executable.yaml new file mode 100644 index 0000000000..4fefd3dd87 --- /dev/null +++ b/changelogs/fragments/lldp-use-get_bin_path-to-locate-the-lldpctl-executable.yaml @@ -0,0 +1,2 @@ +bugfixes: + - lldp - use ``get_bin_path`` to locate the ``lldpctl`` executable (https://github.com/ansible-collections/community.general/pull/1643). diff --git a/plugins/modules/net_tools/lldp.py b/plugins/modules/net_tools/lldp.py index 41853eb864..ae86db4088 100644 --- a/plugins/modules/net_tools/lldp.py +++ b/plugins/modules/net_tools/lldp.py @@ -41,7 +41,7 @@ from ansible.module_utils.basic import AnsibleModule def gather_lldp(module): - cmd = ['lldpctl', '-f', 'keyvalue'] + cmd = [module.get_bin_path('lldpctl'), '-f', 'keyvalue'] rc, output, err = module.run_command(cmd) if output: output_dict = {}