安裝 Ansible 在 macOS 上
Ansible 可以通過多種方式在 macOS 上安裝,推薦使用 pip
或 Homebrew。
使用 Homebrew 安裝 Ansible
運行以下命令:
brew install ansible
使用 pip 安裝 Ansible
確保 Python 已安裝(macOS 通常自帶 Python),然后運行:
pip install ansible
驗證安裝是否成功:
ansible --version
準備 hosts 文件
Ansible 使用 hosts
文件(也稱為 Inventory 文件)定義目標主機。創建一個 hosts
文件:
[servers]
localhost ansible_connection=local