mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 20:54:24 -07:00
Fix listen-port-facts crash
This commit is contained in:
parent
6d67546902
commit
f2c12576d5
2 changed files with 32 additions and 1 deletions
|
@ -397,7 +397,7 @@ def main():
|
||||||
break
|
break
|
||||||
|
|
||||||
if bin_path is None:
|
if bin_path is None:
|
||||||
raise EnvironmentError(msg='Unable to find any of the supported commands in PATH: {0}'.format(", ".join(sorted(commands_map))))
|
raise EnvironmentError('Unable to find any of the supported commands in PATH: {0}'.format(", ".join(sorted(commands_map))))
|
||||||
|
|
||||||
# which ports are listening for connections?
|
# which ports are listening for connections?
|
||||||
args = commands_map[command]['args']
|
args = commands_map[command]['args']
|
||||||
|
|
|
@ -110,3 +110,34 @@
|
||||||
loop: "{{ [tcp_listen, udp_listen]|flatten }}"
|
loop: "{{ [tcp_listen, udp_listen]|flatten }}"
|
||||||
when: item.name == 'nc'
|
when: item.name == 'nc'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
|
|
||||||
|
- name: Remove netstat and ss dependencies to simulate missing executables
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- net-tools
|
||||||
|
- iproute2
|
||||||
|
state: absent
|
||||||
|
ignore_errors: true
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
|
- name: Trigger listen_ports_facts with missing tools
|
||||||
|
community.general.listen_ports_facts:
|
||||||
|
register: listen_ports_failure_result
|
||||||
|
ignore_errors: true
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
|
- name: Assert graceful failure when dependencies are missing
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- listen_ports_failure_result.failed
|
||||||
|
- "'Unable to find any of the supported commands' in listen_ports_failure_result.msg"
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
|
- name: Reinstall netstat and ss dependencies after test
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- net-tools
|
||||||
|
- iproute2
|
||||||
|
state: present
|
||||||
|
when: ansible_os_family == "Debian"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue