Debian Codegraph @

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

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 # Don't run this test for non-MacOS systems.
7 - meta: end_play
8 when: ansible_facts.distribution != 'MacOSX'
9
10 - name: MACOS | Find brew binary
11 command: which brew
12 register: brew_which
13
14 - name: MACOS | Get owner of brew binary
15 stat:
16 path: "{{ brew_which.stdout }}"
17 register: brew_stat
18
19 - name: Homebrew Services test block
20 become: true
21 become_user: "{{ brew_stat.stat.pw_name }}"
22 block:
23 - name: MACOS | Install black
24 community.general.homebrew:
25 name: black
26 state: present
27 register: install_result
28 notify:
29 - uninstall black
30
31 - name: Check the black service is installed
32 assert:
33 that:
34 - install_result is success
35
36 - name: Start the black service
37 community.general.homebrew_services:
38 name: black
39 state: present
40 register: start_result
41 environment:
42 HOMEBREW_NO_ENV_HINTS: "1"
43
44 - name: Check the black service is running
45 assert:
46 that:
47 - start_result is success
48
49 - name: Start the black service when already started
50 community.general.homebrew_services:
51 name: black
52 state: present
53 register: start_result
54 environment:
55 HOMEBREW_NO_ENV_HINTS: "1"
56
57 - name: Check for idempotency
58 assert:
59 that:
60 - start_result.changed == 0
61
62 - name: Restart the black service
63 community.general.homebrew_services:
64 name: black
65 state: restarted
66 register: restart_result
67 environment:
68 HOMEBREW_NO_ENV_HINTS: "1"
69
70 - name: Check the black service is restarted
71 assert:
72 that:
73 - restart_result is success
74
75 - name: Stop the black service
76 community.general.homebrew_services:
77 name: black
78 state: present
79 register: stop_result
80 environment:
81 HOMEBREW_NO_ENV_HINTS: "1"
82
83 - name: Check the black service is stopped
84 assert:
85 that:
86 - stop_result is success