Vamsi Savaram | f285ed8 | 2019-08-07 15:55:30 +0000 | [diff] [blame^] | 1 | --- |
| 2 | # ============LICENSE_START======================================================= |
| 3 | # Copyright (C) 2019 The Nordix Foundation. All rights reserved. |
| 4 | # ================================================================================ |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | # SPDX-License-Identifier: Apache-2.0 |
| 18 | # ============LICENSE_END========================================================= |
| 19 | |
| 20 | - name: Print interface information |
| 21 | debug: |
| 22 | msg: "{{ ansible_interfaces }}" |
| 23 | |
| 24 | - name: Get node name from IDF for host "{{ inventory_hostname }}" |
| 25 | set_fact: |
| 26 | node_name: "{{ item.key }}" |
| 27 | with_dict: "{{ (installer_type == 'kolla') | ternary(idf.kolla.hostnames, idf.kubespray.hostnames) }}" |
| 28 | when: item.value == inventory_hostname |
| 29 | |
| 30 | - name: Set facts for the node "{{ node_name }}" |
| 31 | set_fact: |
| 32 | node: "{{ nodes | selectattr('name', 'equalto', node_name) | first }}" |
| 33 | |
| 34 | - name: Fetch mgmt network interface name |
| 35 | set_fact: |
| 36 | mgmt_ifname: "{{ (node.interfaces[idf.net_config.mgmt.interface].vlan == 'native') | ternary(interface.device, interface.device + '.' + node.interfaces[idf.net_config.mgmt.interface].vlan) }}" |
| 37 | loop: "{{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }}" |
| 38 | loop_control: |
| 39 | loop_var: interface |
| 40 | when: interface.macaddress == node.interfaces[idf.net_config.mgmt.interface].mac_address |
| 41 | |
| 42 | - name: Fetch neutron network interface name |
| 43 | set_fact: |
| 44 | neutron_ifname: "{{ (node.interfaces[idf.net_config.neutron.interface].vlan == 'native') | ternary(interface.device, interface.device + '.' + node.interfaces[idf.net_config.neutron.interface].vlan) }}" |
| 45 | loop: "{{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }}" |
| 46 | loop_control: |
| 47 | loop_var: interface |
| 48 | when: interface.macaddress == node.interfaces[idf.net_config.neutron.interface].mac_address |