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

Properties for repositories don't work #85

Open
praste opened this issue Jun 5, 2014 · 13 comments
Open

Properties for repositories don't work #85

praste opened this issue Jun 5, 2014 · 13 comments

Comments

@praste
Copy link
Contributor

praste commented Jun 5, 2014

Hi,
I am trying to use properties to create hosted, proxy and group repos, but looks like these properties are completely ignored.

Here are the attributes that I added to attributes/default.rb

default[:nexus][:hosted_repositories] = [{name: "My Test Repo",publisher: true}]

default[:nexus][:proxy_repositories] = [{ name: "My Proxy Repo", subscriber: true, publisher: false, url: "http://some-other-nexus/repo" }]

default[:nexus][:group_repositories] = [ {name: "My Group Repo", add: ["My Hosted Repo"], remote: ["My Proxy Repo"] }]

am I missing something?

@KAllan357
Copy link
Contributor

Sorry, I think that particular feature was removed. The README may need updating. My current recommendation is to use this cookbook to set up your default server and write your own 'wrapper' cookbook that encapsulates some extra setup behavior.

@praste
Copy link
Contributor Author

praste commented Jun 6, 2014

I am a bit new to chef, hence pardon my ignorance. Today I tried to create repo using 'resources' approach. I added following to recipe/app.rb

nexus_hosted_repository node[:nexus][:name] do
name 'local_snapshots'
publisher true
end

However, I keep getting error "ERROR: nexus_hosted_repository[local_snapshots](nexus::app line 111) had an error: TypeError: can't convert Array into String"

I don't understand which variable it thinks is of type Array ???

@KAllan357
Copy link
Contributor

Can you create a gist of the full stack trace? I'd like to see the compiled Chef resource as well if possible.

@praste
Copy link
Contributor Author

praste commented Jun 6, 2014

-Here it is :

[2014-06-06T20:43:51+00:00] INFO: template[/etc/nginx/sites-available/nexus_proxy.conf] created file /etc/nginx/sites-available/nexus_proxy.conf
[2014-06-06T20:43:51+00:00] INFO: template[/etc/nginx/sites-available/nexus_proxy.conf] updated file contents /etc/nginx/sites-available/nexus_proxy.conf
[2014-06-06T20:43:51+00:00] INFO: template[/etc/nginx/sites-available/nexus_proxy.conf] owner changed to 0
[2014-06-06T20:43:51+00:00] INFO: template[/etc/nginx/sites-available/nexus_proxy.conf] group changed to 0
[2014-06-06T20:43:51+00:00] INFO: template[/etc/nginx/sites-available/nexus_proxy.conf] mode changed to 644
[2014-06-06T20:43:51+00:00] INFO: execute[nxensite nexus_proxy.conf] ran successfully
[2014-06-06T20:43:51+00:00] INFO: execute[nxensite nexus_proxy.conf] not queuing delayed action reload on servicenginx, as it's already been queued
[2014-06-06T20:43:51+00:00] INFO: execute[nxdissite default] ran successfully
[2014-06-06T20:43:51+00:00] INFO: execute[nxdissite default] not queuing delayed action reload on servicenginx, as it's already been queued

===============================================================================
Error executing action create on resource 'nexus_hosted_repository[local_snapshots]'
===============================================================================

Chef::Exceptions::ValidationFailed

Data Bag Items must contain a Hash or Mash!

Cookbook Trace:

/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nexus/libraries/chef_nexus.rb:218:in encrypted_data_bag_item' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nexus/libraries/chef_nexus.rb:203:inencrypted_data_bag_for'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nexus/libraries/chef_nexus.rb:37:in get_nexus_data_bag' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nexus/libraries/chef_nexus.rb:46:inget_credentials'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nexus/libraries/chef_nexus.rb:79:in nexus' /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nexus/providers/hosted_repository.rb:62:inrepository_exists?'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/nexus/providers/hosted_repository.rb:33:in `block in class_from_file'

Resource Declaration:

In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/my-nexus/recipes/default.rb

13: nexus_hosted_repository node[:nexus][:name] do
14: name 'local_snapshots'
15: publisher true
16: end

Compiled Resource:

Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/my-nexus/recipes/default.rb:13:in `from_file'

nexus_hosted_repository("local_snapshots") do
action :create
retries 0
retry_delay 2
guard_interpreter :default
cookbook_name :"my-nexus"
recipe_name "default"
publisher true
end

