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 | |
Vamsi Savaram | f285ed8 | 2019-08-07 15:55:30 +0000 | [diff] [blame] | 20 | - name: Get node name from IDF for host "{{ inventory_hostname }}" |
| 21 | set_fact: |
| 22 | node_name: "{{ item.key }}" |
| 23 | with_dict: "{{ (installer_type == 'kolla') | ternary(idf.kolla.hostnames, idf.kubespray.hostnames) }}" |
| 24 | when: item.value == inventory_hostname |
| 25 | |
| 26 | - name: Set facts for the node "{{ node_name }}" |
| 27 | set_fact: |
| 28 | node: "{{ nodes | selectattr('name', 'equalto', node_name) | first }}" |
| 29 | |
| 30 | - name: Fetch mgmt network interface name |
| 31 | set_fact: |
Fatih Degirmenci | df251d5 | 2019-12-11 13:43:10 +0100 | [diff] [blame] | 32 | mgmt_ifname: |- |
| 33 | {{ (node.interfaces[idf.net_config.mgmt.interface].vlan == 'native') | |
| 34 | ternary(interface.device, interface.device + '.' + node.interfaces[idf.net_config.mgmt.interface].vlan) }} |
| 35 | loop: |- |
| 36 | {{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | |
| 37 | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }} |
Vamsi Savaram | f285ed8 | 2019-08-07 15:55:30 +0000 | [diff] [blame] | 38 | loop_control: |
| 39 | loop_var: interface |
Vamsi Savaram | 5a7b972 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 40 | when: |
| 41 | - interface.macaddress == node.interfaces[idf.net_config.mgmt.interface].mac_address |
Fatih Degirmenci | df251d5 | 2019-12-11 13:43:10 +0100 | [diff] [blame] | 42 | - "'.' not in interface.device" |
Vamsi Savaram | f285ed8 | 2019-08-07 15:55:30 +0000 | [diff] [blame] | 43 | |
| 44 | - name: Fetch neutron network interface name |
| 45 | set_fact: |
Fatih Degirmenci | df251d5 | 2019-12-11 13:43:10 +0100 | [diff] [blame] | 46 | neutron_ifname: |- |
| 47 | {{ (node.interfaces[idf.net_config.neutron.interface].vlan == 'native') | |
| 48 | ternary(interface.device, interface.device + '.' + node.interfaces[idf.net_config.neutron.interface].vlan) }} |
| 49 | loop: |- |
| 50 | {{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | |
| 51 | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }} |
Vamsi Savaram | f285ed8 | 2019-08-07 15:55:30 +0000 | [diff] [blame] | 52 | loop_control: |
| 53 | loop_var: interface |
Vamsi Savaram | 5a7b972 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 54 | when: |
| 55 | - interface.macaddress == node.interfaces[idf.net_config.neutron.interface].mac_address |
Fatih Degirmenci | df251d5 | 2019-12-11 13:43:10 +0100 | [diff] [blame] | 56 | - "'.' not in interface.device" |
Fatih Degirmenci | ef0b16f | 2020-01-08 23:53:05 +0000 | [diff] [blame^] | 57 | |
| 58 | # vim: set ts=2 sw=2 expandtab: |