From e8f6f7180dc5d78520d3ab298f279a8dd1b8795b Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 24 Aug 2017 13:33:38 +0100 Subject: [PATCH] xci: playbooks: configure-network: Prepare for multi-distro support 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 --- xci/playbooks/configure-opnfvhost.yml | 3 +-- xci/playbooks/configure-targethosts.yml | 6 ++---- xci/playbooks/roles/configure-network/tasks/main.yml | 6 +++--- .../configure-network/templates/debian/compute00.interface.j2} | 2 ++ .../configure-network/templates/debian/controller00.interface.j2} | 2 ++ .../roles/configure-network/templates/debian}/opnfv.interface.j2 | 2 ++ 6 files changed, 12 insertions(+), 9 deletions(-) rename xci/{template/compute.interface.j2 => playbooks/roles/configure-network/templates/debian/compute00.interface.j2} (98%) rename xci/{template/controller.interface.j2 => playbooks/roles/configure-network/templates/debian/controller00.interface.j2} (98%) rename xci/{template => playbooks/roles/configure-network/templates/debian}/opnfv.interface.j2 (98%) diff --git a/xci/playbooks/configure-opnfvhost.yml b/xci/playbooks/configure-opnfvhost.yml index 53e34418..7bc434d7 100644 --- a/xci/playbooks/configure-opnfvhost.yml +++ b/xci/playbooks/configure-opnfvhost.yml @@ -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 "" diff --git a/xci/playbooks/configure-targethosts.yml b/xci/playbooks/configure-targethosts.yml index 50da1f22..88da1312 100644 --- a/xci/playbooks/configure-targethosts.yml +++ b/xci/playbooks/configure-targethosts.yml @@ -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 diff --git a/xci/playbooks/roles/configure-network/tasks/main.yml b/xci/playbooks/roles/configure-network/tasks/main.yml index aafadf71..df1580e5 100644 --- a/xci/playbooks/roles/configure-network/tasks/main.yml +++ b/xci/playbooks/roles/configure-network/tasks/main.yml @@ -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" diff --git a/xci/template/compute.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 similarity index 98% rename from xci/template/compute.interface.j2 rename to xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 index 094544c3..6d6a3835 100644 --- a/xci/template/compute.interface.j2 +++ b/xci/playbooks/roles/configure-network/templates/debian/compute00.interface.j2 @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + # The loopback network interface auto lo iface lo inet loopback diff --git a/xci/template/controller.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 similarity index 98% rename from xci/template/controller.interface.j2 rename to xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 index 638e78e1..5d42a5d2 100644 --- a/xci/template/controller.interface.j2 +++ b/xci/playbooks/roles/configure-network/templates/debian/controller00.interface.j2 @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + # The loopback network interface auto lo iface lo inet loopback diff --git a/xci/template/opnfv.interface.j2 b/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 similarity index 98% rename from xci/template/opnfv.interface.j2 rename to xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 index e9f8649c..42826414 100644 --- a/xci/template/opnfv.interface.j2 +++ b/xci/playbooks/roles/configure-network/templates/debian/opnfv.interface.j2 @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + # The loopback network interface auto lo iface lo inet loopback -- 2.16.6