blob: 600d5d6c11d866f451ab0c6b5eceadc4165d8075 [file] [log] [blame]
---
# ============LICENSE_START=======================================================
# Copyright (C) 2019 The Nordix Foundation. 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.
#
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
- name: Configure modules
lineinfile:
dest: /etc/modules
state: present
create: yes
line: "8021q"
- name: Add modules
modprobe:
name: 8021q
state: present
- name: Compute mapping dict from mac address to device name
set_fact:
device_mac_dict: "{{ (device_mac_dict | default({})) | combine({item.macaddress: item.device}) }}"
with_items:
- "{{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }}"
- name: Compute mapping dict from mac address to interface name (device name with/without VLAN info)
set_fact:
if_mac_dict: "{{ ( if_mac_dict | default({}) ) | combine({item.mac_address: (item.vlan == 'native') | ternary(device_mac_dict[item.mac_address], device_mac_dict[item.mac_address] + '.' + item.vlan) }) }}"
with_items:
- "{{ node.interfaces }}"
- name: Configure networking for host
template:
src: "{{ ansible_os_family }}.interface.j2"
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.value }}"
with_items:
- "{{ if_mac_dict | dict2items }}"
- name: Proxy configuration for yum
block:
- name: Check that the /etc/yum.conf exists
stat:
path: /etc/yum.conf
register: stat_result
- name: Create /etc/yum.conf, if it doesn't exist
file:
path: /etc/yum.conf
state: touch
when: stat_result.stat.exists == False
- name: Add proxy setting to /etc/yum.conf
lineinfile:
dest: /etc/yum.conf
state: present
regexp: "^{{ item.name }}"
line: "{{ item.name }}={{ item.value }} "
with_items:
- {name: 'proxy', value: '"{{ idf.proxy_settings.http_proxy }}"' }
when:
idf.proxy_settings is defined
- name: Restart network
service:
name: network
state: restarted
# vim: set ts=2 sw=2 expandtab: