--- # Copyright (c) Ansible Project # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later - name: Run api module community.routeros.api: username: foo password: bar hostname: localhost path: ip address ignore_errors: true register: result - name: Validate result assert: that: - result is failed - result.msg in potential_errors vars: potential_errors: - "Error while connecting: [Errno 111] Connection refused" - "Error while connecting: [Errno 99] Cannot assign requested address" - name: Run command module community.routeros.command: commands: - /ip address print vars: ansible_host: localhost ansible_connection: ansible.netcommon.network_cli ansible_network_os: community.routeros.routeros ansible_user: foo ansible_ssh_pass: bar ansible_ssh_port: 12349 ignore_errors: true register: result - name: Validate result assert: that: - result is failed - "'Unable to connect to port 12349 ' in result.msg or 'ssh connect failed: Connection refused' in result.msg"