- name: stateless nat acceptance gather_facts: no hosts: "{{target}}" become: "{{ become_var|default(false) }}" tasks: - debug: var=type run_once: true - shell: executable: /bin/bash cmd: | route -n | grep ^0.0.0.0 || true register: output changed_when: false check_mode: false - debug: var=output.stdout - assert: that: output.stdout != '' when: > natgw is defined or not type.startswith('full') - assert: that: output.stdout == '' when: > natgw is undefined and type.startswith('full') - delegate_to: localhost run_once: true shell: executable: /bin/bash cmd: | set -e if [[ {{ type.endswith('-many') }} == True ]]; then nmap -p 2201 192.168.122.102 nmap -p 2203 192.168.122.102 ssh 192.168.122.102 -l root -p 2201 hostname ssh 192.168.122.102 -l root -p 2203 hostname else nmap -p 22 192.168.122.102 ssh 192.168.122.102 -l root hostname fi register: output changed_when: false check_mode: false - debug: var=output.stdout run_once: true