From feabad39f4faf52294b7a7809a4d9f024959ee46 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 28 Sep 2020 07:15:48 +0200 Subject: [PATCH] launchd: fix for user-level services (#899) (#970) * launchd: fix for user-level services * fix changelog fragment number (cherry picked from commit 2794dc7b029eb7def2aa08a8e3669d1211443d50) Co-authored-by: tomaszn --- changelogs/fragments/899_launchd_user_service.yml | 2 ++ plugins/modules/system/launchd.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/899_launchd_user_service.yml diff --git a/changelogs/fragments/899_launchd_user_service.yml b/changelogs/fragments/899_launchd_user_service.yml new file mode 100644 index 0000000000..5abca2a6a7 --- /dev/null +++ b/changelogs/fragments/899_launchd_user_service.yml @@ -0,0 +1,2 @@ +bugfixes: +- launchd - fix for user-level services (https://github.com/ansible-collections/community.general/issues/896). diff --git a/plugins/modules/system/launchd.py b/plugins/modules/system/launchd.py index 76cbf565a0..d3d9fcb108 100644 --- a/plugins/modules/system/launchd.py +++ b/plugins/modules/system/launchd.py @@ -154,7 +154,7 @@ class Plist: """Finds the plist file associated with a service""" launchd_paths = [ - '~/Library/LaunchAgents', + os.path.expanduser('~/Library/LaunchAgents'), '/Library/LaunchAgents', '/Library/LaunchDaemons', '/System/Library/LaunchAgents', @@ -163,7 +163,7 @@ class Plist: for path in launchd_paths: try: - files = os.listdir(os.path.expanduser(path)) + files = os.listdir(path) except OSError: continue