124421b56cac378195134ecb6451679dbf9ea452
[yardstick.git] / ansible / roles / infra_create_vms / tasks / create_interfaces.yml
1 # Copyright (c) 2017-2018 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 - name: Add network-data
16   blockinfile:
17     path: "{{ network_config }}"
18     insertafter: 'ethernets:'
19     marker: "MARKER"
20     block: |2
21         {{ 'enp0s%d:'| format( slot_address | int) }}
22           match:
23             mac_address: {{ '52:54:00:5d:7d:%02x'| format( mac_address_counter | int) }}
24           addresses:
25             - {{ interface_item.ip }}/{{ interface_item.netmask }}
26
27
28 - name: Remove the marker introduced in network-data
29   lineinfile:
30     dest: "{{ network_config }}"
31     state: absent
32     regexp: "MARKER"
33
34 - name: Add new children nodes to "domain" node
35   xml:
36     path: "{{ xml_file }}"
37     xpath: /domain/devices
38     add_children:
39       - interface:
40           type: 'bridge'
41     pretty_print: yes
42
43 - name: Add new children nodes to "domain" node
44   xml:
45     path: "{{ xml_file }}"
46     xpath: /domain/devices/interface
47     add_children:
48       - source:
49           bridge: "{{ interface_item.network }}"
50       - model:
51           type: 'virtio'
52       - address:
53           type: 'pci'
54           domain: '0x0000'
55           bus: '0x00'
56           slot: "{{ '0x%02x'| format( slot_address | int) }}"
57           function: '0x0'
58       - mac:
59           address: "{{ '52:54:00:5d:7d:%02x'| format( mac_address_counter | int) }}"
60     pretty_print: yes
61
62 - set_fact:
63     slot_address: "{{ slot_address | int + 1 }}"
64 - set_fact:
65     mac_address_counter: "{{ mac_address_counter | int + 1 }}"