LoginSignup
24
24

More than 5 years have passed since last update.

ansible2.0を使った環境構築−準備編

Posted at

動機

いつの間にか、ansibleの2.0が正式リリースされていた。
現在使っている仮想環境は、知り合いからもらった設定ファイルを使って構築したものなので、再勉強がてら開発環境の再構築をしていこうと思い立つ。

参考にしたサイトはこちら: http://dev.classmethod.jp/server-side/ansible/using_ansible_2-0_and_1-0_via_pyenv-virtualenv/

現状確認

まず現在の環境を確認

$ ansible --version
ansible 1.9.1
  configured module search path = None
$ python --version
Python 2.7.5

ansibleはbrewを使ってインストールしたものだったので、これをアンインストール

$ brew uninstall ansible --force
Uninstalling ansible... (1527 files, 18M)
$ 

pythonの準備

pythonのバージョンは2.6、2.7系が必要とのこと。
現状のままでも要件をみたいしているが、せっかくなので参考サイトにならってpyenv-vitualenvを導入してみる。

$ brew install pyenv-virtualenv

installはbrewコマンドで問題なく完了したものの

$ pyenv install 2.7.10
python-build: definition not found: 2.7.10

See all available versions with `pyenv install --list'.

If the version you need is missing, try upgrading pyenv:

  brew update && brew upgrade pyenv

となり、python2.7.10のインストールに失敗。
エラーメッセージによるとbrewのバージョンに問題があるようなので、素直にbrewを更新後再実行すると、今度は成功。
globalのバージョンを2.7.10に指定する。

$ pyenv virtualenv 2.7.10 ansible2
$ pyenv global ansible2
$ python --version
Python 2.7.5

…うまくいかない。
少しの調査後、pyenvの設定が正しくなかったと判明
http://qiita.com/Kodaira_/items/feadfef9add468e3a85b
こちらを参考にbash_profileを更新したところ

$ python --version
Python 2.7.10

無事pythonの準備完了

ansible2.0のインストール

ansibleの最新版のインストールはpipを使って行う

$ pip install ansible

これだけ。
ちなみに、準備開始前に環境確認した際にはpipコマンドは動かなく別途用意する必要があると思っていたが、この段階では問題なく動作した。
どうやらpyenvを使ってpythonをインストールする際に一緒に導入されるようだ。

$ ansible --version
ansible 2.0.0.2
  config file = 
  configured module search path = Default w/o overrides

これでansible2.0のインストールも完了。
環境構築編へ続く。

24
24
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
24
24