LoginSignup
11
11

More than 5 years have passed since last update.

MacにVagrant、Cent OS、apacheをインストール(Chefでインストール編)

Posted at

chefを使ってapacheをインストールします。

chefクックブックについて

MacにVagrant、Cent OS、apacheをインストール(Chefクックブック作成編)のクックブックを使います。
上記クックブックはgithubに公開しています。
https://github.com/pakiln/chef-repo

VagrantとCentOS

本投稿はMacにVagrant、Cent OS、apacheをインストールvagrant upを実行できた状態からの手順です。
CentOSのipアドレスは192.168.33.10としています。

chef(knife)の実行

Macのターミナルからknife solo prepareを実行します。
これはCentOSのchef環境を整えてくれる便利なコマンドです。
一度だけ実行してください。
なお、実行時のディレクトリはクックブックのディレクトリです。

$ ls
Cheffile  Cheffile.lock  cookbooks/  data_bags/  nodes/  roles/  site-cookbooks/

$ knife solo prepare 192.168.33.10 --ssh-user vagrant --identity-file ~/.vagrant.d/insecure_private_key
Bootstrapping Chef...
Enter the password for vagrant@192.168.33.10: 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
101  6790  101  6790    0     0    992      0  0:00:06  0:00:06 --:--:-- 11040
Downloading Chef 11.6.0 for el...
Installing Chef 11.6.0
warning: /tmp/tmp.aSjAYKHN/chef-11.6.0.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
Preparing...                ########################################### [100%]
   1:chef                   ########################################### [100%]
Thank you for installing Chef!

続けてMacのターミナルからknife solo cookを実行します。
192.168.33.10のCentOSに対して、nodes/192.168.33.10.jsonに従いchefを実行させます。
「nodes/192.168.33.10.json」の部分を省略することも可能です。

$ knife solo cook 192.168.33.10 nodes/192.168.33.10.json --ssh-user vagrant --identity-file ~/.vagrant.d/insecure_private_key
Running Chef on 192.168.33.10...
Checking Chef version...
Installing Librarian cookbooks...
Uploading the kitchen...
Generating solo config...
Running Chef...
Starting Chef Client, version 11.6.0
Compiling Cookbooks...
[2013-09-22T03:49:31+00:00] FATAL: No cookbook found in ["/home/vagrant/chef-solo/cookbooks-1", "/home/vagrant/chef-solo/cookbooks-2", "/home/vagrant/chef-solo/cookbooks-3"], make sure cookbook_path is set correctly.
Converging 3 resources
Recipe: iptables_stop::default
  * service[iptables] action disable
    - disable service service[iptables]

  * service[iptables] action stop
    - stop service service[iptables]

Recipe: httpd::default
  * package[httpd] action install
    - install version 2.2.15-29.el6.centos of package httpd

  * service[httpd] action enable
    - enable service service[httpd]

  * service[httpd] action start
    - start service service[httpd]

Chef Client finished, 5 resources updated

Macのブラウザから192.168.33.10にアクセスすると、Apacheのテストページが表示されます。

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