1 # Copyright (c) 2017-2018 Intel Corporation.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 - name: Define XML file name
17 xml_file: "{{ '/tmp/'+item.name+'.xml' }}"
19 - name: Delete the file, if exists
21 path: "{{ xml_file }}"
24 - name: Create a new empty file
26 path: "{{ xml_file }}"
29 - name: Add root "network" node
31 path: "{{ xml_file }}"
37 - name: Add new children nodes to "network" node
39 path: "{{ xml_file }}"
42 - name: "{{ item.name }}"
49 - name: Add new children nodes to "forward" node
51 path: "{{ xml_file }}"
52 xpath: /network/forward
57 - name: Add new children nodes to "nat" node
59 path: "{{ xml_file }}"
60 xpath: /network/forward/nat
67 - name: Add "name" attribute to "bridge" node
69 path: "{{ xml_file }}"
70 xpath: /network/bridge
72 value: "{{ item.name }}"
75 - name: Add "stp" attribute to "bridge" node
77 path: "{{ xml_file }}"
78 xpath: /network/bridge
83 - name: Add "delay" attribute to "bridge" node
85 path: "{{ xml_file }}"
86 xpath: /network/bridge
91 - name: Add "address" attribute to "ip" node
93 path: "{{ xml_file }}"
96 value: "{{ item.host_ip }}"
99 - name: Add "netmask" attribute to "ip" node
101 path: "{{ xml_file }}"
104 value: "{{ item.netmask }}"
107 - name: Define the networks
110 name: "{{ item.name }}"
111 xml: "{{ lookup('file', xml_file) }}"
113 - name: Set autostart to yes
116 name: "{{ item.name }}"
118 - name: Start the networks
121 name: "{{ item.name }}"
123 - name: Remove XML file
125 path: "{{ xml_file }}"