creates で指定しているのになんでこんなエラーが出てくるのだろう。。
==> default: Notice: /Stage[main]/Main/Exec[clone rbenv]/returns: fatal: destination path 'rbenv' already exists and is not an empty directory.
==> default: Error: git clone https://github.com/sstephenson/rbenv.git returned 128 instead of one of [0]
==> default: Error: /Stage[main]/Main/Exec[clone rbenv]/returns: change from notrun to 0 failed: git clone https://github.com/sstephenson/rbenv.git returned 128 instead of one of [0]
cwd => "/home/vagrant",
path => ['/usr/bin'],
command => "git clone https://github.com/sstephenson/rbenv.git",
creates => "/home/vagrant/.rbenv",
- 上の様な manifest を作成したが、この記述だと $HOME に rbenv というディレクトリができてしまっていた。
- デフォルトでは git clone してくる際に、$HOME以下にrbenvというディレクトリを作成してしまう。
- そのため commnad に Path を指定してあげなくてはならない。
command => "git clone https://github.com/sstephenson/rbenv.git .rbenv",
cwd
とpathの区別がつけることができた
実行したいリソースタイプ内で他のリソースが必要な場合は require で依存関係を作らないと実行できないと思ってました。例えば、git clone するには、Package の git について依存関係を作らないと、実行できないと思ってました。
==> default: Notice: /Stage[main]/Main/File[/home/vagrant/.bash_profile]: Dependency Exec[clone rbenv] has failures: true
==> default: Warning: /Stage[main]/Main/File[/home/vagrant/.bash_profile]: Skipping because of failed dependencies
==> default: Notice: Finished catalog run in 0.36 seconds
- require は依存関係を作るだけatributes。(dependency relationship)。どこかのリソースが実行できなかった場合、そのリソースに依存しているものは全て実行できなくなる。依存関係だらけになりすぎるのも良くないので、できるだけ使わないようにするのが望ましい。
==> default: Warning: The package type's allow_virtual parameter will be changing its default value from false to true in a future release. If you do not want to allow virtual packages, please explicitly set allow_virtual to false.
==> default: (at /usr/lib/ruby/site_ruby/1.8/puppet/type/package.rb:430:in `default')
Package { allow_virtual => true } をmanifest の文頭に付け加えることでWorningが消えました。 ちょっと難しいので保留。
- テンプレートの作成まで、provision で行なうのかなと思っていました。
- テンプレートは先に作っておき、gitで管理している場所に置いて適宜参照すること
- sourse でリポジトリからポコポコ持ってこれる。
file { '/home/vagrant/.bash_profile':
source => '/vagrant/template_bash_profile',
}
notify を指定したものを再読み込みさせる atributes だと思っていたので、以下のように記述すればいいのかなと勘違いしました。
file { '/home/vagrant/.bash_profile':
source => '/vagrant/template_bash_profile',
notify => File['/home/vagrant/.bash_profile']
}
でも、notice はそんな機能ではなかった。 notice は、例えば file から service に対して依存関係を作ったときに、fileの内容を変更したときなんかに通知がいくようにしてくれる atributes 。(変更に対してリスタートしてね〜とか)(iptablesの設定のときとかに必要かな?)
==> default: Error: Could not apply complete catalog: Found 1 dependency cycle:
==> default: (File[/home/vagrant/.bash_profile] => File[/home/vagrant/.bash_profile])
==> default: Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
notice はいらなかったのであった。
exec リソースタイプでsourse
を使って .bash_profile を読みこもうとするとエラーがでる。
==> default: Error: Validation of Exec[.bash_profile load] failed: 'source /home/vagrant/.bash_profile' is not qualified and no path was specified. Please qualify the command or specify a path. at /tmp/vagrant-puppet-3/manifests/init.pp:43
==> default: Wrapped exception:
==> default: 'source /home/vagrant/.bash_profile' is not qualified and no path was specified. Please qualify the command or specify a path.
manifestはこれ
exec { '.bash_profile load':
command => 'source /home/vagrant/.bash_profile',
subscribe => File['/home/vagrant/.bash_profile'],
refreshonly => true,
}
- exec と puppet apply は独立しているので、もしも exec で読み込ませたとしても、puppet apply には関与しないのであった。
- そのため解決策としては、フルパスで実行するか、.bash_profile の変更点が必要な場合のみ、逐一読み込ませるかをすること
- 今回はrbenv で ruby をインストールする場合のみに必要になるので、逐一読み込ませるmanifestを書いていくことにしました。
clone しようと思ったら、~/.rbenv/pluginsなんてディレクトリはないよっていわれた
==> default: Error: Working directory '/home/vagrant/.rbenv/plugins' does not exist
==> default: Error: /Stage[main]/Main/Exec[clone ruby-build]/returns: change from notrun to 0 failed: Working directory '/home/vagrant/.rbenv/plugins' does not exist
==> default: Notice: Finished catalog run in 0.20 seconds
ssh でみてみたら、確かにない。。もしかしてこのディレクトリを作る必要あるのかな。。 いや、そんなことしなくても、cwd と command の中の path の指定をしてあげることで実行された
==> default: Notice: /Stage[main]/Main/Exec[clone ruby-build]/returns: executed successfully
==> default: Notice: Finished catalog run in 8.20 seconds
source が見つからないよ!エラー
==> default: Error: Could not find command '/bin/bash/source'
==> default: Error: /Stage[main]/Main/Exec[ruby install]/returns: change from notrun to 0 failed: Could not find command '/bin/bash/source'
- コマンドには組み込みコマンドがある(ビルトインコマンド)。これらは
/usr/bin/
や/bin/
のような環境変数pathは関係なく、bash や zsh のようなシェルを指定してあげることで実行できる - 組み込みコマンドかどうかの判別は、man をして左上に
BUILTIN(1)
とでること - 普段使っているビルトインコマンドではないコマンドは、shell から子プロセスをはやして扱っている。
- 具体的な解決策は
bash -c'hoge'
で良いっぽい!来週書いてみます!
- チェックサム:データを送受信する際の誤り検出方法の一つ
http://e-words.jp/w/E38381E382A7E38383E382AFE382B5E383A0.html
- directoryは必ず ensure => directory を明示する
- recurse は再帰的な処理
- with sum 加える