我正在尝试通过我的剧本将自制程序安装到 Linux ubuntu 主机节点上,但无法弄清楚。我尝试了几种变体,但每一种都失败了。
为了完整起见,这里是试用路径。
- name: "foo brew"
hosts: "machines"
become: true
become_method: sudo
become_user: foo
tasks:
- name: "install HomeBrew"
expect:
command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
responses:
"Press RETURN/ENTER to continue or any other key to abort:": ''
register: hombrew
- debug:
var: homebrew.stdout_lines
fatal: [192.168.1.000]: FAILED! => {"changed": true, "cmd": "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"", "delta": "0:00:00.173932", "end": "2025-01-04 09:53:21.517005", "msg": "non-zero return code", "rc": 127, "start": "2025-01-04 09:53:21.343073", "stdout": "/bin/bash: line 1: #!/bin/bash: No such file or directory", "stdout_lines": ["/bin/bash: line 1: #!/bin/bash: No such file or directory"]}
我知道
/bin/bash
安装在我尝试运行此命令的主机上。
这种模式似乎是最有希望的。使用
shell
模块运行 brew install 并绕过提示。同样奇怪的是命令中的错误没有持续存在。
- name: "foo brew"
hosts: "machines"
become: true
become_method: sudo
become_user: foo
tasks:
- name: "install HomeBrew"
become: true
become_method: sudo
become_user: foo
shell: echo | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
register: brew
- debug:
var: brew.stdout_lines
fatal: [192.168.1.000]: FAILED! => {"changed": true, "cmd": "echo | /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"", "delta": "0:00:00.211944", "end": "2025-01-04 09:56:57.957293", "msg": "non-zero return code", "rc": 1, "start": "2025-01-04 09:56:57.745349", "stderr": "Warning: Running in non-interactive mode because `stdin` is not a TTY.\nInsufficient permissions to install Homebrew to \"/home/linuxbrew/.linuxbrew\" (the default prefix).\n\nAlternative (unsupported) installation methods are available at:\nhttps://docs.brew.sh/Installation#alternative-installs\n\nPlease note this will require most formula to build from source, a buggy, slow and energy-inefficient experience.\nWe will close any issues without response for these unsupported configurations.", "stderr_lines": ["Warning: Running in non-interactive mode because `stdin` is not a TTY.", "Insufficient permissions to install Homebrew to \"/home/linuxbrew/.linuxbrew\" (the default prefix).", "", "Alternative (unsupported) installation methods are available at:", "https://docs.brew.sh/Installation#alternative-installs", "", "Please note this will require most formula to build from source, a buggy, slow and energy-inefficient experience.", "We will close any issues without response for these unsupported configurations."], "stdout": "==> Checking for `sudo` access (which may request your password)...", "stdout_lines": ["==> Checking for `sudo` access (which may request your password)..."]}
从错误消息来看,安装命令没有作为
sudo
运行,但我正在使用 become
并显式设置 become_method
。当我执行 ansible playbook 时,我正在使用 --ask-become-pass
。
我感到困惑和沮丧,因为这似乎是机器设置和配置的一个非常愉快的路径用例。我确信我错过了一些简单的事情。预先感谢您。
我找到了有关在 Linux 上使用和安装 HomeBrew 的链接,这里是链接 Linux 上的 HomeBrew