Create CentOS networking configuration 31/49531/12
authorTapio Tallgren <tapio.tallgren@nokia.com>
Fri, 1 Dec 2017 11:53:29 +0000 (13:53 +0200)
committerTapio Tallgren <tapio.tallgren@nokia.com>
Mon, 15 Jan 2018 11:04:13 +0000 (13:04 +0200)
Change-Id: If8c0de44c313fdc22b1c7443b12d42769035c5b0
Signed-off-by: Tapio Tallgren <tapio.tallgren@nokia.com>
xci/playbooks/roles/configure-network/tasks/main.yml
xci/playbooks/roles/configure-network/templates/redhat/bridge.ifcfg.j2 [new file with mode: 0644]
xci/playbooks/roles/configure-network/templates/redhat/interface.ifcfg.j2 [new file with mode: 0644]
xci/var/RedHat.yml

index 9a08cfb..65abaa4 100644 (file)
     - name: restart network service
       shell: "/usr/sbin/wicked ifreload all"
   when: ansible_os_family | lower == "suse"
+
+- block:
+    - name: Configure networking on CentOS for interfaces
+      template:
+        src: "{{ ansible_os_family | lower }}/interface.ifcfg.j2"
+        dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}"
+      with_items:
+        - { name: "{{ interface }}"   , bridge: "br-vlan"                 }
+        - { name: "{{ interface }}.10", bridge: "br-mgmt"   , vlan_id: 10 }
+        - { name: "{{ interface }}.20", bridge: "br-storage", vlan_id: 20 }
+        - { name: "{{ interface }}.30", bridge: "br-vxlan"  , vlan_id: 30 }
+    - name: Configure networking on CentOS for bridges
+      template:
+        src: "{{ ansible_os_family | lower }}/bridge.ifcfg.j2"
+        dest: "/etc/sysconfig/network-scripts/ifcfg-{{ item.name }}"
+      with_items:
+        - { name: "br-vlan"   , ip: "{{ host_info[inventory_hostname].VLAN_IP }}",    prefix: 24 }
+        - { name: "br-mgmt"   , ip: "{{ host_info[inventory_hostname].MGMT_IP }}",    prefix: 22 }
+        - { name: "br-storage", ip: "{{ host_info[inventory_hostname].STORAGE_IP }}", prefix: 22 }
+        - { name: "br-vxlan"  , ip: "{{ host_info[inventory_hostname].VXLAN_IP }}",   prefix: 22 }
+    - name: Add default route through br-vlan
+      lineinfile:
+        path: "/etc/sysconfig/network-scripts/ifcfg-br-vlan"
+        line: "GATEWAY=192.168.122.1"
+    - name: Restart networking
+      command: "systemctl restart network"
+    - name: wait for the server to come back
+      wait_for_connection:
+  when: ansible_os_family | lower == "redhat"
diff --git a/xci/playbooks/roles/configure-network/templates/redhat/bridge.ifcfg.j2 b/xci/playbooks/roles/configure-network/templates/redhat/bridge.ifcfg.j2
new file mode 100644 (file)
index 0000000..06b5f17
--- /dev/null
@@ -0,0 +1,9 @@
+DEVICE={{ item.name }}
+NM_CONTROLLED=no
+IPADDR={{ item.ip }}
+PREFIX={{ item.prefix }}
+ONBOOT=yes
+BOOTPROTO=none
+TYPE=Bridge
+DELAY=0
+STP=off
diff --git a/xci/playbooks/roles/configure-network/templates/redhat/interface.ifcfg.j2 b/xci/playbooks/roles/configure-network/templates/redhat/interface.ifcfg.j2
new file mode 100644 (file)
index 0000000..b0dea0f
--- /dev/null
@@ -0,0 +1,10 @@
+DEVICE={{ item.name }}
+NM_CONTROLLED=no
+ONBOOT=yes
+BOOTPROTO=none
+{% if item.vlan_id is defined %}
+VLAN=yes
+ETHERDEVICE={{ interface }}
+VLAN_ID={{ item.vlan_id }}
+{% endif %}
+BRIDGE={{ item.bridge }}
index 8ea2e15..814d060 100644 (file)
@@ -8,6 +8,7 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 # this is placeholder and left blank intentionally to complete later on
+interface: "ens3"
 python_crypto_package_name: python-crypto
 docker_package_name: docker
 docker_service_name: docker