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

PATH issue finding MAS, when running REMOTELY #86

Open
jeverett-syl opened this issue Dec 22, 2023 · 1 comment
Open

PATH issue finding MAS, when running REMOTELY #86

jeverett-syl opened this issue Dec 22, 2023 · 1 comment

Comments

@jeverett-syl
Copy link

jeverett-syl commented Dec 22, 2023

Running my playbook on my Mac acting as control node and managing itself as localhost, everything works fine with MAS:

$ ansible-playbook -i inventory/localhost.yml macOS_app-installs.yml --ask-become-pass
...

TASK [geerlingguy.mac.mas : Ensure MAS is installed.] *******************************************************************************************************************************************************
ok: [127.0.0.1]
...
TASK [geerlingguy.mac.mas : List installed MAS apps.] *******************************************************************************************************************************************************
ok: [127.0.0.1]
...

However, when I try running the same playbook via SSH remotely, something fails after detecting the installed MAS, and when MAS is called to run (and it comes back, "[Errno 2] No such file or directory: b'mas'"):

$ ansible-playbook -i inventory/mac_ssh.yml macOS_app-installs.yml --private-key ~/.ssh/id_rsa --ask-become-pass
...
TASK [geerlingguy.mac.mas : Ensure MAS is installed.] **************************************************************************************************************
ok: [192.168.1.97]
...
TASK [geerlingguy.mac.mas : List installed MAS apps.] **************************************************************************************************************
fatal: [192.168.1.97]: FAILED! => {"changed": false, "cmd": "mas list", "msg": "[Errno 2] No such file or directory: b'mas'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

I can correct this problem when coming in remotely by tweaking the PATH in the environment, like this:

  environment:
    PATH: /usr/local/bin:{{ lookup('ansible.builtin.env', 'PATH') }}

  roles:
    - geerlingguy.mac.homebrew
    - geerlingguy.mac.mas

that is, by injecting into the PATH environment variable where (on my Intel Mac) the mas executable is.

$ ls -l $(which mas)
lrwxr-xr-x  1 user  group  27 Dec 20 14:08 /usr/local/bin/mas -> ../Cellar/mas/1.8.6/bin/mas

(I'd imagine, on an Apple Silicon Mac, if Apple Silicon systems have the same problem, one might need to inject "/opt/homebrew" instead of "/usr/local/bin".)

However, it seems strange that "TASK [geerlingguy.mac.mas : Ensure MAS is installed.]" works fine (i.e., it finds the mas executable), but then when it comes it comes time to actually use the detected installed mas in "TASK [geerlingguy.mac.mas : List installed MAS apps.]" then it fails. (And, perhaps, if it got that far, it'd also fail in "TASK [geerlingguy.mac.mas : Ensure configured MAS apps are installed.]" as well.)

I found a couple of past issues referencing what sounds like the same/similar problems, but those both ended up going stale and getting closed.
Problems with the PATH fo mas commands #10
and
Installing apps with mas doesn't work for pubkey ssh tunnels #70

Is there a fix for this that should be put in the role code, and that would work across Intel and Apple Silicon Macs? Or is it just best to stick with tweaking the PATH in the calling playbook? Or is this a problem somewhere else that needs to be corrected instead?

Thanks for any guidance!

@Moghi
Copy link

Moghi commented Jul 22, 2024

I am having the same problem and I am running the playbook locally. I was able to confirm that mas is indeed installed at /opt/homebrew/bin, but the task geerlingguy.mac.mas : List installed MAS apps. fails with [Errno 2] No such file or directory: b''mas'''. 4 tasks before there is a task ensuring that mas is installed.

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

No branches or pull requests

2 participants