Last active
November 16, 2024 02:34
-
-
Save oxagast/3ac9e5681039e2917e22163a5a60f2c2 to your computer and use it in GitHub Desktop.
Ansible online connectivity check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creator: oxagast | |
# | |
# usage: | |
# ansible-playbook -i inventory.yml conn_chk.yml --extra-vars "hostname=google.com" | |
# or.. | |
# ansible-playbook -i inventory.yml conn_chk.yml | |
--- | |
- hosts: linux | |
gather_facts: False | |
connection: local | |
vars: | |
ip: "{{ hostname | default('8.8.8.8', true) }}" | |
tasks: | |
- name: Pinging host {{ ip }} | |
shell: ping -w 3 -c 1 {{ ip }} | |
ignore_errors: false | |
- hosts: freebsd | |
gather_facts: False | |
connection: local | |
vars: | |
ip: "{{ hostname | default('8.8.8.8', true) }}" | |
tasks: | |
- name: Pinging host {{ ip }} | |
shell: ping -t 3 -c 1 {{ ip }} | |
ignore_errors: false | |
- hosts: windows | |
gather_facts: False | |
connection: local | |
vars: | |
ip: "{{ hostname | default('8.8.8.8', true) }}" | |
tasks: | |
- name: Pinging host {{ ip }} | |
win_command: ping -w 3 -n 1 {{ ip }} | |
ignore_errors: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment