Map nicX abstraction to phys interface name

Map os-net-config nicX abstraction to physical interface names.

  $ os-net-config -i
  {'nic1': 'eth0', 'nic2': 'eth1'}

Change-Id: I34a2da66d24a20926394be32e2679f316c821ac6
This commit is contained in:
Carlos Goncalves 2021-01-18 15:53:47 +01:00
parent ad5a1f9577
commit 8020ca7d25
2 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,5 @@
---
# Copyright 2020 Red Hat, Inc.
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -23,6 +23,26 @@
selevel: s0
setype: container_file_t
- name: identify the real interfaces via os-net-config
shell: os-net-config -i
register: os_net_config_result
- name: os-net-config from json
set_fact:
iface_map: "{{ os_net_config_result.stdout }}"
- name: FRR uplink interfaces
block:
- name: construct FRR uplink interfaces from os-net-config mappings
set_fact:
tripleo_frr_bgp_uplinks_mapped: "{{ tripleo_frr_bgp_uplinks | map('extract', iface_map) | list }}"
rescue:
- name: failed to construct FRR uplink interfaces
ansible.builtin.fail:
msg: |
Failed to map at least one interface from {{ tripleo_frr_bgp_uplinks }} to {{ iface_map }}.
Please check value of Ansible variable tripleo_frr_bgp_uplinks.
- name: configure FRR
become: true
ansible.builtin.template:

View File

@ -15,7 +15,7 @@ router bgp {{ tripleo_frr_bgp_asn }}
{% if tripleo_frr_bfd %}
neighbor uplink bfd
{% endif %}
{% for iface in tripleo_frr_bgp_uplinks %}
{% for iface in tripleo_frr_bgp_uplinks_mapped %}
neighbor {{ iface }} interface peer-group uplink
{% endfor %}