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 }}"
46 name: "{{ item.name }}"
50 address: "{{ item.host_ip }}"
51 netmask: "{{ item.netmask }}"
54 - name: Add new children nodes to "forward" node
56 path: "{{ xml_file }}"
57 xpath: /network/forward
62 - name: Add new children nodes to "nat" node
64 path: "{{ xml_file }}"
65 xpath: /network/forward/nat
72 - name: Define the networks
75 name: "{{ item.name }}"
76 xml: "{{ lookup('file', xml_file) }}"
78 - name: Set autostart to yes
81 name: "{{ item.name }}"
83 - name: Start the networks
86 name: "{{ item.name }}"
88 - name: Remove XML file
90 path: "{{ xml_file }}"