tripleo-ansible/tripleo_ansible/roles/tripleo_nodes_validation/tasks/main.yml

58 lines
1.8 KiB
YAML

---
# Copyright 2020 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: Collect default network fact
setup:
gather_subset:
- '!all'
- '!min'
- network
filter: 'ansible_default_ipv4'
- name: Check Default IPv4 Gateway availability
command: "ping -w 10 -c 1 {{ ansible_facts.default_ipv4.gateway }}"
retries: 10
delay: 60
changed_when: false
when:
- tripleo_nodes_validation_validate_gateway_icmp|bool
- ansible_facts.default_ipv4 is defined
- ansible_facts.default_ipv4.gateway is defined
- name: Check Controllers availability
include_tasks: ping.yml
loop_control:
loop_var: controller
loop: "{{ tripleo_nodes_validation_ping_test_ips }}"
when:
- tripleo_nodes_validation_validate_controllers_icmp|bool
- tripleo_nodes_validation_ping_test_ips | length > 0
- name: Verify the configured FQDN vs /etc/hosts
shell: |
HOSTNAME=$(hostname)
SHORT_NAME=$(hostname -s)
FQDN_FROM_HOSTS=$(awk '$3 == "'${SHORT_NAME}'"{print $2}' /etc/hosts)
if [[ $HOSTNAME != $FQDN_FROM_HOSTS ]]; then
echo "FAILURE"
echo -e "System hostname: ${HOSTNAME}\nEntry from /etc/hosts: ${FQDN_FROM_HOSTS}\n"
exit 1
fi
exit 0
changed_when: false
when:
- tripleo_nodes_validation_validate_fqdn|bool