
The playbooks were running a bunch of common tasks that could be simplified and unified into a single common_task include. This PR moves the interface look into a single place and cleans up the duplicate code within the cinder, neutron, and nova playbooks. Change-Id: I46f2812670ea17b9ff28ef6f054d82fd6dccc999 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
50 lines
2.0 KiB
YAML
50 lines
2.0 KiB
YAML
---
|
|
# Copyright 2017, Rackspace US, Inc.
|
|
#
|
|
# 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: Gather address fact
|
|
set_fact:
|
|
# NOTE(cloudnull):
|
|
# Collect the interface address from hostvars of a target node.
|
|
# Check if the host is running in a container. If not, pull the bridge data from the
|
|
# network interface. If an interface bridge is defined, pull the IP address from the
|
|
# physical network device. If no physical bridge is defined collect the address from
|
|
# the "<INTERFACE>_network_data" variable. If nothing is defined use the
|
|
# "ansible_host" address.
|
|
_lookup_address: >-
|
|
{%- set _network_data = hostvars[inventory_hostname]['container_networks'][network_address] | default({}) -%}
|
|
{%- if is_metal is defined and is_metal | bool -%}
|
|
{%- set _bridge = _network_data['bridge'] | default('no_bridge_defined') | replace('-', '_') -%}
|
|
{%- else -%}
|
|
{%- set _bridge = 'no_bridge_defined' -%}
|
|
{%- endif -%}
|
|
{%- if _bridge != 'no_bridge_defined' -%}
|
|
{{ hostvars[inventory_hostname]['ansible_' + _bridge]['ipv4']['address'] }}
|
|
{%- elif _network_data['address'] is defined -%}
|
|
{{ _network_data['address'] }}
|
|
{%- else -%}
|
|
{{ ansible_host }}
|
|
{%- endif -%}
|
|
tags:
|
|
- always
|
|
|
|
# NOTE(cloudnull):
|
|
# This task is not in dict formation because it is
|
|
# dynamically loading facts based on the network_address
|
|
# and the _lookup_address.
|
|
- name: Set address fact
|
|
set_fact: "{{ network_address }}={{ _lookup_address }}"
|
|
tags:
|
|
- always
|