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