Ansible : インストール2025/10/14 |
|
構成管理ツール Ansible のインストールと利用方法です。 専用の サーバー/クライアント プログラム は必要なく、Ansible コマンドと SSH のみで利用できるのが特徴です。 |
|
| [1] | |
| [2] | Ansible をインストールします。 |
|
root@dlp:~#
root@dlp:~# apt -y install ansible-core ansible --version ansible [core 2.19.0b6] config file = None configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3/dist-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections executable location = /usr/bin/ansible python version = 3.13.5 (main, Jun 25 2025, 18:55:22) [GCC 14.2.0] (/usr/bin/python3) jinja version = 3.1.6 pyyaml version = 6.0.2 (with libyaml v0.2.5) |
| [3] | Ansible の基本設定として、管理対象クライアントを定義します。 |
|
root@dlp:~# mkdir /etc/ansible
root@dlp:~#
vi /etc/ansible/ansible.cfg # 新規作成 [defaults] # 必要に応じて設定 (ホストキーチェックをするか否か) host_key_checking=False # デフォルトの python のパスを設定 interpreter_python=/usr/bin/python3
root@dlp:~#
vi /etc/ansible/hosts # 新規作成 # 管理対象としたいホストを記述 10.0.0.50 # グループ化する場合は以下のように記述 # 任意のグループ名を定義 [target_servers] # グループ化したいホスト名を一行ずつ記述 10.0.0.51 # 設定確認 # 定義済みホストを全て表示 root@dlp:~# ansible all --list-hosts
hosts (3):
10.0.0.50
10.0.0.51
10.0.0.52
# 特定のグループの定義済みホストを表示 root@dlp:~# ansible target_servers --list-hosts
hosts (2):
10.0.0.51
10.0.0.52
|
| Sponsored Link |
|
|