46 lines
1.6 KiB
YAML
46 lines
1.6 KiB
YAML
---
|
|
# Copyright 2021 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
- name: Set IP options
|
|
set_fact:
|
|
_sed_opts: "'s/.*dev \\([^ ]*\\).*/\\1/') "
|
|
_ping_cmd: "{{ (':' in controller) | ternary('ping6', 'ping') }}"
|
|
- name: Lookup interface information
|
|
register: _nic_mtu
|
|
shell: |
|
|
INT=$(ip ro get {{ controller }} | head -1 | sed '{{ _sed_opts }}')
|
|
MTU=$(cat /sys/class/net/${INT}/mtu 2>/dev/null || echo "0")
|
|
echo "$INT $MTU"
|
|
- name: Set interface vars
|
|
set_fact:
|
|
_nic: "{{ _nic_mtu.get('stdout', '').split(' ')[0] | default('lo') }}"
|
|
_mtu: "{{ _nic_mtu.get('stdout', '').split(' ')[1] | default(0) | int - 28 }}"
|
|
- name: Network availability validation block
|
|
block:
|
|
- name: Check IP responsiveness
|
|
command: "{{ _ping_cmd }} -w 10 -c 1 {{ controller }}"
|
|
retries: 10
|
|
delay: 60
|
|
changed_when: false
|
|
|
|
- name: Validate packet with {{ _mtu }} MTU size can reach controller from {{ _nic }}
|
|
command: "{{ _ping_cmd }} -w 10 -s {{ _mtu }} -c 1 {{ controller }}"
|
|
retries: 10
|
|
delay: 60
|
|
changed_when: false
|
|
when: _mtu | int > 0
|
|
when: _nic != 'lo'
|