abbf57c03fbbb30d763bc7fcccbd457af58ea825
[yardstick.git] / ansible / roles / build_yardstick_image / tasks / post_build.yml
1 # Copyright (c) 2018 Intel Corporation.\r
2 #\r
3 # Licensed under the Apache License, Version 2.0 (the "License");\r
4 # you may not use this file except in compliance with the License.\r
5 # You may obtain a copy of the License at\r
6 #\r
7 #      http://www.apache.org/licenses/LICENSE-2.0\r
8 #\r
9 # Unless required by applicable law or agreed to in writing, software\r
10 # distributed under the License is distributed on an "AS IS" BASIS,\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 # See the License for the specific language governing permissions and\r
13 # limitations under the License.\r
14 ---\r
15 - name: convert image to image file\r
16   command: qemu-img convert -c -o compat=0.10 -O qcow2 {{ raw_imgfile }} {{ imgfile }}\r
17 \r
18 # Post build yardstick image\r
19 - group_by:\r
20     key: image_builder\r
21 \r
22 - name: remove ubuntu policy-rc.d workaround\r
23   file:\r
24     path: "{{ mountdir }}/usr/sbin/policy-rc.d"\r
25     state: absent\r
26   when: "target_os == 'Ubuntu'"\r
27 \r
28 - name: cleanup fake tmp fstab\r
29   file:\r
30     path: "{{ fake_fstab }}"\r
31     state: absent\r
32 \r
33 - mount:\r
34     name: "{{ mountdir }}/proc"\r
35     state: unmounted\r
36 \r
37 - mount:\r
38     name: "{{ mountdir }}/run"\r
39     state: unmounted\r
40 \r
41 - mount:\r
42     name: "{{ mountdir }}"\r
43     state: unmounted\r
44 \r
45 - name: kpartx -dv to delete all image partition device nodes\r
46   command: kpartx -dv "{{ raw_imgfile }}"\r
47   ignore_errors: true\r
48 \r
49 - debug:\r
50     msg: "yardstick image = {{ imgfile }}"\r
51 \r
52 - set_fact:\r
53     imgdest: "/var/lib/libvirt/images/{{ imgfile | basename}}"\r
54     name: "{{ (imgfile | basename | splitext)[0] }}"\r
55     ext: "{{ (imgfile | basename | splitext)[1] }}"\r
56 \r
57 - name: Verify if imgfile exists in libvirt images\r
58   stat:\r
59     path: "{{ imgdest }}"\r
60   register: imgdest_stat\r
61 \r
62 - set_fact:\r
63     imgdest: "/var/lib/libvirt/images/{{ name }}_autogen{{ ext }}"\r
64   when: imgdest_stat.stat.exists\r
65 \r
66 - name: Copy image to libvirt images\r
67   shell: "cp {{ imgfile }} {{ imgdest }}"\r