Adopt infra_deploy to spawn VM on LTS Ubuntu 18 91/61291/2
authorStepan Andrushko <stepanx.andrushko@intel.com>
Thu, 23 Aug 2018 13:13:47 +0000 (16:13 +0300)
committerStepan Andrushko <stepanx.andrushko@intel.com>
Thu, 30 Aug 2018 15:01:44 +0000 (18:01 +0300)
Add possibility ro reuse infra_deploy.yaml to spawn VMs on jump host,
depending on jump host Ubuntu version: either 16 or 18.

JIRA: YARDSTICK-1396

Change-Id: Id0682c03098e611fe3a51cbd24d8ff2dda7c552a
Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
ansible/infra_deploy.yml
ansible/roles/infra_create_vms/tasks/create_interfaces.yml
ansible/roles/infra_install_dependencies/tasks/Debian.yml [new file with mode: 0644]
ansible/roles/infra_install_dependencies/tasks/main.yml [new file with mode: 0644]

index 8cf5dff..4a5716e 100644 (file)
@@ -27,6 +27,7 @@
       proxy_host_ip: "{{ lookup('dig', proxy_host) }}"
 
   roles:
+    - infra_install_dependencies
     - infra_destroy_previous_configuration
     - infra_check_requirements
     - infra_create_network
index 34bfd1b..12b2726 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ---
+- set_fact:
+    mac_address_arg: "mac_address"
+
+- set_fact:
+    mac_address_arg: "macaddress"
+  when:
+    - ansible_distribution == 'Ubuntu'
+    - ansible_distribution_major_version|int >= 18
+
 - name: Add network-data
   blockinfile:
     path: "{{ network_config }}"
@@ -20,9 +29,9 @@
     block: |2
         {{ 'enp0s%d:'| format( slot_address | int) }}
           match:
-            mac_address: {{ '52:54:00:5d:7d:%02x'| format( mac_address_counter | int) }}
+            {{ mac_address_arg }}: {{ '52:54:00:5d:7d:%02x'| format( mac_address_counter | int) }}
           addresses:
-            - {{ interface_item.ip }}/{{ interface_item.netmask }}
+            - {{ interface_item.ip }}/{{ (interface_item.ip + '/' + interface_item.netmask) | ipaddr('prefix') }}
 
 - name: Add default gateway
   blockinfile:
diff --git a/ansible/roles/infra_install_dependencies/tasks/Debian.yml b/ansible/roles/infra_install_dependencies/tasks/Debian.yml
new file mode 100644 (file)
index 0000000..9f4dc10
--- /dev/null
@@ -0,0 +1,34 @@
+# Copyright (c) 2018 Intel Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+---\r
+- name: Update repositories\r
+  apt:\r
+    update_cache: yes\r
+\r
+- name: Install core packages\r
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"\r
+  with_items:\r
+    - python-libvirt\r
+    - genisoimage\r
+  when: ansible_distribution_major_version|int == 16\r
+\r
+- name: Install core packages\r
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"\r
+  with_items:\r
+    - python-pip\r
+    - python-libvirt\r
+    - python-lxml\r
+    - python-netaddr\r
+    - genisoimage\r
+  when: ansible_distribution_major_version|int >= 18\r
diff --git a/ansible/roles/infra_install_dependencies/tasks/main.yml b/ansible/roles/infra_install_dependencies/tasks/main.yml
new file mode 100644 (file)
index 0000000..115b1e3
--- /dev/null
@@ -0,0 +1,15 @@
+# Copyright (c) 2018 Intel Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+---\r
+- include_tasks: "{{ ansible_os_family }}.yml"\r