OSX and

15 views
Skip to first unread message

Alain Terriault

unread,
Apr 20, 2022, 3:50:05 AM4/20/22
to salt-...@googlegroups.com
Hi,

I am a little bit puzzle and wonder how to make the `pkg` module works
under OSX.

The command, `salt \MyMac pkg.latest_version neofetch` returns the error

```
ERROR: Unable to run command '['brew', '--prefix']' with the context
'{'cwd': '/var/root', 'shell': False, 'env': {'PATH':
'/usr/bin:/bin:/usr/sbin:/sbin', 'PWD': '/', 'XPC_FLAGS': '0x0',
'XPC_SERVICE_NAME': 'com.saltstack.salt.minion', 'SHLVL': '0',
'LC_CTYPE': 'C', 'LC_NUMERIC': 'C', 'LC_TIME': 'C', 'LC_COLLATE': 'C',
'LC_MONETARY': 'C', 'LC_MESSAGES': 'C', 'LC_PAPER': 'C', 'LC_NAME': 'C',
'LC_ADDRESS': 'C', 'LC_TELEPHONE': 'C', 'LC_MEASUREMENT': 'C',
'LC_IDENTIFICATION': 'C', 'LANGUAGE': 'C'}, 'stdin': None, 'stdout': -1,
'stderr': -2, 'with_communicate': True, 'timeout': None, 'bg': False,
'close_fds': True}', reason: [Errno 2] No such file or directory:
'brew': 'brew'
ERROR: Minions returned with non-zero exit code
```

Brew is installed and working as expected on `MyMac`.

My observations are
- The minion seems to be trying to run `brew` as root .. brew will not
allow to run as root.
- Why is /usr/local/bin not in the Minion env PATH … `MyMac:/etc/paths`
does have `/usr/local/bin` and `root> echo $PATH` does display it.

In short, I will like to know how do OSX admins use the `pkg` module ?
should I just use cmd.run instead of pkg?

Thank you,
alain

michael....@method-b.uk

unread,
May 6, 2022, 5:41:59 AM5/6/22
to Salt-users
Hi Alain,

This was years ago now, but I ended up modifying mac_brew_pkg.py (source: https://github.com/saltstack/salt/blame/master/salt/modules/mac_brew_pkg.py) and then deploying it as a custom module (instructions: https://docs.saltproject.io/en/latest/ref/modules/index.html). There's a function _homebrew_bin, you can hard code the correct path in there if you wish.

I stopped using Salt and brew together on MacOS though, too many quirks and problems over the years. Brew needs to run as a non-root user, which Salt's pkg module handles, but could be a source of problems. Brew can be slow, I generally want my salt states to be fairly quick to run. I ended up using a commercial MDM and Munki for managing packages instead, much smoother. Brew is great if run by the user themselves instead of via Salt.

If you've not found it yet, Salt has another state called macpackage, which you can use for .dmg and .pkg files https://docs.saltproject.io/en/latest/ref/states/all/salt.states.macpackage.html

Hope that helps,
Mike

Alain Terriault

unread,
May 12, 2022, 10:40:15 AM5/12/22
to salt-...@googlegroups.com


.

On May 6, 2022, at 05:42, 'michael....@method-b.uk' via Salt-users <salt-...@googlegroups.com> wrote:


--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/5619827e-4281-4a0f-805e-ff3ea0660987n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages