blob: 3d605bb9d68c04505bc8c9dc17c6ecdb92ce3388 [file] [log] [blame]
Fatih Degirmenci82259612019-05-02 11:44:02 -06001---
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: Configure modules
21 lineinfile:
22 dest: /etc/modules
23 state: present
24 create: yes
25 line: "8021q"
26
27- name: Add modules
28 modprobe:
29 name: 8021q
30 state: present
31
32- name: Compute mapping dict from mac address to device name
33 set_fact:
34 device_mac_dict: "{{ (device_mac_dict | default({})) | combine({item.macaddress: item.device}) }}"
Fatih Degirmenci572223c2019-12-11 13:43:10 +010035 loop: |-
36 {{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') |
37 map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }}
38 when: "'.' not in item.device"
Fatih Degirmenci82259612019-05-02 11:44:02 -060039
Vamsi Savaramf82b1a22019-09-20 11:16:46 +000040- name: Filter to include only configured ethernet interfaces
Fatih Degirmenci82259612019-05-02 11:44:02 -060041 set_fact:
Vamsi Savaramf82b1a22019-09-20 11:16:46 +000042 if_mac_dict: "{{ ( if_mac_dict | default({}) ) | combine({item.mac_address: device_mac_dict[item.mac_address]}) }}"
43 loop: "{{ node.interfaces }}"
Fatih Degirmenci82259612019-05-02 11:44:02 -060044
45- name: Configure networking for host
46 template:
47 src: "{{ ansible_os_family }}.interface.j2"
48 dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.value }}"
49 with_items:
50 - "{{ if_mac_dict | dict2items }}"
51
Yantian You09d30492019-05-22 20:35:44 +020052- name: Proxy configuration for yum
53 block:
54 - name: Check that the /etc/yum.conf exists
55 stat:
56 path: /etc/yum.conf
57 register: stat_result
58
59 - name: Create /etc/yum.conf, if it doesn't exist
60 file:
61 path: /etc/yum.conf
62 state: touch
Fatih Degirmenci572223c2019-12-11 13:43:10 +010063 when: not stat_result.stat.exists
Yantian You09d30492019-05-22 20:35:44 +020064
65 - name: Add proxy setting to /etc/yum.conf
66 lineinfile:
67 dest: /etc/yum.conf
68 state: present
69 regexp: "^{{ item.name }}"
70 line: "{{ item.name }}={{ item.value }} "
71 with_items:
72 - {name: 'proxy', value: '"{{ idf.proxy_settings.http_proxy }}"' }
73 when:
74 idf.proxy_settings is defined
75
Fatih Degirmenci82259612019-05-02 11:44:02 -060076- name: Restart network
77 service:
78 name: network
79 state: restarted
80
81# vim: set ts=2 sw=2 expandtab: