Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No resource or method named not_if' for Chef::Recipe "setup_package_manager"' #2

Closed
Joseph-R opened this issue Apr 12, 2015 · 4 comments

Comments

@Joseph-R
Copy link
Collaborator

Hey there!

I ran into error No resource or method namednot_if' for Chef::Recipe "setup_package_manager when attempting to use this cookbook with the ChefDK (0.4.0) and Chef (12.2.1).

================================================================================
10.0.1.78 Recipe Compile Error in /var/chef/cache/cookbooks/hdp/recipes/ambari_server.rb
10.0.1.78 ================================================================================
10.0.1.78
10.0.1.78 NoMethodError
10.0.1.78 -------------
10.0.1.78 No resource or method named `not_if' for `Chef::Recipe "setup_package_manager"'
10.0.1.78
10.0.1.78 Cookbook Trace:
10.0.1.78 ---------------
10.0.1.78   /var/chef/cache/cookbooks/ambari/recipes/setup_package_manager.rb:45:in `from_file'
10.0.1.78   /var/chef/cache/cookbooks/ambari/recipes/server.rb:20:in `from_file'
10.0.1.78   /var/chef/cache/cookbooks/hdp/recipes/ambari_server.rb:1:in `from_file'
10.0.1.78
10.0.1.78 Relevant File Content:
10.0.1.78 ----------------------
10.0.1.78 /var/chef/cache/cookbooks/ambari/recipes/setup_package_manager.rb:
10.0.1.78
10.0.1.78  38:      yum_repo = node['ambari']['rhel_5_repo']
10.0.1.78  39:    when 6
10.0.1.78  40:      yum_repo = node['ambari']['rhel_6_repo']
10.0.1.78  41:    end
10.0.1.78  42:    remote_file "/etc/yum.repos.d/ambari.repo" do
10.0.1.78  43:      source yum_repo
10.0.1.78  44:    end
10.0.1.78  45>>   not_if do
10.0.1.78  46:      ::File.exists?("/etc/yum.repos.d/ambari.repo")
10.0.1.78  47:    end
10.0.1.78  48:  when "suse"
10.0.1.78  49:    remote_file "/etc/zypp/repos.d/ambari.repo" do
10.0.1.78  50:      source node['ambari']['suse_11_repo']
10.0.1.78  51:    end
10.0.1.78  52:    not_if do
10.0.1.78  53:      ::File.exists?("/etc/zypp/repos.d/ambari.repo")
10.0.1.78  54:    end

Versions:

chef (12.2.1, 12.0.3)
chef-dk (0.4.0)
chef-provisioning (1.0.1, 0.18)
chef-provisioning-aws (1.0.4, 0.2.1)
chef-provisioning-azure (0.1)
chef-provisioning-fog (0.12)
chef-provisioning-vagrant (0.8.1)
chef-vault (2.4.0)
chef-zero (4.2.1, 3.2.1, 1.5.6)
cheffish (1.1.2, 0.9.2)
chefspec (4.2.0)
@Joseph-R
Copy link
Collaborator Author

I think the issue is with the code itself.

I confirmed the ambari repo was not installed:

[root@ip-10-0-1-78 yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo  elrepo.repo  epel.repo  epel-testing.repo

I think you need to bring the guards within the remote_file resource block, like so:

case node['platform']
when "redhat","centos","amazon","scientific"
  case node['platform_version'].to_i
  when 5
    yum_repo = node['ambari']['rhel_5_repo']
  when 6
    yum_repo = node['ambari']['rhel_6_repo']
  end
  remote_file "/etc/yum.repos.d/ambari.repo" do
    source yum_repo
    not_if { File.exists?("/etc/yum.repos.d/ambari.repo") }
  end
when "suse"
  remote_file "/etc/zypp/repos.d/ambari.repo" do
    source node['ambari']['suse_11_repo']
    not_if { File.exists?("/etc/zypp/repos.d/ambari.repo") }
  end

That worked for me. Let me know if you want me to write that up and submit a pull request.

@jp
Copy link
Owner

jp commented Apr 12, 2015

Hey Joe, thanks for your feedback. I would be happy if you can submit a PR
for this. There is not tests yet for this cookbook, so just write up your
changes ;)
On Apr 12, 2015 3:29 PM, "JoeReid-Korrelate" notifications@github.com
wrote:

I think the issue is with the code itself.

I confirmed the ambari repo was not installed:

[root@ip-10-0-1-78 yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo elrepo.repo epel.repo epel-testing.repo

I think you need to bring the guards within the remote_file resource
block, like so:

case node['platform']
when "redhat","centos","amazon","scientific"
case node['platform_version'].to_i
when 5
yum_repo = node['ambari']['rhel_5_repo']
when 6
yum_repo = node['ambari']['rhel_6_repo']
end
remote_file "/etc/yum.repos.d/ambari.repo" do
source yum_repo
not_if { File.exists?("/etc/yum.repos.d/ambari.repo") }
end
when "suse"
remote_file "/etc/zypp/repos.d/ambari.repo" do
source node['ambari']['suse_11_repo']
not_if { File.exists?("/etc/zypp/repos.d/ambari.repo") }
end

That worked for me. Let me know if you want me to write that up and submit
a pull request.


Reply to this email directly or view it on GitHub
#2 (comment).

@Joseph-R
Copy link
Collaborator Author

Hey JP,

Thanks! Will do.

Regards,
Joe

@jp
Copy link
Owner

jp commented Apr 26, 2015

Thanks for the PR 👍

@jp jp closed this as completed Apr 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants