-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hello,
I'm trying to use this cookbook in the following way:
- have data_bags/ssh-keys.json like:
{
"id": "postgres",
"keys": [
{
"id": "key1",
"pub": "ssh-rsa AAAAB3NzaC1yc2EAAA...",
"priv": [
"-----BEGIN RSA PRIVATE KEY-----",
"MIIEpAIBAAKCAQEAzeHP7DFJjeN...",
"-----END RSA PRIVATE KEY-----"
]
}
],
"id": "barman",
"keys": [
{
"id": "key1",
"pub": "ssh-rsa AAAAB3NzaC1yc2EAAAA...",
"priv": [
"-----BEGIN RSA PRIVATE KEY-----",
"MIIEpAIBAAKCAQEAv2cqOH5o9x8zYvZ...",
"-----END RSA PRIVATE KEY-----"
]
}
]
}
- have a db role with the following:
{
"json_class": "Chef::Role",
"name": "db",
"description": "Database server facing trusted clients",
"run_list": [
...
"recipe[user-ssh-keys]",
],
"default_attributes": {
"user_ssh_keys": {
"data_bag": "ssh_keys",
"users": {
"postgres": {
"authorized_users": ["barman"]
}
}
}
}
}
- similarly, a backup role:
{
"json_class": "Chef::Role",
"name": "backup",
"description": "Barman Server to backup postgresql databases",
"run_list": [
...
"recipe[user-ssh-keys]",
...
],
"user_ssh_keys": {
"data_bag": "ssh_keys",
"users": {
"barman": {
"authorized_users": ["postgres"]
}
}
}
}
}
Now, when trying to provision backup role with vagrant provision backup, I get this error:
=> backup: Recipe: user-ssh-keys::default
==> backup: * user_ssh_keys_key[barman] action create
==> backup: [2016-03-11T17:57:17+00:00] ERROR: Failed to load data bag item: "ssh_keys" "barman"
==> backup:
==> backup:
==> backup: ================================================================================
==> backup: Error executing action `create` on resource 'user_ssh_keys_key[barman]'
==> backup: ================================================================================
==> backup:
==> backup: NoMethodError
==> backup: -------------
==> backup: undefined method `delete' for nil:NilClass
==> backup:
==> backup: Cookbook Trace:
==> backup: ---------------
==> backup: /tmp/vagrant-chef/63cc8ab6e38a899c4d05e103f866c60d/cookbooks/user-ssh-keys/providers/key.rb:13:in `block (2 levels) in class_from_file'
==> backup: /tmp/vagrant-chef/63cc8ab6e38a899c4d05e103f866c60d/cookbooks/user-ssh-keys/libraries/user.rb:25:in `call'
==> backup: /tmp/vagrant-chef/63cc8ab6e38a899c4d05e103f866c60d/cookbooks/user-ssh-keys/libraries/user.rb:25:in `normalize!'
==> backup: /tmp/vagrant-chef/63cc8ab6e38a899c4d05e103f866c60d/cookbooks/user-ssh-keys/providers/key.rb:6:in `block in class_from_file'
==> backup:
==> backup: Resource Declaration:
==> backup: ---------------------
==> backup: # In /tmp/vagrant-chef/63cc8ab6e38a899c4d05e103f866c60d/cookbooks/user-ssh-keys/recipes/default.rb
==> backup:
==> backup: 2: user_ssh_keys_key username do
==> backup: 3: authorized_keys user['authorized_keys']
==> backup: 4: authorized_users user['authorized_users']
==> backup: 5: data_bag node['user_ssh_keys']['data_bag']
==> backup: 6: action :create
==> backup: 7: end
==> backup: 8: end
==> backup:
==> backup: Compiled Resource:
==> backup: ------------------
==> backup: # Declared in /tmp/vagrant-chef/63cc8ab6e38a899c4d05e103f866c60d/cookbooks/user-ssh-keys/recipes/default.rb:2:in `block in from_file'
==> backup:
==> backup: user_ssh_keys_key("barman") do
==> backup: action [:create]
==> backup: retries 0
==> backup: retry_delay 2
==> backup: default_guard_interpreter :default
==> backup: declared_type :user_ssh_keys_key
==> backup: cookbook_name :"user-ssh-keys"
==> backup: recipe_name "default"
==> backup: authorized_users ["postgres"]
==> backup: data_bag "ssh_keys"
==> backup:
==> backup: end
==> backup:
==> backup:
==> backup:
==> backup: [2016-03-11T17:57:17+00:00] INFO: Running queued delayed notifications before re-raising exception
==> backup:
==> backup: Running handlers:
==> backup: [2016-03-11T17:57:17+00:00] ERROR: Running exception handlers
==> backup: Running handlers complete
==> backup:
==> backup: [2016-03-11T17:57:17+00:00] ERROR: Exception handlers complete
==> backup: Chef Client failed. 4 resources updated in 04 seconds
==> backup: [2016-03-11T17:57:17+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> backup: [2016-03-11T17:57:17+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> backup: [2016-03-11T17:57:17+00:00] ERROR: user_ssh_keys_key[barman] (user-ssh-keys::default line 2) had an error: NoMethodError: undefined method `delete' for nil:NilClass
==> backup: [2016-03-11T17:57:17+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.
what am I doing wrong?
thanks for any help,
Hector.
Metadata
Metadata
Assignees
Labels
No labels