[user@俺 ~]$ reboot

何年か新しいIT技術と向き合っていないうちに、浦島太郎になってしまった...そんなインフラ技術者の日記

MEMO : How to install Ansible on centos 7.x .

centos 7.x へAnsible をインストールするときのメモ。Ansibleはepelに公開されているyumパッケージ版ど導入。インストールには、yumコマンドを使用して実行。

環境情報

virtualbox に、ゲストOSとして、CentOSをインストール

  • VirtualBox Version:
  • CPU:1 core
  • RAM:8192MB
  • HDD:40GB

※構築したゲストは、インターネットアクセスが可能な環境で実施。

OSインストール

Centos7.x everything dvd から、core パッケージでインストールを実行。 ※インターネット上のyum repository を使いたいので、ネットワークの設定はきちんと行いましょう。

OS アップデート

インストール完了した状態で、OSアップデートを実行。 ※これは、要件ではありませんが、CentOSのメディアが、だいぶ古い(7.1)ものだったので、最新の状態(まだ、CentOSは、7.3にはなっていないという...)を、使って確認しました。

# yum update -y

※作業時点(2016/11/23)では、アップデート完了後、"CentOS Linux release 7.2.1511 (Core)"となった。

epelリポジトリ追加

epelリポジトリを追加する。CentOSの標準リポジトリには、Ansibleパッケージは用意されていないため、yum でepelリポジトリを利用できるようにする。

# yum install epel-release.noarch -y

Ansible インストール

yumコマンドにて、Ansible パッケージをインストールする。

# yum install ansible

インストールログ

[root@ansible ~]# yum install ansible
Loaded plugins: fastestmirror
epel/x86_64/metalink                                                                             | 4.8 kB  00:00:00
epel                                                                                             | 4.3 kB  00:00:00
(1/3): epel/x86_64/group_gz                                                                      | 170 kB  00:00:00
(2/3): epel/x86_64/updateinfo                                                                    | 678 kB  00:00:00
(3/3): epel/x86_64/primary_db                                                                    | 4.3 MB  00:00:00
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * epel: ftp.riken.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.2.0.0-3.el7 will be installed
--> Processing Dependency: sshpass for package: ansible-2.2.0.0-3.el7.noarch
--> Processing Dependency: python-six for package: ansible-2.2.0.0-3.el7.noarch
--> Processing Dependency: python-paramiko for package: ansible-2.2.0.0-3.el7.noarch
--> Processing Dependency: python-keyczar for package: ansible-2.2.0.0-3.el7.noarch
--> Processing Dependency: python-jinja2 for package: ansible-2.2.0.0-3.el7.noarch
--> Processing Dependency: python-httplib2 for package: ansible-2.2.0.0-3.el7.noarch
--> Processing Dependency: PyYAML for package: ansible-2.2.0.0-3.el7.noarch
--> Running transaction check
---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.el7.x86_64
---> Package python-httplib2.noarch 0:0.7.7-3.el7 will be installed
---> Package python-jinja2.noarch 0:2.7.2-2.el7 will be installed
--> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-2.el7.noarch
--> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-2.el7.noarch
---> Package python-keyczar.noarch 0:0.71c-2.el7 will be installed
--> Processing Dependency: python-pyasn1 for package: python-keyczar-0.71c-2.el7.noarch
--> Processing Dependency: python-crypto for package: python-keyczar-0.71c-2.el7.noarch
---> Package python-six.noarch 0:1.9.0-2.el7 will be installed
---> Package python2-paramiko.noarch 0:1.16.1-1.el7 will be installed
--> Processing Dependency: python2-ecdsa for package: python2-paramiko-1.16.1-1.el7.noarch
---> Package sshpass.x86_64 0:1.05-5.el7 will be installed
--> Running transaction check
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed
---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed
---> Package python-pyasn1.noarch 0:0.1.6-2.el7 will be installed
---> Package python2-crypto.x86_64 0:2.6.1-9.el7 will be installed
--> Processing Dependency: libtomcrypt.so.0()(64bit) for package: python2-crypto-2.6.1-9.el7.x86_64
---> Package python2-ecdsa.noarch 0:0.13-4.el7 will be installed
--> Running transaction check
---> Package libtomcrypt.x86_64 0:1.17-23.el7 will be installed
--> Processing Dependency: libtommath >= 0.42.0 for package: libtomcrypt-1.17-23.el7.x86_64
--> Processing Dependency: libtommath.so.0()(64bit) for package: libtomcrypt-1.17-23.el7.x86_64
--> Running transaction check
---> Package libtommath.x86_64 0:0.42.0-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                            Arch                    Version                         Repository             Size
========================================================================================================================
Installing:
 ansible                            noarch                  2.2.0.0-3.el7                   epel                  4.6 M
