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

Conversation

weswhet
Copy link
Contributor

@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
Copy link
Contributor

@gtmanfred gtmanfred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I changed all my additions to using __utils__

Copy link
Contributor

@twangboy twangboy May 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Contributor Author

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
Contributor Author

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

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

@rallytime
Copy link
Contributor

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
Contributor Author

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
@weswhet weswhet deleted the add-mac_service-update branch September 14, 2018 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants