Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add macOS mac_service update. #47256

Merged
merged 8 commits into from May 22, 2018
Merged

Conversation

@weswhet
Copy link
Collaborator

@weswhet weswhet commented Apr 23, 2018

What does this PR do?

This PR adds support for using the latest macOS launchctl subcommands as well as the ability to manage user specific services.

Previous Behavior

Previously salt would use the legacy subcommands like /bin/launchctl load/unload to start and stop services. It was also not capable of modifying any user specific services located in /Users/foo/Library/LaunchAgents/

New Behavior

Salt now leverages the latest subcommands /bin/launchctl bootstrap/bootout to start and stop services. Using these subcommands allows us to properly load and unload LauchAgents from root without having to run commands as the user as this is handled properly by launchctl when specifying to appropriate domain/system targets like gui/501/ or gui/501/com.apple.example.

Salt also now looks for user specific services located in /Users/foo/Library/LaunchAgents/ and is now capable of modifying them.

Tests written?

No

Commits signed with GPG?

Yes

…ad of the legacy versions, and support for user space LaunchAgents
@rallytime rallytime requested review from twangboy and gtmanfred Apr 24, 2018
Copy link
Contributor

@gtmanfred gtmanfred left a comment

Just one change I would like to see, but it can be merged without it.

# check if a LaunchAgent as we should treat these differently.
if 'LaunchAgents' in path:
# Get the console user so we can service in the correct session
uid = salt.utils.mac_utils.console_user()
Copy link
Contributor

@gtmanfred gtmanfred Apr 24, 2018

can you switch these to using __utils__['mac_utils.console_user']() instead of using the import salt.utils.mac_utils?

It allows for people that use the dropin dynamic modules to actually replace the modules that use newer salt utils.

Thanks,
Daniel

Copy link
Collaborator Author

@weswhet weswhet Apr 24, 2018

@gtmanfred would like me to convert the other mac_util calls as well?

Copy link
Contributor

@gtmanfred gtmanfred Apr 24, 2018

Eventually we should go through and change them all to using __utils__ i was just think about these ones since you are adding new ones.

Copy link
Collaborator Author

@weswhet weswhet Apr 24, 2018

Sounds good, I changed all my additions to using __utils__

Copy link
Contributor

@twangboy twangboy May 1, 2018

I'm still seeing salt.utils.mac_utils.console_user(). Need change it to __utils__['mac_utils.console_user']

…th PIDs as the service state does not pass in the runas parameter
@weswhet
Copy link
Collaborator Author

@weswhet weswhet commented Apr 24, 2018

after testing the requested changes by Daniel, I noticed that the service state doesn't pass in the runas parameter when checking the status of a LaunchAgent. I've added a patch for this behavior in ea6c18c

@weswhet
Copy link
Collaborator Author

@weswhet weswhet commented Apr 24, 2018

@rallytime I'd like to update the documentation with some notes and version added information for these changes. Would this PR make it into the Fluorine release?

@rallytime
Copy link
Contributor

@rallytime rallytime commented Apr 24, 2018

@weswhet Yeah, definitely. We're not branching for the Fluorine release for a while.

@rallytime
Copy link
Contributor

@rallytime rallytime commented May 1, 2018

Hi @weswhet - It looks like this change is causing the following related tests to fail:

  • unit.utils.test_mac_utils.MacUtilsTestCase.test_available_services
  • unit.utils.test_mac_utils.MacUtilsTestCase.test_available_services_broken_symlink
  • unit.utils.test_mac_utils.MacUtilsTestCase.test_available_services_non_xml
  • unit.utils.test_mac_utils.MacUtilsTestCase.test_available_services_non_xml_malformed_plist

https://jenkins.saltstack.com/job/PR/job/salt-pr-linode-ubuntu14-n/22418/

Can you take a look?

@weswhet
Copy link
Collaborator Author

@weswhet weswhet commented May 1, 2018

@rallytime, for future reference what state are the test Macs in? I’m assuming headless With no users and sitting at the login window? Just curious for any future code changes.

@rallytime rallytime merged commit de84f6f into saltstack:develop May 22, 2018
5 of 10 checks passed
@weswhet weswhet deleted the add-mac_service-update branch Sep 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants