Debian13 安裝 Ansible

2026-02-26 linux linux ansible debian

以下是我在 Debian 13 安裝 Ansible 紀錄

sudo apt install python3-venv -y
mkdir ~/ansible_legacy && cd ~/ansible_legacy
python3 -m venv venv
source venv/bin/activate
pip install "ansible-core<2.17"
vim ~/.zshrc
# source ~/ansible_legacy/venv/bin/activate

結果如下

❯ sudo apt install python3-venv -y
Installing:                     
  python3-venv

Installing dependencies:
  python3-pip-whl  python3-setuptools-whl  python3.13-venv

Summary:
  Upgrading: 0, Installing: 4, Removing: 0, Not Upgrading: 0
  Download size: 2,782 kB
  Space needed: 2,957 kB / 961 GB available

Get:1 http://ftp.tw.debian.org/debian trixie/main amd64 python3-pip-whl all 25.1.1+dfsg-1 [1,507 kB]
Get:2 http://ftp.tw.debian.org/debian trixie/main amd64 python3-setuptools-whl all 78.1.1-0.1 [1,268 kB]
Get:3 http://ftp.tw.debian.org/debian trixie/main amd64 python3.13-venv amd64 3.13.5-2 [5,472 B]
Get:4 http://ftp.tw.debian.org/debian trixie/main amd64 python3-venv amd64 3.13.5-1 [1,180 B]
Fetched 2,782 kB in 2s (1,679 kB/s)      
Selecting previously unselected package python3-pip-whl.
(Reading database ... 332994 files and directories currently installed.)
Preparing to unpack .../python3-pip-whl_25.1.1+dfsg-1_all.deb ...
Unpacking python3-pip-whl (25.1.1+dfsg-1) ...
Selecting previously unselected package python3-setuptools-whl.
Preparing to unpack .../python3-setuptools-whl_78.1.1-0.1_all.deb ...
Unpacking python3-setuptools-whl (78.1.1-0.1) ...
Selecting previously unselected package python3.13-venv.
Preparing to unpack .../python3.13-venv_3.13.5-2_amd64.deb ...
Unpacking python3.13-venv (3.13.5-2) ...
Selecting previously unselected package python3-venv.
Preparing to unpack .../python3-venv_3.13.5-1_amd64.deb ...
Unpacking python3-venv (3.13.5-1) ...
Setting up python3-setuptools-whl (78.1.1-0.1) ...
Setting up python3-pip-whl (25.1.1+dfsg-1) ...
Setting up python3.13-venv (3.13.5-2) ...
Setting up python3-venv (3.13.5-1) ...


❯ mkdir ~/ansible_legacy && cd ~/ansible_legacy

❯ python3 -m venv venv

❯ source venv/bin/activate

❯ pip install "ansible-core<2.17"
Collecting ansible-core<2.17
  Downloading ansible_core-2.16.17-py3-none-any.whl.metadata (6.9 kB)
Collecting jinja2>=3.0.0 (from ansible-core<2.17)
  Downloading jinja2-3.1.6-py3-none-any.whl.metadata (2.9 kB)
Collecting PyYAML>=5.1 (from ansible-core<2.17)
  Downloading pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (2.4 kB)
Collecting cryptography (from ansible-core<2.17)
  Downloading cryptography-46.0.5-cp311-abi3-manylinux_2_34_x86_64.whl.metadata (5.7 kB)
Collecting packaging (from ansible-core<2.17)
  Downloading packaging-26.0-py3-none-any.whl.metadata (3.3 kB)
Collecting resolvelib<1.1.0,>=0.5.3 (from ansible-core<2.17)
  Downloading resolvelib-1.0.1-py2.py3-none-any.whl.metadata (4.0 kB)
Collecting MarkupSafe>=2.0 (from jinja2>=3.0.0->ansible-core<2.17)
  Downloading markupsafe-3.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (2.7 kB)
Collecting cffi>=2.0.0 (from cryptography->ansible-core<2.17)
  Downloading cffi-2.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (2.6 kB)
Collecting pycparser (from cffi>=2.0.0->cryptography->ansible-core<2.17)
  Downloading pycparser-3.0-py3-none-any.whl.metadata (8.2 kB)
Downloading ansible_core-2.16.17-py3-none-any.whl (2.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 168.7 kB/s eta 0:00:00
Downloading resolvelib-1.0.1-py2.py3-none-any.whl (17 kB)
Downloading jinja2-3.1.6-py3-none-any.whl (134 kB)
Downloading markupsafe-3.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (22 kB)
Downloading pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (801 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 801.6/801.6 kB 105.9 kB/s eta 0:00:00
Downloading cryptography-46.0.5-cp311-abi3-manylinux_2_34_x86_64.whl (4.5 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.5/4.5 MB 73.5 kB/s eta 0:00:00
Downloading cffi-2.0.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (219 kB)
Downloading packaging-26.0-py3-none-any.whl (74 kB)
Downloading pycparser-3.0-py3-none-any.whl (48 kB)
Installing collected packages: resolvelib, PyYAML, pycparser, packaging, MarkupSafe, jinja2, cffi, cryptography, ansible-core
Successfully installed MarkupSafe-3.0.3 PyYAML-6.0.3 ansible-core-2.16.17 cffi-2.0.0 cryptography-46.0.5 jinja2-3.1.6 packaging-26.0 pycparser-3.0 resolvelib-1.0.1

❯ ansible --version 
ansible [core 2.16.17]
  config file = None
  configured module search path = ['/home/pollochang/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/pollochang/ansible_legacy/venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/pollochang/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/pollochang/ansible_legacy/venv/bin/ansible
  python version = 3.13.5 (main, Jun 25 2025, 18:55:22) [GCC 14.2.0] (/home/pollochang/ansible_legacy/venv/bin/python3)
  jinja version = 3.1.6
  libyaml = True