在云平台的运维中,有时会遇到某个节点的一个IP无法连通导致云平台故障,比较常见的是ceph的某个osd节点storage网络不通导致osd全部down.为了快速检测云平台全部网络的连通性,利用ansible自带的的fact,写了个playbook,特记录下.
1 每台主机三个网卡
2 脚本内容
---
- hosts: all
#vars_prompt:
# - name: share_user
# prompt: "input share_user"
tasks:
- block
- name: restart acpid service
service: name=acpid state=restarted
- name: get the network connection ip
shell: |
ping -c 2 "{
{ hostvars[item[0]]['ansible_' + item[1]].ipv4.address }}"
register: netinfo
ignore_errors: yes
with_nested: