xci: playbooks: configure-network: Prepare for multi-distro support 19/40119/3
authorMarkos Chandras <mchandras@suse.de>
Thu, 24 Aug 2017 12:33:38 +0000 (13:33 +0100)
committerMarkos Chandras <mchandras@suse.de>
Fri, 25 Aug 2017 09:31:53 +0000 (10:31 +0100)
Move the network templates inside the role since it's their only user.
Moreover, remove the arguments when we include the role in playbooks and
move the distro logic to the role itself.

Change-Id: I938686fdb31b9896b9e97339799a0edd4c34bf36
Signed-off-by: Markos Chandras <mchandras@suse.de>
xci/playbooks/configure-opnfvhost.yml
xci/playbooks/configure-targethosts.yml
xci/playbooks/roles/configure-network/tasks/main.yml
xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 [moved from xci/template/compute.interface.j2 with 98% similarity]
xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 [moved from xci/template/controller.interface.j2 with 98% similarity]
xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 [moved from xci/template/opnfv.interface.j2 with 98% similarity]

index 53e3441..7bc434d 100644 (file)
@@ -48,8 +48,7 @@
     - ../var/flavor-vars.yml
     - ../var/opnfv.yml
   roles:
-    # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
-    - { role: configure-network, when: ansible_distribution_release == "xenial", src: "../template/opnfv.interface.j2", dest: "/etc/network/interfaces" }
+      - role: configure-network
   tasks:
     - name: generate SSH keys
       shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
index 50da1f2..88da131 100644 (file)
@@ -13,8 +13,7 @@
     - ../var/{{ ansible_os_family }}.yml
     - ../var/flavor-vars.yml
   roles:
-    # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
-    - { role: configure-network, src: "../template/controller.interface.j2", dest: "/etc/network/interfaces" }
+    - role: configure-network
     # we need to force sync time with ntp or the nodes will be out of sync timewise
     - role: synchronize-time
 
@@ -24,8 +23,7 @@
     - ../var/{{ ansible_os_family }}.yml
     - ../var/flavor-vars.yml
   roles:
-    # TODO: this only works for ubuntu/xenial and need to be adjusted for other distros
-    - { role: configure-network, src: "../template/compute.interface.j2", dest: "/etc/network/interfaces" }
+    - role: configure-network
     # we need to force sync time with ntp or the nodes will be out of sync timewise
     - role: synchronize-time
 
index aafadf7..df1580e 100644 (file)
@@ -27,8 +27,8 @@
       shell: "/bin/rm -rf /etc/network/interfaces.d/*"
     - name: ensure interfaces file is updated
       template:
-        src: "{{ src }}"
-        dest: "{{ dest }}"
+        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_distribution_release == "xenial"
+  when: ansible_os_family | lower == "debian"