Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/mas/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Test code for the mas module.
8 # Copyright (c) 2020, Lukas Bestle <[email protected]>
9 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
10 # SPDX-License-Identifier: GPL-3.0-or-later
11
12 # Test preparation
13 - name: Uninstall Rested to ensure consistent starting point
14 mas:
15 id: 421879749
16 state: absent
17 become: true
18
19 - name: Determine whether the app is installed
20 stat:
21 path: /Applications/Rested.app
22 register: install_status
23
24 - name: Ensure the app is uninstalled
25 assert:
26 that:
27 - install_status.stat.exists == false
28
29 - name: Wait until the OS-internal cache was updated
30 pause:
31 seconds: 5
32
33 # Installation
34 - name: Check if Rested needs to be installed
35 mas:
36 id: 421879749
37 state: present
38 register: install_check
39 check_mode: true
40
41 - name: Ensure that the status would have changed
42 assert:
43 that:
44 - install_check is changed
45 - install_check.msg == "Installed 1 app(s)"
46
47 - name: Determine whether the app is installed
48 stat:
49 path: /Applications/Rested.app
50 register: install_status
51
52 - name: Ensure the app is not yet installed
53 assert:
54 that:
55 - install_status.stat.exists == false
56
57 - name: Install Rested
58 mas:
59 id: 421879749
60 state: present
61 register: install
62
63 - name: Ensure that the status changed
64 assert:
65 that:
66 - install is changed
67 - install.msg == "Installed 1 app(s)"
68
69 - name: Determine whether the app is installed
70 stat:
71 path: /Applications/Rested.app
72 register: install_status
73
74 - name: Ensure the app is installed
75 assert:
76 that:
77 - install_status.stat.exists == true
78
79 - name: Wait until the OS-internal cache was updated
80 pause:
81 seconds: 5
82
83 - name: Install Rested again
84 mas:
85 id: 421879749
86 state: present
87 register: install_again
88
89 - name: Ensure that the status is unchanged (already installed)
90 assert:
91 that:
92 - install_again is not changed
93 - "'msg' not in install_again"
94
95 # Uninstallation
96 - name: Check if Rested needs to be uninstalled
97 mas:
98 id: 421879749
99 state: absent
100 register: uninstall_check
101 become: true
102 check_mode: true
103
104 - name: Ensure that the status would have changed
105 assert:
106 that:
107 - uninstall_check is changed
108 - uninstall_check.msg == "Uninstalled 1 app(s)"
109
110 - name: Determine whether the app is installed
111 stat:
112 path: /Applications/Rested.app
113 register: install_status
114
115 - name: Ensure the app is not yet uninstalled
116 assert:
117 that:
118 - install_status.stat.exists == true
119
120 - name: Uninstall Rested
121 mas:
122 id: 421879749
123 state: absent
124 register: uninstall
125 become: true
126
127 - name: Ensure that the status changed
128 assert:
129 that:
130 - uninstall is changed
131 - uninstall.msg == "Uninstalled 1 app(s)"
132
133 - name: Determine whether the app is installed
134 stat:
135 path: /Applications/Rested.app
136 register: uninstall_status
137
138 - name: Ensure the app is uninstalled
139 assert:
140 that:
141 - uninstall_status.stat.exists == false
142
143 - name: Wait until the OS-internal cache was updated
144 pause:
145 seconds: 5
146
147 - name: Uninstall Rested again
148 mas:
149 id: 421879749
150 state: absent
151 register: uninstall_again
152 become: true
153
154 - name: Ensure that the status is unchanged (already uninstalled)
155 assert:
156 that:
157 - uninstall_again is not changed
158 - "'msg' not in uninstall_again"