Ansible環境を構築してみよう!!
次回はソースコードバージョンをリリース予定
https://github.com/ansible/ansible
https://github.com/ansible/ansible/releases/tag/v2.15.4
OSバージョン:CentOS Stream release 8
インストール前に実施したこと
firewalld.serviceの停止
Selinuxの停止
[root@ansible ~]# dnf install python3
メタデータの期限切れの最終確認: 0:01:57 時間前の 2023年09月30日 04時40分49秒 に実施しました。
依存関係が解決しました。
=======================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
=======================================================================================================================================
インストール:
python36 x86_64 3.6.8-38.module_el8.5.0+895+a459eca8 appstream 19 k
依存関係のインストール:
python3-pip noarch 9.0.3-20.el8 appstream 20 k
python3-setuptools noarch 39.2.0-6.el8 baseos 163 k
モジュールストリームの有効化中:
python36 3.6
トランザクションの概要
=======================================================================================================================================
インストール 3 パッケージ
ダウンロードサイズの合計: 202 k
インストール後のサイズ: 466 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/3): python3-pip-9.0.3-20.el8.noarch.rpm 19 kB/s | 20 kB 00:01
(2/3): python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64.rpm 19 kB/s | 19 kB 00:01
(3/3): python3-setuptools-39.2.0-6.el8.noarch.rpm 147 kB/s | 163 kB 00:01
---------------------------------------------------------------------------------------------------------------------------------------
合計 70 kB/s | 202 kB 00:02
警告: /var/cache/dnf/appstream-773ef6463612e8e2/packages/python3-pip-9.0.3-20.el8.noarch.rpm: ヘッダー V3 RSA/SHA256 Signature、鍵 ID 8 483c65d: NOKEY
CentOS Stream 8 - AppStream 1.6 MB/s | 1.6 kB 00:00
GPG 鍵 0x8483C65D をインポート中:
Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>"
Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
準備 : 1/1
インストール中 : python3-setuptools-39.2.0-6.el8.noarch 1/3
インストール中 : python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 2/3
scriptletの実行中: python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 2/3
インストール中 : python3-pip-9.0.3-20.el8.noarch 3/3
scriptletの実行中: python3-pip-9.0.3-20.el8.noarch 3/3
検証 : python3-pip-9.0.3-20.el8.noarch 1/3
検証 : python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64 2/3
検証 : python3-setuptools-39.2.0-6.el8.noarch 3/3
インストール済み:
python3-pip-9.0.3-20.el8.noarch python3-setuptools-39.2.0-6.el8.noarch python36-3.6.8-38.module_el8.5.0+895+a459eca8.x86_64
完了しました!
[root@ansible ~]#
続いてsshpassのインストール
[root@ansible ~]# dnf install sshpass
メタデータの期限切れの最終確認: 0:01:44 時間前の 2023年09月30日 04時43分20秒 に実施しました。
依存関係が解決しました。
=============================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
=============================================================================================================================================================
インストール:
sshpass x86_64 1.09-4.el8 appstream 30 k
トランザクションの概要
=============================================================================================================================================================
インストール 1 パッケージ
ダウンロードサイズの合計: 30 k
インストール後のサイズ: 43 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
sshpass-1.09-4.el8.x86_64.rpm 31 kB/s | 30 kB 00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
合計 8.2 kB/s | 30 kB 00:03
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
準備 : 1/1
インストール中 : sshpass-1.09-4.el8.x86_64 1/1
scriptletの実行中: sshpass-1.09-4.el8.x86_64 1/1
検証 : sshpass-1.09-4.el8.x86_64 1/1
インストール済み:
sshpass-1.09-4.el8.x86_64
完了しました!
それではAnsibleをインストールすると
失敗
[ansible@ansible ~]$ pip3 install ansible
Collecting ansible
Using cached https://files.pythonhosted.org/packages/fd/f8/071905c6a67592d0852a9f340f6ab9226861eeeb97fdf4068642b22edcf3/ansible-4.10.0.tar.gz
Collecting ansible-core~=2.11.7 (from ansible)
Using cached https://files.pythonhosted.org/packages/98/ea/2935bf0864196cd2c9d14548e399a110f48b3540664ddc462b39ff0b822d/ansible-core-2.11.12.tar.gz
Collecting jinja2 (from ansible-core~=2.11.7->ansible)
Using cached https://files.pythonhosted.org/packages/20/9a/e5d9ec41927401e41aea8af6d16e78b5e612bca4699d417f646a9610a076/Jinja2-3.0.3-py3-none-any.whl
Collecting PyYAML (from ansible-core~=2.11.7->ansible)
Using cached https://files.pythonhosted.org/packages/cd/e5/af35f7ea75cf72f2cd079c95ee16797de7cd71f29ea7c68ae5ce7be1eda0/PyYAML-6.0.1.tar.gz
Collecting cryptography (from ansible-core~=2.11.7->ansible)
Using cached https://files.pythonhosted.org/packages/f7/80/04cc7637238b78f8e7354900817135c5a23cf66dfb3f3a216c6d630d6833/cryptography-40.0.2.tar.gz
Complete output from command python setup.py egg_info:
=============================DEBUG ASSISTANCE==========================
If you are seeing an error here please try the following to
successfully install cryptography:
Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
=============================DEBUG ASSISTANCE==========================
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-4uzmodmx/cryptography/setup.py", line 18, in <module>
from setuptools_rust import RustExtension
ModuleNotFoundError: No module named 'setuptools_rust'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-4uzmodmx/cryptography/
少し調べるとpipのバージョンを最新バージョンにする必要があると
記載を発見
ではpipを最新化します
[root@ansible ~]# pip3 install --upgrade pip
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pip
Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
100% |????????????????????????????????| 1.7MB 1.4MB/s
Installing collected packages: pip
Successfully installed pip-21.3.1
再度Ansibleユーザにスイッチして気を取り直して
Ansibleのインストール
[root@ansible ~]# su - ansible
[ansible@ansible ~]$ pip3 install ansible
Defaulting to user installation because normal site-packages is not writeable
Collecting ansible
Using cached ansible-4.10.0.tar.gz (36.8 MB)
Preparing metadata (setup.py) ... done
Collecting ansible-core~=2.11.7
Using cached ansible-core-2.11.12.tar.gz (7.1 MB)
Preparing metadata (setup.py) ... done
Collecting jinja2
Using cached Jinja2-3.0.3-py3-none-any.whl (133 kB)
Collecting PyYAML
Downloading PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (677 kB)
|????????????????????????????????| 677 kB 15.4 MB/s
Collecting cryptography
Downloading cryptography-40.0.2-cp36-abi3-manylinux_2_28_x86_64.whl (3.7 MB)
|????????????????????????????????| 3.7 MB 97.9 MB/s
Collecting packaging
Downloading packaging-21.3-py3-none-any.whl (40 kB)
|????????????????????????????????| 40 kB 20.5 MB/s
Collecting resolvelib<0.6.0,>=0.5.3
Downloading resolvelib-0.5.4-py2.py3-none-any.whl (12 kB)
Collecting cffi>=1.12
Downloading cffi-1.15.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (402 kB)
|????????????????????????????????| 402 kB 106.3 MB/s
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
Downloading pyparsing-3.1.1-py3-none-any.whl (103 kB)
|????????????????????????????????| 103 kB 40.1 MB/s
Collecting pycparser
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
|????????????????????????????????| 118 kB 37.5 MB/s
Using legacy 'setup.py install' for ansible, since package 'wheel' is not installed.
Using legacy 'setup.py install' for ansible-core, since package 'wheel' is not installed.
Installing collected packages: pycparser, pyparsing, MarkupSafe, cffi, resolvelib, PyYAML, packaging, jinja2, cryptography, ansible-core, ansible
Running setup.py install for ansible-core ... done
Running setup.py install for ansible ... done
Successfully installed MarkupSafe-2.0.1 PyYAML-6.0.1 ansible-4.10.0 ansible-core-2.11.12 cffi-1.15.1 cryptography-40.0.2 jinja2-3.0.3 packaging-21.3 pycparser-2.21 pyparsing-3.1.1 resolvelib-0.5.4
参考URL
https://densan-hoshigumi.com/server/ansible/install-rhel8-centos8