--- # 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 # # 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. # 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 find: 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 block: - name: Update facts before attempting to disable interfaces setup: - name: Find the ifcg files find: paths: /etc/sysconfig/network-scripts/ patterns: ifcfg-* register: ifcfg_files - name: Replace BOOTPROTO to none for interfaces which does not have IP replace: dest: "{{ item.path }}" regexp: '^BOOTPROTO=.*' replace: 'BOOTPROTO=none' when: - 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 with_items: - "{{ ifcfg_files.files }}" become: true when: - os_net_ifcfg_files.matched is defined - os_net_ifcfg_files.matched == 0 - name: Reboot debug message debug: msg: "Going to reboot the node after applying kernel args..." # Reboot the node - name: Reboot after kernel args update reboot: post_reboot_delay: "{{ tripleo_kernel_post_reboot_delay }}" reboot_timeout: "{{ tripleo_kernel_reboot_timeout }}"