我正在尝试使用ansible运行自制软件。我正处于正确安装自制软件的阶段。我只需要配置brew的路径即可。
因为没有路径brew command not found
。
我正在关注:
https://docs.brew.sh/Homebrew-on-Linux
我正在尝试将以下命令添加到ansible中。
test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile
Ansible:
- name: map 1
shell: test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
错误:
FAILED! => {"changed": true, "cmd": "test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)", "delta": "0:00:00.002858", "end": "2020-07-14 16:44:20.881614", "msg": "non-zero return code", "rc": 1, "start": "2020-07-14 16:44:20.878756", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
答案 0 :(得分:0)
经过大量测试,我发现这与所使用的用户帐户有关。
默认情况下,我的基本ansible脚本设置为root
。因此,我需要做的是在become_user: ec2-user
become: no
- name: Test homebrew directive and eval homebrew path
become: no
shell: test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
become_user: ec2-user