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}) }}" |
Fatih Degirmenci | 572223c | 2019-12-11 13:43:10 +0100 | [diff] [blame^] | 35 | 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 Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 39 | |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 40 | - name: Filter to include only configured ethernet interfaces |
Fatih Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 41 | set_fact: |
Vamsi Savaram | f82b1a2 | 2019-09-20 11:16:46 +0000 | [diff] [blame] | 42 | if_mac_dict: "{{ ( if_mac_dict | default({}) ) | combine({item.mac_address: device_mac_dict[item.mac_address]}) }}" |
| 43 | loop: "{{ node.interfaces }}" |
Fatih Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 44 | |
| 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 You | 09d3049 | 2019-05-22 20:35:44 +0200 | [diff] [blame] | 52 | - 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 Degirmenci | 572223c | 2019-12-11 13:43:10 +0100 | [diff] [blame^] | 63 | when: not stat_result.stat.exists |
Yantian You | 09d3049 | 2019-05-22 20:35:44 +0200 | [diff] [blame] | 64 | |
| 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 Degirmenci | 8225961 | 2019-05-02 11:44:02 -0600 | [diff] [blame] | 76 | - name: Restart network |
| 77 | service: |
| 78 | name: network |
| 79 | state: restarted |
| 80 | |
| 81 | # vim: set ts=2 sw=2 expandtab: |