TripleO Ansible project repository. Contains playbooks for use with TripleO OpenStack deployments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
3.4 KiB

# Copyright 2019 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
# 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.
# Check if os-net-config has run once, if yes, no need for the below workaround
- name: Find the ifcfg file generated by os-net-config
paths: /etc/sysconfig/network-scripts/
patterns: ifcfg-*
contains: "# This file is autogenerated by os-net-config"
register: os_net_ifcfg_files
# Provisioning Network workaround
# The script will be executed before os-net-config, in which case, only Provisioning network will have IP
# BOOTPROTO of all interface config files (except provisioning), will be set to "none" to avoid reboot failing to acquire IP on other networks
- name: Apply workaround for node reboot
- name: Update facts before attempting to disable interfaces
- name: Find the ifcfg files
paths: /etc/sysconfig/network-scripts/
patterns: ifcfg-*
register: ifcfg_files
# NOTE(mwhahaha): On computes collecting all the network facts is a huge
# performance issue. So let's only get the ansible facts for the ifcfg
# files which will avoid all the tap interfaces. This takes a while but
# results in less memory utilization for the rest of the deployment.
- name: Get ifcfg facts
- '!all'
- '!min'
- network
filter: "{{ 'ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') }}"
loop: "{{ ifcfg_files.files |flatten(levels=1)}}"
label: "{{ item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') }}"
- name: Replace BOOTPROTO to none for interfaces which does not have IP
dest: "{{ item.path }}"
regexp: '^BOOTPROTO=.*'
replace: 'BOOTPROTO=none'
- item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') != "lo"
# Ensure the interface information is available in the facts
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ] is defined
# This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
# Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4'] is undefined
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ]['ipv4'] is undefined
- "{{ ifcfg_files.files }}"
become: true
- os_net_ifcfg_files.matched is defined
- os_net_ifcfg_files.matched == 0
- name: Reboot debug message
msg: "Going to reboot the node after applying kernel args..."
# Reboot the node
- name: Reboot after kernel args update
post_reboot_delay: "{{ tripleo_kernel_post_reboot_delay }}"
reboot_timeout: "{{ tripleo_kernel_reboot_timeout }}"