2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ansibleをオフラインでインストールするためのメモ

Posted at

Ansibleをオフラインでインストール

本記事はAnsibleをオフライン環境でインストールするために調査したものになります。
なので、中途半端ですし、間違っている可能性もありますので、あくまでも参考程度となります。

環境

# cat /etc/redhat-release 
CentOS Linux release 8.3.2011

# pip3 --version
pip 20.3.3 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

# python3 --version
Python 3.6.8

資材を揃える

まず、最新のAnsibleの依存関係を知るためにオンライン環境で以下を実施します。
ansible2.10からはansible-baseがモジュールとして入ったようです。

【オンラインでやる作業】
# mkdir /tmp/src
# pip3 download -d /tmp/src --no-binary :all: ansible 
# ls -l /tmp/src
合計 35968
-rw-r--r-- 1 root root   257594 12月 20 18:05 Jinja2-2.11.2.tar.gz
-rw-r--r-- 1 root root    19151 12月 20 18:05 MarkupSafe-1.1.1.tar.gz
-rw-r--r-- 1 root root   269377 12月 20 18:05 PyYAML-5.3.1.tar.gz
-rw-r--r-- 1 root root 28622006 12月 20 18:04 ansible-2.10.4.tar.gz
-rw-r--r-- 1 root root  5708083 12月 20 18:05 ansible-base-2.10.4.tar.gz
-rw-r--r-- 1 root root   471302 12月 20 18:05 cffi-1.14.4.tar.gz
-rw-r--r-- 1 root root   539756 12月 20 18:05 cryptography-3.3.1.tar.gz
-rw-r--r-- 1 root root    79359 12月 20 18:05 packaging-20.8.tar.gz
-rw-r--r-- 1 root root   161330 12月 20 18:05 pycparser-2.20.tar.gz
-rw-r--r-- 1 root root   649718 12月 20 18:05 pyparsing-2.4.7.tar.gz
-rw-r--r-- 1 root root    33917 12月 20 18:05 six-1.15.0.tar.gz

また、上とは別に以下も必要なものとなる。

pip-20.3.3.tar.gz
wheel-0.36.2.tar.gz
setuptools-51.0.0.tar.gz
sshpass-1.06-9.el8.x86_64.rpm

上のパッケージを参考に https://pypi.org/ より必要なものをダウンロードします。
sshpassは以下よりダウンロードする。
https://centos.pkgs.org/8/epel-x86_64/sshpass-1.06-9.el8.x86_64.rpm.html
なんらかの方法でオフライン環境に必要パッケージを格納します。
以降は格納できたとして、進めます。

sshpassのインストール

# mkdir /tmp/sshpass
# ls -l /tmp/sshpass
-rw-r--r-- 1 root root 28064 12月 21 09:15 sshpass-1.06-9.el8.x86_64.rpm

# rpm -ivh /tmp/sshpass/sshpass-1.06-9.el8.x86_64.rpm

pipのオフラインアップグレード

# mkdir /tmp/pip
# ls -l /tmp/pip
-rw-r--r-- 1 root root 1529320 12月 21 09:15 pip-20.3.3.tar.gz

# pip3 install --upgrade /tmp/pip/pip-20.3.3.tar.gz

Ansibleのインストール

以下のコマンドでAnsibleをインストールします。

# mkdir /tmp/src
# ls -l /tmp/src
-rw-r--r-- 1 root root   257594 12月 21 09:15 Jinja2-2.11.2.tar.gz
-rw-r--r-- 1 root root    19151 12月 21 09:15 MarkupSafe-1.1.1.tar.gz
-rw-r--r-- 1 root root   269377 12月 21 09:15 PyYAML-5.3.1.tar.gz
-rw-r--r-- 1 root root 28622006 12月 21 09:15 ansible-2.10.4.tar.gz
-rw-r--r-- 1 root root  5708083 12月 21 09:15 ansible-base-2.10.4.tar.gz
-rw-r--r-- 1 root root   471302 12月 21 09:15 cffi-1.14.4.tar.gz
-rw-r--r-- 1 root root   539756 12月 21 09:15 cryptography-3.3.1.tar.gz
-rw-r--r-- 1 root root    79359 12月 21 09:15 packaging-20.8.tar.gz
-rw-r--r-- 1 root root   161330 12月 21 09:15 pycparser-2.20.tar.gz
-rw-r--r-- 1 root root   649718 12月 21 09:15 pyparsing-2.4.7.tar.gz
-rw-r--r-- 1 root root  1957464 12月 21 14:11 setuptools-51.0.0.tar.gz
-rw-r--r-- 1 root root    33917 12月 21 09:15 six-1.15.0.tar.gz
-rw-r--r-- 1 root root    65393 12月 21 14:21 wheel-0.36.2.tar.gz

