- name: Update default route hosts: all become: yes user: root vars_prompt: - name: "gateway_ip" prompt: "Enter the gateway IP address" private: no tasks: - name: Delete the default route command: ip route delete default ignore_errors: yes # Ignore errors in case the default route does not exist - name: Add the new default route command: ip route add default via {{ gateway_ip }}