Installing for dependencies:
 PyYAML                             x86_64                  3.10-11.el7                     base                  153 k
 libtomcrypt                        x86_64                  1.17-23.el7                     epel                  224 k
 libtommath                         x86_64                  0.42.0-4.el7                    epel                   35 k
 libyaml                            x86_64                  0.1.4-11.el7_0                  base                   55 k
 python-babel                       noarch                  0.9.6-8.el7                     base                  1.4 M
 python-httplib2                    noarch                  0.7.7-3.el7                     epel                   70 k
 python-jinja2                      noarch                  2.7.2-2.el7                     base                  515 k
 python-keyczar                     noarch                  0.71c-2.el7                     epel                  218 k
 python-markupsafe                  x86_64                  0.11-10.el7                     base                   25 k
 python-pyasn1                      noarch                  0.1.6-2.el7                     base                   91 k
 python-six                         noarch                  1.9.0-2.el7                     base                   29 k
 python2-crypto                     x86_64                  2.6.1-9.el7                     epel                  475 k
 python2-ecdsa                      noarch                  0.13-4.el7                      epel                   83 k
 python2-paramiko                   noarch                  1.16.1-1.el7                    epel                  257 k
 sshpass                            x86_64                  1.05-5.el7                      epel                   21 k

Transaction Summary
========================================================================================================================
Install  1 Package (+15 Dependent packages)

