{"action":"created","issue":{"url":"https://api.github.com/repos/chef-cookbooks/lvm/issues/102","repository_url":"https://api.github.com/repos/chef-cookbooks/lvm","labels_url":"https://api.github.com/repos/chef-cookbooks/lvm/issues/102/labels{/name}","comments_url":"https://api.github.com/repos/chef-cookbooks/lvm/issues/102/comments","events_url":"https://api.github.com/repos/chef-cookbooks/lvm/issues/102/events","html_url":"https://github.com/chef-cookbooks/lvm/issues/102","id":160195532,"number":102,"title":"undefined method `new_resource' for Chef::Resource::LvmLogicalVolume","user":{"login":"gawbul","id":321291,"avatar_url":"https://avatars.githubusercontent.com/u/321291?v=3","gravatar_id":"","url":"https://api.github.com/users/gawbul","html_url":"https://github.com/gawbul","followers_url":"https://api.github.com/users/gawbul/followers","following_url":"https://api.github.com/users/gawbul/following{/other_user}","gists_url":"https://api.github.com/users/gawbul/gists{/gist_id}","starred_url":"https://api.github.com/users/gawbul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gawbul/subscriptions","organizations_url":"https://api.github.com/users/gawbul/orgs","repos_url":"https://api.github.com/users/gawbul/repos","events_url":"https://api.github.com/users/gawbul/events{/privacy}","received_events_url":"https://api.github.com/users/gawbul/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-14T14:27:27Z","updated_at":"2016-06-16T06:39:28Z","closed_at":null,"body":"### Cookbook version\r\n2.1.2 (also versions 1.4.1+)\r\n\r\n### Chef-client version\r\n12.7.2-1 (also tested with 12.4.1-1 and 12.11.18-1)\r\n\r\n### Platform Details\r\nCentOS Linux release 7.2.1511 (Core)\r\n\r\n### Scenario:\r\nI've created a wrapper around the lvm resource in my own cookbook to create a volume group, with a single logical volume and mount it at a given mount point. However, I receive the following error:\r\n\r\n```\r\n       Recipe: my_cookbook::diskmnt\r\n         * my_cookbook_diskmnt[Setup data disk] action create\r\n\r\n           ================================================================================\r\n           Error executing action `create` on resource 'my_cookbook_diskmnt[Setup data disk]'\r\n           ================================================================================\r\n\r\n           NoMethodError\r\n           -------------\r\n           No resource or method named `new_resource' for `Chef::Resource::LvmLogicalVolume \"lv_data\"'\r\n\r\n           Cookbook Trace:\r\n           ---------------\r\n           /tmp/kitchen/cookbooks/my_cookbook/providers/diskmnt.rb:35:in `block (3 levels) in class_from_file'\r\n           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `instance_eval'\r\n           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `build'\r\n           /tmp/kitchen/cookbooks/lvm/libraries/resource_lvm_volume_group.rb:110:in `logical_volume'\r\n           /tmp/kitchen/cookbooks/my_cookbook/providers/diskmnt.rb:34:in `block (2 levels) in class_from_file'\r\n           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `instance_eval'\r\n           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb:90:in `build'\r\n           /tmp/kitchen/cookbooks/my_cookbook/providers/diskmnt.rb:29:in `block in class_from_file'\r\n           /tmp/kitchen/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'\r\n```\r\n\r\nIf I call the same code I use in the provider in the recipe (i.e. without wrapping it in a provider), it works fine? Something to do with nested resources?\r\n\r\n### Steps to Reproduce:\r\nCreate a resource and provider in a cookbook and call the lvm resource from that, e.g.\r\n\r\n**my_cookbook/resources/diskmnt.rb**\r\n```\r\nactions :create\r\ndefault_action :create\r\n\r\nattribute :vol_group,       kind_of: String,  required: true\r\nattribute :phys_vol,        kind_of: String,  required: true\r\nattribute :log_vol,         kind_of: String,  required: true\r\nattribute :vol_size,        kind_of: String,  default: '100%VG'\r\nattribute :fs_type,         kind_of: String,  default: 'ext4'\r\nattribute :mount_point,     kind_of: String,  required: true\r\n```\r\n\r\n**my_cookbook/provider/diskmnt.rb**\r\n```\r\naction :create do\r\n  # only run if we're set to\r\n  if node['my_cookbook']['diskmnt'] == true\r\n    # install relevant packages and gems\r\n    include_recipe 'lvm::default'\r\n\r\n    vol_group = new_resource.vol_group\r\n    phys_vol = new_resource.phys_vol\r\n    log_vol = new_resource.log_vol\r\n    vol_size = new_resource.vol_size\r\n    fs_type = new_resource.fs_type\r\n    mount_point = new_resource.mount_point\r\n\r\n    # create volume group\r\n    lvm_volume_group vol_group do\r\n      # create physical volume\r\n      physical_volumes [phys_vol]\r\n\r\n      # create logical volume\r\n      logical_volume log_vol do\r\n        size vol_size\r\n        filesystem fs_type\r\n        mount_point mount_point\r\n      end\r\n  end\r\nend\r\n```\r\n\r\n**my_cookbook/recipes/diskmnt.rb**\r\n```\r\nmy_cookbook_diskmnt 'Setup data disk' do\r\n  vol_group   'vg_data'\r\n  phys_vol    '/dev/sdb'\r\n  log_vol     'lv_data'\r\n  vol_size    '100%VG'\r\n  fs_type     'ext4'\r\n  mount_point '/mnt/data'\r\nend\r\n```\r\n\r\n### Expected Result:\r\nThe custom resource/provider should pass the arguments through to the lvm provider and create the volume group with the logical volume and mount it at the mount point.\r\n\r\n### Actual Result:\r\nI get the error `No resource or method named 'new_resource' for 'Chef::Resource::LvmLogicalVolume \"lv_data\"'`"},"comment":{"url":"https://api.github.com/repos/chef-cookbooks/lvm/issues/comments/226400667","html_url":"https://github.com/chef-cookbooks/lvm/issues/102#issuecomment-226400667","issue_url":"https://api.github.com/repos/chef-cookbooks/lvm/issues/102","id":226400667,"user":{"login":"gawbul","id":321291,"avatar_url":"https://avatars.githubusercontent.com/u/321291?v=3","gravatar_id":"","url":"https://api.github.com/users/gawbul","html_url":"https://github.com/gawbul","followers_url":"https://api.github.com/users/gawbul/followers","following_url":"https://api.github.com/users/gawbul/following{/other_user}","gists_url":"https://api.github.com/users/gawbul/gists{/gist_id}","starred_url":"https://api.github.com/users/gawbul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gawbul/subscriptions","organizations_url":"https://api.github.com/users/gawbul/orgs","repos_url":"https://api.github.com/users/gawbul/repos","events_url":"https://api.github.com/users/gawbul/events{/privacy}","received_events_url":"https://api.github.com/users/gawbul/received_events","type":"User","site_admin":false},"created_at":"2016-06-16T06:39:28Z","updated_at":"2016-06-16T06:39:28Z","body":"Doing the following solves the problem, but I aren't quite sure why?\r\n\r\n```\r\naction :create do\r\n  # only run if we're set to\r\n  if node['my_cookbook']['diskmnt'] == true\r\n    # install relevant packages and gems\r\n    include_recipe 'lvm::default'\r\n\r\n    this_resource = new_resource\r\n    vol_group = this_resource.vol_group\r\n    phys_vol = this_resource.phys_vol\r\n    log_vol = this_resource.log_vol\r\n    vol_size = this_resource.vol_size\r\n    fs_type = this_resource.fs_type\r\n    mount_point = this_resource.mount_point\r\n\r\n    # create volume group\r\n    lvm_volume_group vol_group do\r\n      # create physical volume\r\n      physical_volumes [phys_vol]\r\n\r\n      # create logical volume\r\n      logical_volume log_vol do\r\n        size vol_size\r\n        filesystem fs_type\r\n        mount_point mount_point\r\n      end\r\n  end\r\nend\r\n```"}}
{"actor":{"display_login":"gawbul"}}