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 }}"
47 - name: Add "name" attribute to "bridge" node
49 path: "{{ xml_file }}"
50 xpath: /network/bridge
52 value: "{{ item.name }}"
55 - name: Add "stp" attribute to "bridge" node
57 path: "{{ xml_file }}"
58 xpath: /network/bridge
63 - name: Add "delay" attribute to "bridge" node
65 path: "{{ xml_file }}"
66 xpath: /network/bridge
71 - name: Add "address" attribute to "ip" node
73 path: "{{ xml_file }}"
76 value: "{{ item.host_ip }}"
79 - name: Add "netmask" attribute to "ip" node
81 path: "{{ xml_file }}"
84 value: "{{ item.netmask }}"
87 - name: Define the networks
90 name: "{{ item.name }}"
91 xml: "{{ lookup('file', xml_file) }}"
93 - name: Set autostart to yes
96 name: "{{ item.name }}"
98 - name: Start the networks
101 name: "{{ item.name }}"
103 - name: Remove XML file
105 path: "{{ xml_file }}"