Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/homebrew_cask/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 homebrew_cask module.
8 # Copyright (c) 2022, Joseph Torcasso <[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 - name: Find brew binary
13 command: which brew
14 register: brew_which
15 when: ansible_facts.distribution in ['MacOSX']
16
17 - name: Get owner of brew binary
18 stat:
19 path: "{{ brew_which.stdout }}"
20 register: brew_stat
21 when: ansible_facts.distribution in ['MacOSX']
22
23 - block:
24 - name: Install cask
25 homebrew_cask:
26 name: "{{ cask }}"
27 state: present
28 become: true
29 become_user: "{{ brew_stat.stat.pw_name }}"
30 register: cask_install_result
31
32 - assert:
33 that:
34 - cask_install_result is changed
35 - "'Cask installed' in cask_install_result.msg"
36
37 - name: Install cask (idempotence)
38 homebrew_cask:
39 name: "{{ cask }}"
40 state: present
41 become: true
42 become_user: "{{ brew_stat.stat.pw_name }}"
43 register: cask_install_result
44
45 - assert:
46 that:
47 - cask_install_result is not changed
48 - "'Cask installed' not in cask_install_result.msg"
49 - "'Cask already installed' in cask_install_result.msg"
50
51 - name: Install cask with force install option
52 homebrew_cask:
53 name: "{{ cask }}"
54 state: present
55 install_options: force
56 become: true
57 become_user: "{{ brew_stat.stat.pw_name }}"
58 register: cask_install_result
59
60 - assert:
61 that:
62 - cask_install_result is changed
63 - "'Cask installed' in cask_install_result.msg"
64
65 always:
66 - name: Delete cask
67 homebrew_cask:
68 name: "{{ cask }}"
69 state: absent
70 install_options: force
71 become: true
72 become_user: "{{ brew_stat.stat.pw_name }}"
73 ignore_errors: true