Red Hat Enterprise Linux 9でのansibleのインストール作業結果をまとめました。
今回作業に利用したのは以下のLinuxです。
- Red Hat Enterprise Linux 9.5
RHEL9でのAnsibleの使用については以下の記事を参考に実施します。

ansible-freeipaについてはIdMを使用しなければ考慮する必要がありません。
Ansibleの概要
Ansibleの詳細は以下のRed Hatで説明されています。
RHEL8.5までと、RHEL8.6以降、RHEL9でのAnsibleは以下の通り仕様が異なります。
- Ansible Engine が Ansible Core に置き換わる(Ansible Engine はRHEL9.0以降サポートされなくなります)
- Ansible CoreがRHEL 9.0 リリース以降デフォルトでインストール可能、Ansible Engineはデフォルトで有効になるレポジトリ、BaseOS、AppStreamでインストールできない
- Ansible Coreには、ansible-playbook、ansibleコマンドなどが含まれる
Ansibleそのものの公式ドキュメントは以下です。日本語化されているので確認しやすくなっています。
参考:
Ansible Coreのサポート
Ansible CoreはRHEL8.6以降で問題なくサポートされます。RHEL9.0以降もサポートされています。

RHEL9のAnsibleのインストール可否状況確認
実際にRHEL9.5を起動して、Tera TermでSSH接続し以下の2つのコマンドを実行してみました。
dnf info ansible
dnf info ansible-core
まずはOSのバージョンを確認します。
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 9.5 (Plow)
それぞれのコマンドの実行結果は以下です。
[root@localhost ~]# dnf info ansible
サブスクリプション管理リポジトリーを更新しています。
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs) 6.9 kB/s | 4.1 kB 00:00
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs) 2.8 MB/s | 46 MB 00:16
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) 7.7 kB/s | 4.5 kB 00:00
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) 2.5 MB/s | 50 MB 00:20
メタデータの期限切れの最終確認: 0:00:04 前の 2025年02月24日 19時19分42秒 に実施しました。
エラー: 表示するための一致したパッケージはありません
[root@localhost ~]# dnf info ansible-core
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 0:14:14 前の 2025年02月24日 19時19分42秒 に実施しました。
利用可能なパッケージ
名前 : ansible-core
エポック : 1
バージョン : 2.14.17
リリース : 1.el9
Arch : x86_64
サイズ : 2.6 M
ソース : ansible-core-2.14.17-1.el9.src.rpm
リポジトリー : rhel-9-for-x86_64-appstream-rpms
概要 : SSH-based configuration management, deployment, and task execution system
URL : http://ansible.com
ライセンス : GPLv3+
説明 : Ansible is a radically simple model-driven configuration management,
: multi-node deployment, and remote task execution system. Ansible works
: over SSH and does not require any software or daemons to be installed
: on remote nodes. Extension modules can be written in any language and
: are transferred to managed machines automatically.
Ansible Engineはインストールされていませんが、Ansible Coreがインストール可能であることがわかります。これはBaseOS, AppStreamでインストール可能なrpmパッケージの中にAnsible Engineは含まれていないが、Ansible Coreが含まれていることを意味します。
RHEL9.5にはデフォルトでAnsibleはインストールされていない
Website Industriesで管理しているRHEL9.5環境でAnsibleがインストールされているかを確認してみました。
[root@localhost ~]# ansible --version
bash: ansible: コマンドが見つかりませんでした...
コマンド ansible' を提供するためにパッケージ 'ansible-core' をインストールしますか? [N/y]
デフォルトではインストールされていませんでした。
Ansible CoreとRed Hat Enterprise Linux (RHEL) システムロールをRHEL9.5にインストールする
RHEL9.5をRHNに接続し、BaseOS、AppStreamのレポジトリが有効になっていることを確認し、以下のコマンドでAnsible CoreとRed Hat Enterprise Linux (RHEL) システムロールをインストールします。
まずはレポジトリが有効になっていることを確認します。
[root@localhost ~]# yum repolist all | grep 有効
rhel-9-for-x86_64-appstream-rpms Red Hat Ent 有効化
rhel-9-for-x86_64-baseos-rpms Red Hat Ent 有効化
[root@localhost ~]#

