LoginSignup
39
43

More than 5 years have passed since last update.

Ansible インストール

Last updated at Posted at 2016-02-16

Ansible のインストール備忘録です。
インストールのパターンがいくつかあるようなので、複数のパターンで試してみました。

環境情報

  • OS : CentOS 6.7 (minimalでインストール)

yum でのインストール

手軽に始めたい場合はこちらの方法で。

yumでのインストール
$ yum install epel-release
$ yum install ansible
$ ansible --version
ansible 1.9.4
  configured module search path = None

epel レポジトリからのインストールです。
バージョンが若干古いようです。

pip でのインストール

そこで python のパッケージ管理である pip を利用してインストールを行ってみます。
デフォルトでインストールされている python のバージョンは 2.6 の為、2.7 をインストールしてから行います。1

pipでのインストール
# python 2.7 インストールの為、開発用パッケージをインストール
$ yum groupinstall "development tools"
$ yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel wget
# python 2.7 のソースファイルをダウンロード
$ cd /usr/local/src
$ wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
$ tar zxvf Python-2.7.11.tgz
# python 2.7 のインストール
$ cd Python-2.7.11
$ ./configure --prefix=/usr/local
$ make
# インストール済みの python に影響がないようにインストールします
$ make altinstall
$ python -V
Python 2.6.6
$ python2.7 -V
Python 2.7.11

# pip のダウンロード
$ wget https://bootstrap.pypa.io/get-pip.py
# pip のインストール
$ python2.7 get-pip.py
$ pip --version
pip 8.0.2 from /usr/local/lib/python2.7/site-packages (python 2.7)

# ansible のインストール
$ pip install ansible
$ ansible --version
ansible 2.0.0.2
  config file =
  configured module search path = Default w/o overrides

ansible のバージョンは 2.0 となりました。

ソースファイルからインストール

最後に github からソースファイルをダウンロードしてインストールします。
ソースファイルを rpm のパッケージ化してからインストールします。
今回は ansible の開発版である 2.1 のインストールとなります。
※途中、git を最新化しております。

ソースファイルからのインストール
# ソースファイルからインストールの為、開発用パッケージをインストール
$ yum groupinstall "development tools"

# git のアンインストール
$ yum remove git

# git のインストール
# - git に必要なパッケージのインストール
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker gcc wget
# - git のソースをダウンロード
$ cd /usr/local/src
$ wget https://www.kernel.org/pub/software/scm/git/git-2.7.0.tar.gz
$ tar zxvf git-2.7.0.tar.gz
# - git のインストール
$ cd git-2.7.0
$ ./configure --prefix=/usr/local
$ make
$ make install
$ git --version
git version 2.7.0

# ansible のインストール
# - rpm パッケージ化に必要なパッケージのインストール
$ yum install rpm-build make python2-devel asciidoc python-setuptools
# - src のダウンロード
$ cd /usr/local/src
$ git clone git://github.com/ansible/ansible.git --recursive
# - ansible ソースから rpm パッケージ化
$ cd ansible/
$ make rpm
# - ansible に必要なパッケージのインストール
$ yum install epel-release
$ yum install python-keyczar python-httplib2 sshpass python-crypto2.6
# - ansible のインストール
$ yum localinstall ./rpm-build/ansible-*.noarch.rpm
$ ansible --version
ansible 2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

開発段階の バージョン 2.1 がインストールされました。
rpm 化しておくと、次回からは git からのソースファイルのダウンロードや configure/make の作業なしで利用可能となります。

※バージョンを指定したい場合はタグを指定してチェックアウトしてください。

# git からソースファイルのダウンロードまでは一緒
cd ansible/
# タグ(バージョンの一覧の表示)
git tag
# 対象のバージョンを指定してチェックアウト
# xxx:ブランチ名(任意)、yyy:git tag で表示されているタグ名
git checkout -b xxx refs/tags/yyy
# サブモジュールに対して更新
git submodule update
# 以降、make rpm でパッケージ化してインストール

以上となります。

用途に合わせて、インストールしましょう。


  1. 2.6 でインストールを続けるとサポートについての警告が表示されます。DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6 

39
43
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
39
43