blob: f4b0318d84602985dd33a2cd204828c23210ea34 [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}) }}"
Vamsi Savaramf82b1a22019-09-20 11:16:46 +000035 loop: "{{ ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined') | list }}"
36 when: "{{ '.' not in item.device }}"
Fatih Degirmenci82259612019-05-02 11:44:02 -060037
Vamsi Savaramf82b1a22019-09-20 11:16:46 +000038- name: Filter to include only configured ethernet interfaces
Fatih Degirmenci82259612019-05-02 11:44:02 -060039 set_fact:
Vamsi Savaramf82b1a22019-09-20 11:16:46 +000040 if_mac_dict: "{{ ( if_mac_dict | default({}) ) | combine({item.mac_address: device_mac_dict[item.mac_address]}) }}"
41 loop: "{{ node.interfaces }}"
Fatih Degirmenci82259612019-05-02 11:44:02 -060042
43- name: Configure networking for host
44 template:
45 src: "{{ ansible_os_family }}.interface.j2"
46 dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.value }}"
47 with_items:
48 - "{{ if_mac_dict | dict2items }}"
49
Yantian You09d30492019-05-22 20:35:44 +020050- name: Proxy configuration for yum
51 block:
52 - name: Check that the /etc/yum.conf exists
53 stat:
54 path: /etc/yum.conf
55 register: stat_result
56
57 - name: Create /etc/yum.conf, if it doesn't exist
58 file:
59 path: /etc/yum.conf
60 state: touch
61 when: stat_result.stat.exists == False
62
63 - name: Add proxy setting to /etc/yum.conf
64 lineinfile:
65 dest: /etc/yum.conf
66 state: present
67 regexp: "^{{ item.name }}"
68 line: "{{ item.name }}={{ item.value }} "
69 with_items:
70 - {name: 'proxy', value: '"{{ idf.proxy_settings.http_proxy }}"' }
71 when:
72 idf.proxy_settings is defined
73
Fatih Degirmenci82259612019-05-02 11:44:02 -060074- name: Restart network
75 service:
76 name: network
77 state: restarted
78
79# vim: set ts=2 sw=2 expandtab: