Debian Codegraph @

ansible_collections/community/libvirt/tests/integration/targets/virt_net/tasks/main.yml

raw
1 ---
2 - include_vars: '{{ item }}'
3 with_first_found:
4 - "{{ ansible_distribution }}-{{ ansible_distribution_version}}.yml"
5 - "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml"
6 - "{{ ansible_distribution }}.yml"
7 - "default.yml"
8
9 - block:
10 - name: Install libvirt packages
11 package:
12 name: "{{ virt_net_packages }}"
13
14 - name: Start libvirt
15 service:
16 name: libvirtd
17 state: started
18
19 - name: Define the foobar network
20 community.libvirt.virt_net:
21 command: define
22 name: foobar
23 xml: '{{ lookup("file", "foobar.xml") }}'
24
25 - name: Define the foobar network (again)
26 community.libvirt.virt_net:
27 command: define
28 name: foobar
29 xml: '{{ lookup("file", "foobar.xml") }}'
30 register: second_virt_net_define
31
32 - name: Start the foobar network
33 community.libvirt.virt_net:
34 command: start
35 name: foobar
36
37 - name: Start the foobar network (again)
38 community.libvirt.virt_net:
39 command: start
40 name: foobar
41 register: second_virt_net_start
42
43 - name: Get facts for the foobar network
44 community.libvirt.virt_net:
45 command: facts
46 name: foobar
47 register: virt_net_facts
48
49 - name: Destroy the foobar network
50 community.libvirt.virt_net:
51 command: destroy
52 name: foobar
53
54 - name: Undefine the foobar network
55 community.libvirt.virt_net:
56 command: undefine
57 name: foobar
58 register: second_virt_net_define
59
60 - name: Undefine the foobar network (again)
61 community.libvirt.virt_net:
62 command: undefine
63 name: foobar
64 register: second_virt_net_undefine
65
66 - name: Ensure the second calls return "unchanged"
67 assert:
68 that:
69 - "second_virt_net_start is not changed"
70 - "second_virt_net_define is not changed"
71 - "second_virt_net_undefine is not changed"
72
73 - name: List all the networks
74 community.libvirt.virt_net:
75 command: list_nets
76
77 - name: Get all the network facts
78 community.libvirt.virt_net:
79 command: facts
80
81 always:
82 - name: Stop libvirt
83 service:
84 name: libvirtd
85 state: stopped
86
87 - name: Remove only the libvirt packages
88 package:
89 name: "{{ virt_net_packages|select('match', '.*libvirt.*')|list }}"
90 state: absent