我正在尝试配置 Ansible 以安装 Brewfile 中定义的所有软件包,但出现以下错误
fatal: [localhost]: FAILED! => {"changed": true, "cmd": "brew bundle", "delta": "0:00:00.163639", "end": "2024-04-02 21:03:51.639762", "msg": "non-zero return code", "rc": 1, "start": "2024-04-02 21:03:51.476123", "stderr": "Error: Running Homebrew as root is extremely dangerous and no longer supported.\nAs Homebrew does not drop privileges on installation you would be giving all\nbuild scripts full access to your system.", "stderr_lines": ["Error: Running Homebrew as root is extremely dangerous and no longer supported.", "As Homebrew does not drop privileges on installation you would be giving all", "build scripts full access to your system."], "stdout": "", "stdout_lines": []}
这就是我的文件的样子
# bootstrap.yaml
- name: Bootstrap development environment
hosts: localhost
tasks:
- name: Install packages from Brewfile
become: yes
ansible.builtin.shell: brew bundle
when: ansible_distribution == "MacOSX"
# Brewfile
brew "autoconf"
brew "docker", link: false
当我跑步时
ansible-playbook --ask-become-pass bootstrap.yml
我收到上述错误。
这个错误的原因是什么?
顺便说一下,我已经安装了 Ansible 的
community.general
集合,并且已经安装了 Homebrew。 AFAIK,brew bundle
在 Ansible 中仍然不可用,但我不明白为什么 shell 命令不可用。
感谢您的评论。我已将文件更改为
# bootstrap.yaml
- name: Bootstrap development environment
hosts: localhost
tasks:
- name: Install packages from Brewfile
ansible.builtin.shell: brew bundle
when: ansible_distribution == "MacOSX"
我现在正在运行
ansible-playbook bootstrap.yml
没有问题。