I am already using application cookbook to deploy and install my java application. I tried it on my own.
application "saymetrix" do
path "/usr/local"
owner "chef"
group "chef"
end
And for the above code i get following error.
Error executing action `deploy` on resource 'application[saymetrix]'
================================================================================
NameError
---------
Cannot find a resource for saymetrix on ubuntu version 12.04
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/application/providers/default.rb:82:in `before_deploy'
/var/chef/cache/cookbooks/application/providers/default.rb:27:in `block in class_from_file'
I don't get how to resolve this?
Refer to the application_java cookbook.
you need to add these in the metadata.rb of your saymatrix cookbook:
depends 'application'
depends 'application_java'
And add necessary details at least including repository and deployment target like tomcat. You can find the section Usage of the example here: application_java
Related
I'm trying to make a cookbook that has some dependencies, but it doesn't work
/recipe
ls
default.rb
Recipe:
include_recipe 'sudo::default'
include_recipe 'user'
def will_create_user?(username, user)
return false if node['etc']['passwd'].key?(username)
return true if user['action'] == 'create' || !user.key?('action')
false
end
node['authorization']['sudo']['groups'].each do |group|
group group
end
node['vms']['users'].each do |username, user|
send_notification = will_create_user? username, user
user_account username do
comment user['comment'] if user['comment']
ssh_keys user['ssh_keys']
groups user['groups'] if user['groups']
if send_notification
notifies :run, "execute[reset_password_#{username}]", :delayed
end
end
execute "reset_password_#{username}" do
command "passwd -d #{username} && chage -d 0 #{username}"
action :nothing
end
end
Metadata.rb
...
version '0.1.0'
chef_version '>= 14.0'
depends "sudo"
depends "user"
Berksfile.lock
DEPENDENCIES
vms-users
path: .
metadata: true
GRAPH
sudo (5.4.5)
user (0.7.0)
vms-users (0.1.0)
sudo (>= 0.0.0)
user (>= 0.0.0)
Attributes/default.rb
{
"vms": {
"users": {
'magrini' => {
'comment' => 'Bruna Magrini',
'groups' => ['sysadmin'],
'ssh_keys' => ['chave ssh'],
},
}
}
}
I'm executing using chef-client --local-mode default.rb
Error: Chef::Exceptions::CookbookNotFound: Cookbook sudo not found
Recipe `sudo::default` is not in the run_list, and cookbook 'sudo'
is not a dependency of any cookbook in the run_list. To load this recipe,
first add a dependency on cookbook 'sudo' in the cookbook you're
including it from in that cookbook's metadata.
Running handlers:
[2019-12-19T20:42:12+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-12-19T20:42:12+00:00] ERROR: Exception handlers complete
Chef Infra Client failed. 0 resources updated in 01 seconds
[2019-12-19T20:42:12+00:00] FATAL: Stacktrace dumped to /home/chef-repo/.chef/local-mode-cache/cache/chef-stacktrace.out
[2019-12-19T20:42:12+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-12-19T20:42:12+00:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook sudo not found. If you're loading sudo from another cookbook, make sure you configure the dependency in your metadata
i have a feeling that you are confusing something, since the title of your question mentions chef-solo when you are really using chef-zero (--local-mode).
you should definitely favor chef-zero over chef-solo (but i won't get into the reasons why).
in both cases (using chef-zero or chef-solo), you will have to download all the cookbooks and make verify chef-client knows where are the cookbooks located.
if you ase using chef-zero, here are some references:
Local mode does not require a configuration file, instead it will look for a directory named /cookbooks and will set chef_repo_path to be just above that. (Local mode will honor the settings in a configuration file, if desired.) If the client.rb file is not found and no configuration file is specified, local mode will search for a config.rb file.
client.rb settings:
chef_repo_path: The path to the chef-repo containing cookbooks and other files, such as environments or data bags, when running Chef Infra Client in local mode.
cookbook_path: The sub-directory for Chef Infra Client cookbooks. This value can be a string or an array of file system locations, processed in the specified order. The last cookbook is considered to override local modifications.
since i see that you are using berkshelf, you can use vendor sub-command to download all the cookbooks dependencies and place them in the same directory. then, have a custom configuration for chef-client, that sets the value of cookbook_path to the same directory which you used in conjunction with berks vendor, and finally execute chef-client.
I'm having a problem with a chef cookbook that create several shared filesystems.
This is the fragment that is giving me problems:
sii_share_share "ansible" do
remote_path "//#{ node['sii_base']['utils_storage_account_name'] }.file.core.windows.net/ansible"
local_path "/opt/ansible"
fstype "cifs"
dir_owner "root"
dir_group "sysadmin"
dir_mode "0770"
file_mode "0660"
cifs_credentials_file "/root/.smb.utils.credentials"
end
The error is "undefined local variable or method `local_path' for #<#:0x00000000047b3ed8>"
This error is happening with these versions:
Chef-client: 14.1.12
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
With previous versions (chef-client 13.6 and ruby 2.3.1p112) this is working fine. I'm running these cookbooks in Azure, using the Linux Chef extension.
Have anyone experimented something like this?
Thanks in advance.
It's possible your resource is using deprecated property naming.
Verify that the sii_share_share resource has a property named local_path
If it does then you need to verify that all of the code inside the
resource itself refers to the local_path property using
new_resource.local_path and not local_path. This has been a
pending deprecation that went in to effect with Chef Client 14.
You should always review breaking changes before making the move between major versions of Chef Client. The end of each chef-client run also outputs deprecation messages as a warning before these breaking changes go in to place.
I am trying to create a recipe to deploy an application.
I would like to combine the Chef deploy resource with the Chef Mercurial provider. The readme of this provider suggest that it is easy to use with deploy resource. However, I'm not sure how to do this.
The mercurial resource is working as expected:
mercurial deploy[:deploy_to] do
repository deploy[:scm][:repository]
ssh_key "/home/vagrant/.ssh/authorized_keys"
ssh_ignore true
branch true
revision deploy[:scm][:revision]
user deploy[:user]
group deploy[:group]
action :sync
end
However I'm having trouble with the provider
deploy deploy[:deploy_to] do
repository deploy[:scm][:repository]
user deploy[:user]
group deploy[:group]
revision deploy[:scm][:revision]
environment deploy[:environment].to_hash
scm_provider Chef::Provider::Mercurial
action :deploy
end
The error I'm getting is NoMethodError: undefined method 'ssh_key' for Chef::Resource::Deploy. This is probably due to the fact that the resource requires the ssh_key attribute. I don't know how to pass this attribute through when using the deploy resource.
How can I make this work?
Does anyone have an example of how to use the Chef deploy resource with the Chef Mercurial provider?
I'm wrapping my usage of the Opscode Java cookbook with one for my company.
I've created an attributes\default.rb file with values specific to my usage.
Despite including a value for the windows package, I keep getting the following error:
NoMethodError
-------------
No resource or method named `windows_package' for `Chef::Recipe "windows"'
Here is my attributes\default.rb file:
default[:java][:install_flavor] = "windows"
default[:java][:jdk_version] = "7"
default[:java][:windows][:url] = "http"
default[:java][:windows][:package_name] = "Java VM"
I am certain that I have uploaded the updated cookbook to my server, and I am certain that the attributes in this file are being loaded as I was previously receiving errors about missing the required windows package URL until I added it (path edited out above).
In the windows recipe of the Java cookbook, there is a call to the windows_package provider of the windows Cookbook. Thus, the windows cookbook is required for the Java cookbook at least on your platform.
As the Java cookbook doesn't explicitly depend on the windows cookbook (through the metadata.rb), it fails at this late stage.
The solution is to add the windows cookbook to your run list.
I have been attempting to setup a chef recipe which installs ruby using RVM and then uses the application_ruby cookbook to configure the application, however I keep running into the error
NameError: Cannot find a resource for bundle_options on ubuntu version 12.04
I am using the following code
application "application setup" do
owner "ubuntu"
group "ubuntu"
repository "https://github.com/me/myapplication.git" // Real address removed
path rails_app_path
revision "master"
rails do
bundler true
precompile_assets true
bundler_deployment true
end
end
I noticed that the bundle_options was recently added, https://github.com/opscode-cookbooks/application_ruby/commit/e7719170a661a957796e8e5d58ba8f4ecd937487 however I am unable to track down if this is causing the issue. I have included
depends "application"
depends "application_ruby"
in my metadata.rb and made sure all my dependencies are installed so I am unsure what I am doing wrong at this point.
According to documentation bundle_options is an attribute of the rails resource, not a resource itself.
The only correct way of using it is INSIDE the "rails" block, so you got the message because you either used it as :
an attribute of the application resource (but outside of the "rails" block)
standalone resource (outside of any resource).
Message you mentioned is being displayed when nonexistent resource is being referenced. e.g. if you had tried to execute following code on your system:
nonexistent_resource "failure gonna happen" do
some_attribute "whatever_value"
end
you would've got a message
NameError: Cannot find a resource for nonexistent_resource on Ubuntu version 12.04
I ran into this problem today as well. It appears the problem is that commit e771917 forgot to add the necessary getter for the bundle_option. Someone filed a PR to fix it (https://github.com/poise/application_ruby/pull/44), but it has not yet been merged. I can confirm that when I made that change locally, this error went away. The forked branch in the PR is located at https://github.com/mauriciosilva/application_ruby/tree/bundle_options_fix.