# python3 -m pip install --no-index --find-links /tmp/src/ansible-2.10.4.tar.gz --user ansible
Processing /tmp/src/ansible-2.10.4.tar.gz
Collecting ansible-base<2.11,>=2.10.3
  Using cached ansible-base-2.10.4.tar.gz (5.7 MB)
Requirement already satisfied: jinja2 in /usr/local/lib/python3.6/site-packages (from ansible-base<2.11,>=2.10.3->ansible==2.10.4) (2.11.2)
Requirement already satisfied: PyYAML in /usr/local/lib64/python3.6/site-packages (from ansible-base<2.11,>=2.10.3->ansible==2.10.4) (5.3.1)
Requirement already satisfied: cryptography in /usr/local/lib64/python3.6/site-packages (from ansible-base<2.11,>=2.10.3->ansible==2.10.4) (3.3.1)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib64/python3.6/site-packages (from cryptography->ansible-base<2.11,>=2.10.3->ansible==2.10.4) (1.14.4)
Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python3.6/site-packages (from cryptography->ansible-base<2.11,>=2.10.3->ansible==2.10.4) (1.15.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.6/site-packages (from cffi>=1.12->cryptography->ansible-base<2.11,>=2.10.3->ansible==2.10.4) (2.20)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib64/python3.6/site-packages (from jinja2->ansible-base<2.11,>=2.10.3->ansible==2.10.4) (1.1.1)
Collecting packaging
  Using cached packaging-20.8-py2.py3-none-any.whl (39 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Using legacy 'setup.py install' for ansible, since package 'wheel' is not installed.
Using legacy 'setup.py install' for ansible-base, since package 'wheel' is not installed.
Installing collected packages: pyparsing, packaging, ansible-base, ansible
    Running setup.py install for ansible-base ... done
    Running setup.py install for ansible ... done
Successfully installed ansible-2.10.4 ansible-base-2.10.4 packaging-20.8 pyparsing-2.4.7
# ansible --version
ansible 2.10.4
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

インストール後のパッケージのバージョン一覧。

# pip list
Package              Version
-------------------- -----------
ansible              2.10.4
ansible-base         2.10.4
bcc                  0.14.0
blivet               3.2.2
Brlapi               0.6.7
cffi                 1.14.4
chardet              3.0.4
chrome-gnome-shell   0.0.0
configobj            5.0.6
cryptography         3.3.1
cupshelpers          1.0
dasbus               1.2
dbus-python          1.2.4
decorator            4.2.1
ethtool              0.14
gpg                  1.13.1
html5lib             0.999999999
idna                 2.5
iniparse             0.4
initial-setup        0.3.81.6
iotop                0.6
isc                  2.0
Jinja2               2.11.2
jsonpointer          1.10
kmod                 0.1
langtable            0.0.51
libvirt-python       6.0.0
lxml                 4.2.3
MarkupSafe           1.1.1
netaddr              0.7.19
nftables             0.1
ntplib               0.3.3
ordered-set          2.0.2
packaging            20.8
pcp                  5.0
perf                 0.1
pid                  2.1.1
pip                  20.3.3
ply                  3.9
productmd            1.11
psycopg2             2.7.5
pwquality            1.4.0
pycairo              1.16.3
pycparser            2.20
pycups               1.9.72
pycurl               7.43.0.2
pydbus               0.6.0
pyenchant            2.0.0
pygobject            3.28.3
pyinotify            0.9.6
pykickstart          3.16.11
pyparsing            2.4.7
pyparted             3.11.0
PySocks              1.6.8
python-dateutil      2.6.1
python-dmidecode     3.12.2
python-linux-procfs  0.6.2
python-meh           0.47.2
pytz                 2017.2
pyudev               0.21.0
pyxdg                0.25
PyYAML               5.3.1
requests             2.20.0
requests-file        1.4.3
requests-ftp         0.3.1
rpm                  4.14.3
rtslib-fb            2.1.73
schedutils           0.6
selinux              2.9
sepolicy             1.1
setools              4.3.0
setroubleshoot       1.1
setuptools           51.0.0
simpleline           1.1.1
six                  1.15.0
slip                 0.6.4
slip.dbus            0.6.4
sos                  3.9
SSSDConfig           2.3.0
subscription-manager 1.27.16
syspurpose        1.27.16
systemd-python       234
urllib3              1.24.2
webencodings         0.5.1

番外編

Ansibleのバージョン指定をした場合。今回は2.9の最新バージョンを選択。
確認すると、2.10ではtar.gzだったが、2.9は.whlがあることがわかります。

【オンラインでやる作業】
# mkdir /tmp/src2
# pip3 download -d /tmp/src2 ansible==2.9.16
# ls -l /tmp/src2
合計 17400
-rw-r--r-- 1 root root   125774 12月 20 18:55 Jinja2-2.11.2-py2.py3-none-any.whl
-rw-r--r-- 1 root root    27520 12月 20 18:55 MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
-rw-r--r-- 1 root root   269377 12月 20 18:55 PyYAML-5.3.1.tar.gz
-rw-r--r-- 1 r# python3 -m pip install /tmp/src2/ansible-2.9.16.tar.gz oot root 14245156 12月 20 18:55 ansible-2.9.16.tar.gz
-rw-r--r-- 1 root root   401227 12月 20 18:55 cffi-1.14.4-cp36-cp36m-manylinux1_x86_64.whl
-rw-r--r-- 1 root root  2617057 12月 20 18:55 cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl
-rw-r--r-- 1 root root   112041 12月 20 18:55 pycparser-2.20-py2.py3-none-any.whl
-rw-r--r-- 1 root root    10963 12月 20 18:55 six-1.15.0-py2.py3-none-any.whl
# python3 -m pip install --no-index --find-links /tmp/src2/ansible-2.9.16.tar.gz --user ansible
Processing /tmp/src2/ansible-2.9.16.tar.gz
Collecting cryptography
  Using cached cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl (2.6 MB)
Collecting cffi>=1.12
  Using cached cffi-1.14.4-cp36-cp36m-manylinux1_x86_64.whl (401 kB)
Collecting six>=1.4.1
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting jinja2
  Using cached Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
Collecting MarkupSafe>=0.23
  Using cached MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (27 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Collecting PyYAML
  Using cached PyYAML-5.3.1.tar.gz (269 kB)
Using legacy 'setup.py install' for ansible, since package 'wheel' is not installed.
Using legacy 'setup.py install' for PyYAML, since package 'wheel' is not installed.
Installing collected packages: pycparser, six, MarkupSafe, cffi, PyYAML, jinja2, cryptography, ansible
    Running setup.py install for PyYAML ... done
    Running setup.py install for ansible ... done
Successfully installed MarkupSafe-1.1.1 PyYAML-5.3.1 ansible-2.9.16 cffi-1.14.4 cryptography-3.3.1 jinja2-2.11.2 pycparser-2.20 six-1.15.0
# pip list
Package              Version
-------------------- -----------
ansible              2.9.16
bcc                  0.14.0
blivet               3.2.2
Brlapi               0.6.7
cffi                 1.14.4
chardet              3.0.4
chrome-gnome-shell   0.0.0
configobj            5.0.6
cryptography         3.3.1
cupshelpers          1.0
dasbus               1.2
dbus-python          1.2.4
decorator            4.2.1
ethtool              0.14
gpg                  1.13.1
html5lib             0.999999999
idna                 2.5
iniparse             0.4
initial-setup        0.3.81.6
iotop                0.6
isc                  2.0
Jinja2               2.11.2
jsonpointer          1.10
kmod                 0.1
langtable            0.0.51
libvirt-python       6.0.0
lxml                 4.2.3
MarkupSafe           1.1.1
netaddr              0.7.19
nftables             0.1
ntplib               0.3.3
ordered-set          2.0.2
pcp                  5.0
perf                 0.1
pid                  2.1.1
pip                  20.3.3
ply                  3.9
productmd            1.11
psycopg2             2.7.5
pwquality            1.4.0
pycairo              1.16.3
pycparser            2.20
pycups               1.9.72
pycurl               7.43.0.2
pydbus               0.6.0
pyenchant            2.0.0
pygobject            3.28.3
pyinotify            0.9.6
pykickstart          3.16.11
pyparted             3.11.0
PySocks              1.6.8
python-dateutil      2.6.1
python-dmidecode     3.12.2
python-linux-procfs  0.6.2
python-meh           0.47.2
pytz                 2017.2
pyudev               0.21.0
pyxdg                0.25
PyYAML               5.3.1
requests             2.20.0
requests-file        1.4.3
requests-ftp         0.3.1
rpm                  4.14.3
rtslib-fb            2.1.73
schedutils           0.6
selinux              2.9
sepolicy             1.1
setools              4.3.0
setroubleshoot       1.1
setuptools           51.0.0
simpleline           1.1.1
six                  1.15.0
slip                 0.6.4
slip.dbus            0.6.4
sos                  3.9
SSSDConfig           2.3.0
subscription-manager 1.27.16
syspurpose           1.27.16
systemd-python       234
urllib3              1.24.2
webencodings         0.5.1
# ansible --version
ansible 2.9.16
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

Ansible2.9と2.10のモジュールの差分

2.10 2.9
ansible 2.10.4 ansible 2.9.16
ansible-base 2.10.4
packaging 20.8
pyparsing 2.4.7
webencodings 0.5.1

path問題

ansibleコマンドで実行できない場合、以下で試してみる。

# ./.local/bin/ansible --help
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?