[2014-06-06T20:43:53+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-06-06T20:43:53+00:00] INFO: template[nginx.conf] sending reload action to servicenginx
[2014-06-06T20:43:54+00:00] INFO: service[nginx] reloaded
[2014-06-06T20:43:54+00:00] ERROR: Running exception handlers
[2014-06-06T20:43:54+00:00] ERROR: Exception handlers complete
[2014-06-06T20:43:54+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-06-06T20:43:54+00:00] ERROR: nexus_hosted_repository[local_snapshots](my-nexus::default line 13) had an error: Chef::Exceptions::ValidationFailed: Data Bag Items must contain a Hash or Mash!
[2014-06-06T20:43:54+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

  • Here is how my databag looks like

bash$ cat ~/.chef/data_bags/nexus/_wildcard.json
{
"id": "_wildcard",
"credentials": {
"encrypted_data": "AHjl1FdL3KjjjkWT4lkxbSqUA77zlQTX1pnbyPED/THbCBryZmP/dBhTPmdQ\nVzz9qs7P5WY7eLxa6dMzy6yayS8EAzBcRyo+bOHjSlIEiy0NfuZEtV2nUAn0\nptSo31qRTC72ph615R/n31u+EzHdxzDIbPQwjVdJ+SbSGQM6qu98apPo44Fz\nEQwHqq2dJV+Z\n",
"iv": "8lXA1LR+geOPBpWVOr6gVw==\n",
"version": 1,
"cipher": "aes-256-cbc"
},
"license": {
"encrypted_data": "oFEdZBVzEhDeqMYa2QegzNIoDnP/Y+B8VHaKb0L8XPmTkZidflPhaZAZypFY\nLjNeIM9Xjgxq+RxvqrLFwvrSHA==\n",
"iv": "cOSiNl3H46KvRdF6VLfF7g==\n",
"version": 1,
"cipher": "aes-256-cbc"
}
}

@KAllan357
Copy link
Contributor

Seems like there is something wrong with your data bag setup. My guess would be maybe you aren't passing an encrypted data bag secret in your run?

@praste
Copy link
Contributor Author

praste commented Jun 9, 2014

You mean

chef.encrypted_data_bag_secret_key_path = File.join(chef_dir, "encrypted_data_bag_secret")

I am already doing that. Is there additional step required?
My data bag is in ~/.chef/data_bags directory
Secrete file is in ~/.chef directory

@praste
Copy link
Contributor Author

praste commented Jun 9, 2014

I think I found the issue. Following line is causing the error as default chef environment is '_default' and we are trying to load file with that id

/libraries/chef_nexus.rb:203
data_bag_item = encrypted_data_bag_item(node, data_bag, node.chef_environment)

@atoulme
Copy link
Contributor

atoulme commented Sep 26, 2014

I have the same issue, and being a newbie myself, I'm not sure I understand what you did to fix the problem. Would you please help me understand how to fix the issue?

@praste
Copy link
Contributor Author

praste commented Sep 26, 2014

I send a patch to fix the issue, which is now incorporated into the
cookbook. You can download cookbook source and it would work (I am not sure
if cookbook was with patch was released to opscode's cookbook repository)

On Fri, Sep 26, 2014 at 2:59 PM, Antoine Toulme [email protected]
wrote:

I have the same issue, and being a newbie myself, I'm not sure I
understand what you did to fix the problem. Would you please help me
understand how to fix the issue?


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

@atoulme
Copy link
Contributor

atoulme commented Sep 26, 2014

Thank you!

@atoulme
Copy link
Contributor

atoulme commented Sep 27, 2014

Hmmm, I'm still getting the same problem. I will investigate further.

@praste
Copy link
Contributor Author

praste commented Sep 27, 2014

you mean issue with the databag ? Are you running chef solo? If yes then you might want to have following config in ~/.chef/knife.rb

log_level                :info
log_location             STDOUT
node_name                'solo'
cache_type               'BasicFile'
current_dir = File.dirname(__FILE__)
cookbook_path ["#{current_dir}/cookbooks"]
role_path "#{current_dir}/roles"
data_bag_path "#{current_dir}/data_bags"
chef_repo_path "."

and make sure that directory pointed to data_bag_path has directory named nexus which in turn contains a databag named _wildcard.json

@atoulme
Copy link
Contributor

atoulme commented Sep 27, 2014

I actually use Berkshelf+Vagrant.
It turned out I was missing a chef.data_bags_path = "data_bags" instruction in my VagrantFile.
Once I placed that in, I still had a little fight with knife to encrypt the nexus_ssl_files data bag (apparently it is required even if you try to disable proxy).

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

3 participants