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
Kit Ham 2963004991
homebrew: Add support for services functions (#8329)
* Homebrew: Add support for services functions

Fixes #8286.
Add a homebrew.services module for starting and stopping services
that are attached to homebrew packages.

* Address python version compatibility

* Addressing reviewer comments

* Addressing sanity logs

* Address str format issues

* Fixing Python 2.7 syntax issues

* Test alias, BOTMETA, grammar

* Attempt to fix brew in tests

* Address comments by russoz

* Fixing more dumb typos

* Actually uninstall black

* Update version_added in plugins/modules/homebrew_services.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
2024-08-01 17:11:23 +02:00

86 lines
2 KiB
YAML

---
# 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