Skip to content

Instantly share code, notes, and snippets.

@yutokyokutyo
Created December 17, 2014 10:17
Show Gist options
  • Save yutokyokutyo/488d16b2d4f067f10f8e to your computer and use it in GitHub Desktop.
Save yutokyokutyo/488d16b2d4f067f10f8e to your computer and use it in GitHub Desktop.

Ops研修(12月17日)

Chapter 7: Puppet を導入する

vagrant destroy => up をして何もない状態から provisioning をすると Worning がでる

==> default: Error: Working directory '/home/vagrant/Sample_app_on_VM' does not exist
==> default: Error: /Stage[main]/Main/Exec[install gem]/returns: change from notrun to 0 failed: Working directory '/home/vagrant/Sample_app_on_VM' does not exist
  • puppetは上から順番に実行していく訳ではなく、依存関係をつくってあげることで順番が決まる。その順番(依存関係)を上手く設定してあげるためにrequireが必要なのであった。(有向グラフ)
  • 「require」パラメータは、そのリソースを作成するのに必要なリソースを指定するもの

http://knowledge.sakura.ad.jp/tech/755/

テストは通っていたが、gem がインストールされていない。bundle install されていないっぽい。

(テストはGemfileに、入れたいgemの文字列があるかどうかのテストとなっています)

[vagrant@localhost Sample_app_on_VM]$ bundle exec rails s
bundler: command not found: rails
Install missing gem executables with `bundle install`
# 必要な Gem を bundle install する
exec { 'install gem':
	user        => "vagrant",
	cwd         => "/home/vagrant/Sample_app_on_VM",
	environment => ['HOME=/home/vagrant'],
	command     => "bash -c 'source /home/vagrant/.bash_profile ; bundle install --without production --path vendor/bundle'",
	creates     => "/home/vagrant/Sample_app_on_VM/vendor/bundle",
}
  • bundle install をする際に インストールする場所について、pathを指定していなかったことが原因
  • puppet のatributes であるpath とは全然意味が違うので注意!

よく表示されるエラー

==> default: Error: Could not parse for environment production: Syntax error at 'require'; expected '}' at /tmp/vagrant-puppet-3/manifests/init.pp:109 on node localhost
==> default: Error: Could not parse for environment production: Syntax error at 'require'; expected '}' at /tmp/vagrant-puppet-3/manifests/init.pp:109 on node localhost

大体末尾に,がついていないことが原因

この Worning は何だろう?

vagrant up 時のyum install 時に必ず表示されるこの Warning はなんなんだろう?

==> default: Warning: RPMDB altered outside of yum.

RPMDBというDBがあって、そこにはrpmの依存関係や、yumの依存関係の情報がキャッシュされている。 そこで、rpmとyumの依存関係の整合性がとれなくなってしまい、Warning がでている。

shell script の先頭にyum history syncを追加することで rpm/yum DB の再同期が行なわれるので解決できそう。

http://kometchtech.blog.fc2.com/blog-entry-1506.html

むむ!!まだWarningがでる!! yum clean all をしてみてもまだでる! vagrant で環境構築をする分には直接被害を被らないないので、この warning は今回は保留にすることに。

PR

一応一通りPRが完成したのでWIPを外しました。 どうかお手すきの際にレビューをよろしくお願いします!

yutokyokutyo/sampleapp_vm#4

備考

  • 今はrequire で依存関係をつくるときにgitしか指定していないけど、rubyをインストールするときやbundle install するときに、他のパッケージも必要だったと思う。そのへんのパッケージは指定しなくていいのかな。
  • .bash_profile はuserとか指定する必要あるのかな。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment