以下のようなchef Kitchen用のyamlと
recipe、libraryを書いて実行しているのですが、
タイトルのエラーが出て解決できません。。。
※library側、yml側双方をいろいろ書き方を変えてみましたがうまくいかず。。。
どういった書き方が正しいのか
わかる方がいましたらご指摘お願いします。。。
◎recipe
# Handling test Lvm # Install Parted package package 'parted' do action :install end ::Chef::Recipe.send(:include, HandleDevice::Helper) ::Chef::Recipe.send(:include, HandleLVM::Helper) node['disks']['devices'].each do |device| create_device(device) end node['disks']['vg'].each do |vg| handling_physical_volume(vg) end
◎Library
module HandleLVM module Helper def handling_physical_volume(vg) p vg vg.each do |vg| print "hello: " p vg['name'] if ! system("vgdisplay #{vg['name']}") system("vgcreate -v #{vg['name']} #{vg['members'][0]}") end end end
◎kitchen.yml
suites: - name: default run_list: - test_lvm attributes: environment: 'development' location: 'local' disks: devices: - name: '/dev/sda' path: '/dev/sda3' label: 'msdos' disk_type: 'primary' alignment: 'minimal' - name: '/dev/sdb' path: '/dev/sdb1' label: 'msdos' disk_type: 'primary' alignment: 'minimal' vg: - name: 'vg1' members: - '/dev/sda3' - name: 'vg2' members: - '/dev/sdb1' lv: - name: 'root' group: 'vg1' fs_type: 'ext4' mount_path: '/' - name: 'data' group: 'vg2' fs_type: 'ext4' mount_path: 'data'
エラー内容
TypeError --------- no implicit conversion of String into Integer Cookbook Trace: --------------- /tmp/kitchen/cache/cookbooks/test_lvm/libraries/HandleLVM.rb:9:in `[]' /tmp/kitchen/cache/cookbooks/test_lvm/libraries/HandleLVM.rb:9:in `block in handling_physical_volume' /tmp/kitchen/cache/cookbooks/test_lvm/libraries/HandleLVM.rb:7:in `each' /tmp/kitchen/cache/cookbooks/test_lvm/libraries/HandleLVM.rb:7:in `handling_physical_volume' /tmp/kitchen/cache/cookbooks/test_lvm/recipes/default.rb:19:in `block in from_file' /tmp/kitchen/cache/cookbooks/test_lvm/recipes/default.rb:17:in `each' /tmp/kitchen/cache/cookbooks/test_lvm/recipes/default.rb:17:in `from_file' Relevant File Content: ---------------------- /tmp/kitchen/cache/cookbooks/test_lvm/libraries/HandleLVM.rb: 2: module HandleLVM 3: module Helper 4: def handling_physical_volume(vg) 5: p vg 6: 7: vg.each do |vg| 8: print "hello: " 9>> p vg['name'] 10: if ! system("vgdisplay #{vg['name']}") 11: system("vgcreate -v #{vg['name']} #{vg['members'][0]}") 12: end 13: end 14: end 15:
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。