Ansible Coreをインストール
yum/dnfコマンドでAnsible Coreをインストールします。
dnf install ansible-core
もしくは
yum install ansible-core
実際に実行してみます。
[root@localhost ~]# dnf install ansible-core
サブスクリプション管理リポジトリーを更新しています。
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs) 6.7 kB/s | 4.1 kB 00:00
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs) 5.3 MB/s | 50 MB 00:09
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) 7.4 kB/s | 4.5 kB 00:00
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) 4.8 MB/s | 52 MB 00:10
メタデータの期限切れの最終確認: 0:00:05 前の 2025年03月29日 20時30分00秒 に実施しました。
依存関係が解決しました。
=============================================================================================================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
=============================================================================================================================================================================================================================================
インストール:
ansible-core x86_64 1:2.14.17-1.el9 rhel-9-for-x86_64-appstream-rpms 2.6 M
依存関係のインストール:
git-core x86_64 2.43.5-2.el9_5 rhel-9-for-x86_64-appstream-rpms 4.4 M
python3-cffi x86_64 1.14.5-5.el9 rhel-9-for-x86_64-baseos-rpms 257 k
python3-cryptography x86_64 36.0.1-4.el9 rhel-9-for-x86_64-baseos-rpms 1.2 M
python3-packaging noarch 20.9-5.el9 rhel-9-for-x86_64-appstream-rpms 81 k
python3-ply noarch 3.11-14.el9 rhel-9-for-x86_64-baseos-rpms 111 k
python3-pycparser noarch 2.20-6.el9 rhel-9-for-x86_64-baseos-rpms 139 k
python3-pyparsing noarch 2.4.7-9.el9 rhel-9-for-x86_64-baseos-rpms 154 k
python3-resolvelib noarch 0.5.4-5.el9 rhel-9-for-x86_64-appstream-rpms 38 k
sshpass x86_64 1.09-4.el9 rhel-9-for-x86_64-appstream-rpms 30 k
トランザクションの概要
=============================================================================================================================================================================================================================================
インストール 10 パッケージ
ダウンロードサイズの合計: 9.1 M
インストール後のサイズ: 38 M
これでよろしいですか? [y/N]: y
Traceback (most recent call last):
File "/usr/bin/dnf", line 62, in <module>
main.user_main(sys.argv[1:], exit_code=True)
File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 201, in user_main
errcode = main(args)
File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 67, in main
return _main(base, args, cli_class, option_parser_class)
File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 106, in _main
return cli_run(cli, base)
File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 130, in cli_run
ret = resolving(cli, base)
File "/usr/lib/python3.9/site-packages/dnf/cli/main.py", line 176, in resolving
base.do_transaction(display=displays)
File "/usr/lib/python3.9/site-packages/dnf/cli/cli.py", line 218, in do_transaction
if self.conf.assumeno or not self.output.userconfirm():
File "/usr/lib/python3.9/site-packages/dnf/cli/output.py", line 663, in userconfirm
choice = dnf.i18n.ucd_input(msg)
File "/usr/lib/python3.9/site-packages/dnf/i18n.py", line 122, in ucd_input
return dnf.pycomp.raw_input()
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-1: invalid continuation byte
再起動して再度コマンドを実行したところ問題なくインストールできました。再起動以外は実施していませんので、上記の作業証跡と同じエラーが出た際は再起動をお試しいただけると幸いです。
メモリなどの不具合が原因かもしれません。
メモリーのトラブルにより、ダウンロードしたファイルに損傷が生じていたようです。
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 124: invalid continuation byte が出たときのその場しのぎ対処 - QiitaPython力が低いのでメモ。…
[root@localhost ~]# dnf install ansible-core
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 0:12:35 前の 2025年03月29日 20時30分00秒 に実施しました。
依存関係が解決しました。
=============================================================================================================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
=============================================================================================================================================================================================================================================
インストール:
ansible-core x86_64 1:2.14.17-1.el9 rhel-9-for-x86_64-appstream-rpms 2.6 M
依存関係のインストール:
git-core x86_64 2.43.5-2.el9_5 rhel-9-for-x86_64-appstream-rpms 4.4 M
python3-cffi x86_64 1.14.5-5.el9 rhel-9-for-x86_64-baseos-rpms 257 k
python3-cryptography x86_64 36.0.1-4.el9 rhel-9-for-x86_64-baseos-rpms 1.2 M
python3-packaging noarch 20.9-5.el9 rhel-9-for-x86_64-appstream-rpms 81 k
python3-ply noarch 3.11-14.el9 rhel-9-for-x86_64-baseos-rpms 111 k
python3-pycparser noarch 2.20-6.el9 rhel-9-for-x86_64-baseos-rpms 139 k
python3-pyparsing noarch 2.4.7-9.el9 rhel-9-for-x86_64-baseos-rpms 154 k
python3-resolvelib noarch 0.5.4-5.el9 rhel-9-for-x86_64-appstream-rpms 38 k
sshpass x86_64 1.09-4.el9 rhel-9-for-x86_64-appstream-rpms 30 k
トランザクションの概要
=============================================================================================================================================================================================================================================
インストール 10 パッケージ
ダウンロードサイズの合計: 9.1 M
インストール後のサイズ: 38 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/10): python3-pyparsing-2.4.7-9.el9.noarch.rpm 221 kB/s | 154 kB 00:00
(2/10): python3-ply-3.11-14.el9.noarch.rpm 158 kB/s | 111 kB 00:00
(3/10): python3-cffi-1.14.5-5.el9.x86_64.rpm 272 kB/s | 257 kB 00:00
(4/10): python3-pycparser-2.20-6.el9.noarch.rpm 429 kB/s | 139 kB 00:00
(5/10): python3-resolvelib-0.5.4-5.el9.noarch.rpm 151 kB/s | 38 kB 00:00
(6/10): sshpass-1.09-4.el9.x86_64.rpm 82 kB/s | 30 kB 00:00
(7/10): python3-packaging-20.9-5.el9.noarch.rpm 254 kB/s | 81 kB 00:00
(8/10): python3-cryptography-36.0.1-4.el9.x86_64.rpm 1.4 MB/s | 1.2 MB 00:00
(9/10): ansible-core-2.14.17-1.el9.x86_64.rpm 1.7 MB/s | 2.6 MB 00:01
(10/10): git-core-2.43.5-2.el9_5.x86_64.rpm 2.0 MB/s | 4.4 MB 00:02
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計 2.4 MB/s | 9.1 MB 00:03
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
準備中 : 1/1
インストール中 : git-core-2.43.5-2.el9_5.x86_64 1/10
インストール中 : sshpass-1.09-4.el9.x86_64 2/10
インストール中 : python3-resolvelib-0.5.4-5.el9.noarch 3/10
インストール中 : python3-ply-3.11-14.el9.noarch 4/10
インストール中 : python3-pycparser-2.20-6.el9.noarch 5/10
インストール中 : python3-cffi-1.14.5-5.el9.x86_64 6/10
インストール中 : python3-cryptography-36.0.1-4.el9.x86_64 7/10
インストール中 : python3-pyparsing-2.4.7-9.el9.noarch 8/10
インストール中 : python3-packaging-20.9-5.el9.noarch 9/10
インストール中 : ansible-core-1:2.14.17-1.el9.x86_64 10/10
scriptletの実行中: ansible-core-1:2.14.17-1.el9.x86_64 10/10
検証中 : python3-pyparsing-2.4.7-9.el9.noarch 1/10
検証中 : python3-cffi-1.14.5-5.el9.x86_64 2/10
検証中 : python3-ply-3.11-14.el9.noarch 3/10
検証中 : python3-pycparser-2.20-6.el9.noarch 4/10
検証中 : python3-cryptography-36.0.1-4.el9.x86_64 5/10
検証中 : python3-resolvelib-0.5.4-5.el9.noarch 6/10
検証中 : sshpass-1.09-4.el9.x86_64 7/10
検証中 : python3-packaging-20.9-5.el9.noarch 8/10
検証中 : ansible-core-1:2.14.17-1.el9.x86_64 9/10
検証中 : git-core-2.43.5-2.el9_5.x86_64 10/10
インストール済みの製品が更新されています。
インストール済み:
ansible-core-1:2.14.17-1.el9.x86_64 git-core-2.43.5-2.el9_5.x86_64 python3-cffi-1.14.5-5.el9.x86_64 python3-cryptography-36.0.1-4.el9.x86_64 python3-packaging-20.9-5.el9.noarch python3-ply-3.11-14.el9.noarch
python3-pycparser-2.20-6.el9.noarch python3-pyparsing-2.4.7-9.el9.noarch python3-resolvelib-0.5.4-5.el9.noarch sshpass-1.09-4.el9.x86_64
完了しました!
Ansible Coreがインストールされたことを確認する
以下のコマンドを実行してAnsible Coreがインストールされたことを確認します。
# ansible --version
[root@localhost ~]# ansible --version
ansible [core 2.14.17]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.9.21 (main, Dec 5 2024, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-2)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
問題なくインストールされました。
Red Hat Enterprise Linux (RHEL) システムロールをインストールする
以下のコマンドを実行してRed Hat Enterprise Linux (RHEL) システムロールをインストールします。
# dnf install rhel-system-roles
コマンドを実際にRHEL9.5で実行します。
[root@localhost ~]# dnf install rhel-system-roles
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 0:21:17 前の 2025年03月29日 20時30分00秒 に実施しました。
依存関係が解決しました。
=============================================================================================================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
=============================================================================================================================================================================================================================================
インストール:
rhel-system-roles noarch 1.88.9-0.1.el9_5 rhel-9-for-x86_64-appstream-rpms 3.9 M
トランザクションの概要
=============================================================================================================================================================================================================================================
インストール 1 パッケージ
ダウンロードサイズの合計: 3.9 M
インストール後のサイズ: 19 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
rhel-system-roles-1.88.9-0.1.el9_5.noarch.rpm 2.1 MB/s | 3.9 MB 00:01
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計 2.1 MB/s | 3.9 MB 00:01
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
scriptletの実行中: rhel-system-roles-1.88.9-0.1.el9_5.noarch 1/1
準備中 : 1/1
インストール中 : rhel-system-roles-1.88.9-0.1.el9_5.noarch 1/1
検証中 : rhel-system-roles-1.88.9-0.1.el9_5.noarch 1/1
インストール済みの製品が更新されています。
インストール済み:
rhel-system-roles-1.88.9-0.1.el9_5.noarch
完了しました!
[root@localhost ~]#
ローカル環境(localhost)でAnsibleを実行する
ローカル環境でAnsibleを実行する場合は以下の記事に記載の事項を注意します。

RHEL9でAnsibleのバージョン1.4は脆弱性として検知される
ansible-core を 2.14.14 に更新 (JIRA:RHEL-23783)することで脆弱性は解消する。
https://access.redhat.com/errata/RHSA-2024:2246
参考
