cygwin+vagrant(virtualbox)+ansibleの動作確認メモ
virtual boxとvagrantのインストール
まず、virtual boxとvagrantのバイナリを公式サイトからDLしてインストールする。 特にハマリポイントはなし。
cygwinからvagrantを操作
vagrantの実行パスが環境変数に追加されており、cygwinのために 何も設定をすることなく普通にcygwinターミナルからvagrantコマンド実行可能。
ansibleのインストール
以下を参考に。
- http://qiita.com/kutsushitaneko/items/ad3ac7c712de4cb81963
- http://chiranoura.nobody.jp/articles/2014-03-04_01_how_to_install_pip_and_setuptools/
まず、以下をcygwinのsetup.exeを使ってインストール。
- python
- python-paramiko
- python-crypto
- python-setuptools
- gcc-core
- gcc-g++
- make
- wget
- openssh
- libyaml-devel
次に、setuptoolsのeasy_installコマンドを使ってpipをインストール。 単純に、easy_install pipとすると以下の様な感じでなぜかエラーになるので注意。
$ easy_install-2.7 pip Couldn't find a setup script in /c/Users/kj".
以下の様にして直接tar ballをインターネットからDLする。
$ easy_install https://pypi.python.org/packages/source/p/pip/pip-1.4.1.tar.gz
そして、pipを使ってansibleをインストール
$ pip ansible
ansibleの動作確認
下記を参考に。
- http://blog.s-uni.net/2013/08/27/ansible-running-on-cygwin/
- http://momijiame.tumblr.com/post/78187543848/vagrant-%E3%81%A8-ansible-%E3%82%92%E7%B5%84%E3%81%BF%E5%90%88%E3%82%8F%E3%81%9B%E3%81%A6%E4%BD%BF%E3%81%86
vagrantでhost01という名前のVMを起動しているとき、以下のようにすることでansibleでhost01へアクセス、操作ができる。
$ vagrant ssh-config >> ~/.ssh/config $ sed -i 's/Host default/Host host01/' ~/.ssh/config
- ansibleでアクセスするhostの一覧を列挙。ここではhost01のみ列挙。
$ cat << EOS > hosts host01 EOS
$ cat << EOS > ansible.cfg [defaults] hostfile = hosts [ssh_connection] ssh_args = -o ControlMaster=no EOS
動作確認。
$ ansible host01 -m ping host01 | SUCCESS => { "changed": false, "ping": "pong" } $ ansible host01 -a 'uname -a' host01 | SUCCESS | rc=0 >> Linux ubuntu 4.2.0-30-generic #36-Ubuntu SMP Fri Feb 26 00:58:07 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
以上。