利用ansible檢測網路連通性 多個網段多IP

2022-09-11 13:27:22 字數 1822 閱讀 6398

在雲平台的運維中,有時會遇到某個節點的乙個ip無法連通導致雲平台故障,比較常見的是ceph的某個osd節點storage網路不通導致osd全部down.為了快速檢測雲平台全部網路的連通性,利用ansible自帶的的fact,寫了個playbook,特記錄下.

1 每台主機三個網絡卡

2  指令碼內容

3 測試 

3.1 關掉minion1的eth2網絡卡

3.2 執行檢測指令碼

3.3 測試結果

補充乙個playbook,利用fact的ansible_all_ipv4_addresses變數

---- hosts: all

become: yes

become_user: root

become_method: sudo

tasks:

- block:

- name: check the net connection(ping)

shell: ping -c 2 }

register: netresult

ignore_errors: yes

with_items:

- "}"

when: item !='240.0.0.1'          #增加過濾不想檢測的ip

- debug:

var=netresult

- name: get the no ping  ipadress

shell: |

echo "ip } is unreachable" >>/root/noping.txt

with_items:

"}"when: item.item !='240.0.0.1' and item.rc !=0

delegate_to: localhost

VB6實現網路連通檢測

private sub form load if isconnected true then msgbox 您已經連通了inter end if if isconnected false then msgbox 您還沒有連通 inter end if end sub option explicit ...

封裝Linux下網路連通性檢測函式

我們在編寫網路通訊程式的時候,不論作為 服務端還是 客戶端,常常需要確保實時檢測與對方的連線狀態,呼叫select 函式監控 檔案描述符 套接字 的連線狀態是最普遍的方法,但是當遇到對方斷電或者網路線路突然斷開的情況,select函式將接收不到來自對方的斷開訊息,所以維護著這一連線的檔案描述符 套接...

設定ansible與windows連通性

1.確認powershell的版本,必須是3.0以上 2.確認winrm是否開啟 命令 winrm quickconfig 3.在windows配置winrm 執行命令 4.在ansible主機上安裝pywinrm模組 首先安裝pip centos7上 安裝epel源 yum y install e...