Skip to content

Commit

Permalink
feat(module): add acme_sh.version
Browse files Browse the repository at this point in the history
  • Loading branch information
genaumann committed Jan 11, 2024
1 parent 1e657ce commit c999c36
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions _modules/acme_sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,30 @@ def renew(
ret = renew

return ret

def version(
user='root'
):

"""
Get version of acme.sh
user
run the command as a specified user
default: root
"""

home_dir = __salt__["user.info"](user)["home"]

acme_bin = _get_acme_bin(home_dir)

cmd = [acme_bin, "--version"]

version_cmd = __salt__["cmd.run_all"](" ".join(cmd), python_shell=False, runas=user)

if version_cmd["retcode"] == 0:
ret = re.search(r"v(.*)", version_cmd["stdout"]).group(1)
else:
ret = version_cmd

return ret

0 comments on commit c999c36

Please sign in to comment.