mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -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
|
@ -113,3 +113,30 @@ class HomebrewValidate(object):
|
|||
return isinstance(
|
||||
package, string_types
|
||||
) and not cls.INVALID_PACKAGE_REGEX.search(package)
|
||||
|
||||
|
||||
def parse_brew_path(module):
|
||||
# type: (...) -> str
|
||||
"""Attempt to find the Homebrew executable path.
|
||||
|
||||
Requires:
|
||||
- module has a `path` parameter
|
||||
- path is a valid path string for the target OS. Otherwise, module.fail_json()
|
||||
is called with msg="Invalid_path: <path>".
|
||||
"""
|
||||
path = module.params["path"]
|
||||
if not HomebrewValidate.valid_path(path):
|
||||
module.fail_json(msg="Invalid path: {0}".format(path))
|
||||
|
||||
if isinstance(path, string_types):
|
||||
paths = path.split(":")
|
||||
elif isinstance(path, list):
|
||||
paths = path
|
||||
else:
|
||||
module.fail_json(msg="Invalid path: {0}".format(path))
|
||||
|
||||
brew_path = module.get_bin_path("brew", required=True, opt_dirs=paths)
|
||||
if not HomebrewValidate.valid_brew_path(brew_path):
|
||||
module.fail_json(msg="Invalid brew path: {0}".format(brew_path))
|
||||
|
||||
return brew_path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue