1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/homebrew_services/tasks/main.yml

87 lines
2 KiB
YAML
Raw Normal View History

---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# Don't run this test for non-MacOS systems.
- meta: end_play
when: ansible_facts.distribution != 'MacOSX'
- name: MACOS | Find brew binary
command: which brew
register: brew_which
- name: MACOS | Get owner of brew binary
stat:
path: "{{ brew_which.stdout }}"
register: brew_stat
- name: Homebrew Services test block
become: true
become_user: "{{ brew_stat.stat.pw_name }}"
block:
- name: MACOS | Install black
community.general.homebrew:
name: black
state: present
register: install_result
notify:
- uninstall black
- name: Check the black service is installed
assert:
that:
- install_result is success
- name: Start the black service
community.general.homebrew_services:
name: black
state: present
register: start_result
environment:
HOMEBREW_NO_ENV_HINTS: "1"
- name: Check the black service is running
assert:
that:
- start_result is success
- name: Start the black service when already started
community.general.homebrew_services:
name: black
state: present
register: start_result
environment:
HOMEBREW_NO_ENV_HINTS: "1"
- name: Check for idempotency
assert:
that:
- start_result.changed == 0
- name: Restart the black service
community.general.homebrew_services:
name: black
state: restarted
register: restart_result
environment:
HOMEBREW_NO_ENV_HINTS: "1"
- name: Check the black service is restarted
assert:
that:
- restart_result is success
- name: Stop the black service
community.general.homebrew_services:
name: black
state: present
register: stop_result
environment:
HOMEBREW_NO_ENV_HINTS: "1"
- name: Check the black service is stopped
assert:
that:
- stop_result is success