summaryrefslogtreecommitdiffstats
path: root/xci/playbooks/roles/configure-network/tasks/main.yml
blob: 9a08cfb7befe3282088ce477e4354b9e43868f7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2017 Ericsson AB and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
- name: ensure glean rules are removed
  file:
    path: "/etc/udev/rules.d/99-glean.rules"
    state: absent

- block:
    - name: configure modules
      lineinfile:
        dest: /etc/modules
        state: present
        create: yes
        line: "8021q"
    - name: add modules
      modprobe:
        name: 8021q
        state: present
    - name: ensure interfaces.d folder is empty
      shell: "/bin/rm -rf /etc/network/interfaces.d/*"
    - name: ensure interfaces file is updated
      template:
        src: "{{ ansible_os_family | lower }}/{{ ansible_hostname }}.interface.j2"
        dest: "/etc/network/interfaces"
    - name: restart network service
      shell: "/sbin/ifconfig {{ interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a"
  when: ansible_os_family | lower == "debian"

- block:
    - name: Remove existing network configuration
      file:
        path: "/etc/sysconfig/network/{{ item }}"
        state: absent
      with_items:
        - "ifcfg-eth0"
        - "ifroute-eth0"

    - name: Configure networking on SUSE
      template:
        src: "{{ ansible_os_family | lower }}/suse.interface.j2"
        dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}"
      with_items:
        - { name: "{{ interface }}" }
        - { name: "{{ interface }}.10", vlan_id: 10 }
        - { name: "{{ interface }}.30", vlan_id: 30 }
        - { name: "{{ interface }}.20", vlan_id: 20 }
        - { name: "br-mgmt", bridge_ports: "{{ interface }}.10", ip: "{{ host_info[inventory_hostname].MGMT_IP }}/22" }
        - { name: "br-vxlan", bridge_ports: "{{ interface }}.30", ip: "{{ host_info[inventory_hostname].VXLAN_IP }}/22" }
        - { name: "br-vlan", bridge_ports: "{{ interface }}", ip: "{{ host_info[inventory_hostname].VLAN_IP }}/24" }
        - { name: "br-storage", bridge_ports: "{{ interface }}.20", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}/22" }

    - name: Add postup/postdown scripts on SUSE
      copy:
        src: "network-config-suse"
        dest: "/etc/sysconfig/network/scripts/network-config-suse"
        mode: 0755

    - name: Configure routes on SUSE
      template:
        src: "{{ ansible_os_family | lower }}/suse.routes.j2"
        dest: "/etc/sysconfig/network/ifroute-{{ item.name }}"
      with_items:
        - { name: "br-vlan", gateway: "192.168.122.1", route: "default" }

    - name: restart network service
      shell: "/usr/sbin/wicked ifreload all"
  when: ansible_os_family | lower == "suse"