mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
[PR #8329/29630049 backport][stable-9] homebrew: Add support for services functions (#8697)
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>
(cherry picked from commit 2963004991
)
Co-authored-by: Kit Ham <kitizz.devside@gmail.com>
This commit is contained in:
parent
86caa19f78
commit
70acdf1f6d
6 changed files with 394 additions and 0 deletions
9
tests/integration/targets/homebrew_services/aliases
Normal file
9
tests/integration/targets/homebrew_services/aliases
Normal file
|
@ -0,0 +1,9 @@
|
|||
# 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
|
||||
|
||||
azp/posix/1
|
||||
skip/aix
|
||||
skip/freebsd
|
||||
skip/rhel
|
||||
skip/docker
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
# 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
|
||||
|
||||
- name: uninstall black
|
||||
community.general.homebrew:
|
||||
name: black
|
||||
state: absent
|
||||
become: true
|
||||
become_user: "{{ brew_stat.stat.pw_name }}"
|
86
tests/integration/targets/homebrew_services/tasks/main.yml
Normal file
86
tests/integration/targets/homebrew_services/tasks/main.yml
Normal file
|
@ -0,0 +1,86 @@
|
|||
---
|
||||
# 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
|
Loading…
Add table
Add a link
Reference in a new issue