Total download size: 8.1 M
Installed size: 36 M
Is this ok [y/d/N]: y
Downloading packages:
(1/16): PyYAML-3.10-11.el7.x86_64.rpm                                                            | 153 kB  00:00:00
warning: /var/cache/yum/x86_64/7/epel/packages/ansible-2.2.0.0-3.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for ansible-2.2.0.0-3.el7.noarch.rpm is not installed
(2/16): ansible-2.2.0.0-3.el7.noarch.rpm                                                         | 4.6 MB  00:00:03
(3/16): libtomcrypt-1.17-23.el7.x86_64.rpm                                                       | 224 kB  00:00:00
(4/16): libtommath-0.42.0-4.el7.x86_64.rpm                                                       |  35 kB  00:00:00
(5/16): python-httplib2-0.7.7-3.el7.noarch.rpm                                                   |  70 kB  00:00:00
(6/16): python-keyczar-0.71c-2.el7.noarch.rpm                                                    | 218 kB  00:00:00
(7/16): libyaml-0.1.4-11.el7_0.x86_64.rpm                                                        |  55 kB  00:00:00
(8/16): python-markupsafe-0.11-10.el7.x86_64.rpm                                                 |  25 kB  00:00:00
(9/16): python-pyasn1-0.1.6-2.el7.noarch.rpm                                                     |  91 kB  00:00:00
(10/16): python-jinja2-2.7.2-2.el7.noarch.rpm                                                    | 515 kB  00:00:00
(11/16): python-babel-0.9.6-8.el7.noarch.rpm                                                     | 1.4 MB  00:00:00
(12/16): python-six-1.9.0-2.el7.noarch.rpm                                                       |  29 kB  00:00:00
(13/16): python2-crypto-2.6.1-9.el7.x86_64.rpm                                                   | 475 kB  00:00:02
(14/16): python2-ecdsa-0.13-4.el7.noarch.rpm                                                     |  83 kB  00:00:00
(15/16): python2-paramiko-1.16.1-1.el7.noarch.rpm                                                | 257 kB  00:00:00
(16/16): sshpass-1.05-5.el7.x86_64.rpm                                                           |  21 kB  00:00:00
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   1.1 MB/s | 8.1 MB  00:00:07
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-6.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-six-1.9.0-2.el7.noarch                                                                       1/16
  Installing : python2-ecdsa-0.13-4.el7.noarch                                                                     2/16
  Installing : sshpass-1.05-5.el7.x86_64                                                                           3/16
  Installing : libtommath-0.42.0-4.el7.x86_64                                                                      4/16
  Installing : libtomcrypt-1.17-23.el7.x86_64                                                                      5/16
  Installing : python2-crypto-2.6.1-9.el7.x86_64                                                                   6/16
  Installing : python2-paramiko-1.16.1-1.el7.noarch                                                                7/16
  Installing : python-babel-0.9.6-8.el7.noarch                                                                     8/16
  Installing : python-pyasn1-0.1.6-2.el7.noarch                                                                    9/16
  Installing : python-keyczar-0.71c-2.el7.noarch                                                                  10/16
  Installing : python-httplib2-0.7.7-3.el7.noarch                                                                 11/16
  Installing : python-markupsafe-0.11-10.el7.x86_64                                                               12/16
  Installing : python-jinja2-2.7.2-2.el7.noarch                                                                   13/16
  Installing : libyaml-0.1.4-11.el7_0.x86_64                                                                      14/16
  Installing : PyYAML-3.10-11.el7.x86_64                                                                          15/16
  Installing : ansible-2.2.0.0-3.el7.noarch                                                                       16/16
  Verifying  : python-keyczar-0.71c-2.el7.noarch                                                                   1/16
  Verifying  : libyaml-0.1.4-11.el7_0.x86_64                                                                       2/16
  Verifying  : python-jinja2-2.7.2-2.el7.noarch                                                                    3/16
  Verifying  : python-markupsafe-0.11-10.el7.x86_64                                                                4/16
  Verifying  : python-httplib2-0.7.7-3.el7.noarch                                                                  5/16
  Verifying  : python2-ecdsa-0.13-4.el7.noarch                                                                     6/16
  Verifying  : libtomcrypt-1.17-23.el7.x86_64                                                                      7/16
  Verifying  : ansible-2.2.0.0-3.el7.noarch                                                                        8/16
  Verifying  : python2-crypto-2.6.1-9.el7.x86_64                                                                   9/16
  Verifying  : python-pyasn1-0.1.6-2.el7.noarch                                                                   10/16
  Verifying  : PyYAML-3.10-11.el7.x86_64                                                                          11/16
  Verifying  : python-babel-0.9.6-8.el7.noarch                                                                    12/16
  Verifying  : python-six-1.9.0-2.el7.noarch                                                                      13/16
  Verifying  : libtommath-0.42.0-4.el7.x86_64                                                                     14/16
  Verifying  : python2-paramiko-1.16.1-1.el7.noarch                                                               15/16
  Verifying  : sshpass-1.05-5.el7.x86_64                                                                          16/16

Installed:
  ansible.noarch 0:2.2.0.0-3.el7

Dependency Installed:
  PyYAML.x86_64 0:3.10-11.el7          libtomcrypt.x86_64 0:1.17-23.el7         libtommath.x86_64 0:0.42.0-4.el7
  libyaml.x86_64 0:0.1.4-11.el7_0      python-babel.noarch 0:0.9.6-8.el7        python-httplib2.noarch 0:0.7.7-3.el7
  python-jinja2.noarch 0:2.7.2-2.el7   python-keyczar.noarch 0:0.71c-2.el7      python-markupsafe.x86_64 0:0.11-10.el7
  python-pyasn1.noarch 0:0.1.6-2.el7   python-six.noarch 0:1.9.0-2.el7          python2-crypto.x86_64 0:2.6.1-9.el7
  python2-ecdsa.noarch 0:0.13-4.el7    python2-paramiko.noarch 0:1.16.1-1.el7   sshpass.x86_64 0:1.05-5.el7

Complete!
[root@ansible ~]# 

Ansible 導入の確認

導入が完了した時点で、Ansible のバージョンを確認。

[root@ansible ~]# ansible --version
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
[root@ansible ~]#