# display some per host info using 'magic variables' # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html # https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html # https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_delegation.html # --- - name: "03 - display some per host info" hosts: all # hosts: localhost # connection: local tasks: - name: Print the gateway for each host when defined ansible.builtin.debug: msg: System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }} when: ansible_default_ipv4.gateway is defined