ローカル検証環境の構築(Vagrant + knife-solo)
はじめに
Windows7で Vagrant と knife-solo を利用できる環境は整いました。
今日は Vagrant でCentOSを用意して knife-solo で yum update をやってみようと
思います。
Chef実践入門 ~コードによるインフラ構成の自動化 (WEB+DB PRESS plus)
- 作者: 吉羽龍太郎,安藤祐介,伊藤直也,菅井祐太朗,並河祐貴
- 出版社/メーカー: 技術評論社
- 発売日: 2014/05/22
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (5件) を見る
環境
Windows7
Virtualbox 4.3.12 インストール済み
Vagrant_1.3.5 インストール済み
knife-solo 0.4.2 インストール済み
Vagrant
作成
c:\>mkdir hoge c:\>cd hoge c:\hoge>vagrant init opscode_centos-6.5-i386 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.
VagrantfileのIPアドレス(192.168.33.11)を設定してから起動
c:\hoge>vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'opscode_centos-6.5-i386'... ==> default: Matching MAC address for NAT networking... ==> default: Setting the name of the VM: hoge_default_1403242243958_6477 ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 22 => 2222 (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Connection timeout. Retrying... default: Warning: Remote connection disconnect. Retrying... ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM... ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /vagrant => C:/hoge
knife-solo
リポジトリを準備
c:\hoge>knife solo init . WARNING: No knife configuration file found Creating kitchen... Creating knife.rb in kitchen... Creating cupboards...
192.168.33.11にChef Solo インストール
c:\hoge>knife solo bootstrap root@192.168.33.11
クックブック作成
c:\hoge>knife cookbook create prepare -o site-cookbooks ** Creating cookbook prepare ** Creating README for cookbook: prepare ** Creating CHANGELOG for cookbook: prepare ** Creating metadata for cookbook: prepare
レシピ作成
default.rbを下記に
yum_package "yum-fastestmirror" do action :install end execute "yum-update" do user "root" command "yum -y update" action :run end
Nodeオブジェクトの設定(nodesフォルダの192.168.33.11.json)
{ "run_list": [ "prepare" ], "automatic": { "ipaddress": "192.168.33.11" } }
実行
c:\hoge>knife solo cook root@192.168.33.11
まとめ
できるようになったのですが、実行時に何回もユーザーのパスワードを
入力しなけければいけないのは、どうにかできるかと思うので来週やってみる。