Fatih Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [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: 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 Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame^] | 35 | 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 Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 37 | |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame^] | 38 | - name: Filter to include only configured ethernet interfaces |
Fatih Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 39 | set_fact: |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame^] | 40 | if_mac_dict: "{{ ( if_mac_dict | default({}) ) | combine({item.mac_address: device_mac_dict[item.mac_address]}) }}" |
| 41 | loop: "{{ node.interfaces }}" |
Fatih Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 42 | |
| 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 You | 09d3049 | 2019-05-22 20:35:44 +0200 | [diff] [blame] | 50 | - 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 Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 74 | - name: Restart network |
| 75 | service: |
| 76 | name: network |
| 77 | state: restarted |
| 78 | |
| 79 | # vim: set ts=2 sw=2 expandtab: |