0
votes

Can anyone tell me what I'm doing wrong here. I am trying to use chef solo to deploy a rails stack. I am using the database cookbook. I have two roles webserver & sparkle_database_master that are attached at the end.

My command line:

knife solo cook --identity-file=/home/sburke/.ssh/sab-sburke-sparkle.pem -r "role[sparkle_database_master], role[webserver]" -E production [email protected]

Output: ================================================================================ Recipe Compile Error in /home/ubuntu/chef-solo/cookbooks-2/database/recipes/master.rb ================================================================================

Chef::Exceptions::PrivateKeyMissing
-----------------------------------
I cannot read /etc/chef/client.pem, which you told me to use to sign requests!

Cookbook Trace:
---------------
  /home/ubuntu/chef-solo/cookbooks-2/database/recipes/master.rb:30:in `from_file'

Relevant File Content:
----------------------
/home/ubuntu/chef-solo/cookbooks-2/database/recipes/master.rb:

 23:  # will win out, so make sure the databags have the same passwords set for
 24:  # the root, repl, and debian-sys-maint users.
 25:  #
 26:  
 27:  db_info = {}
 28:  root_pw = ''
 29:  
 30>> search(:apps) do |app|
 31:    (app['database_master_role'] & node.run_list.roles).each do |dbm_role|
 32:      %w(root repl debian).each do |user|
 33:        user_pw = app["mysql_#{user}_password"]
 34:        if !user_pw.nil? && user_pw[node.chef_environment]
 35:          Chef::Log.debug("Saving password for #{user} as node attribute node['mysql']['server_#{user}_password'")
 36:          node.set['mysql']["server_#{user}_password"] = user_pw[node.chef_environment]
 37:          node.save
 38:        else
 39:          log "A password for MySQL user #{user} was not found in DataBag 'apps' item '#{app["id"]}' for environment ' for #{node.chef_environment}'." do


Running handlers:
[2014-11-15T08:38:44+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-11-15T08:38:44+00:00] ERROR: Exception handlers complete
[2014-11-15T08:38:44+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 1.24174155 seconds
[2014-11-15T08:38:44+00:00] ERROR: I cannot read /etc/chef/client.pem, which you told me to use to sign requests!
[2014-11-15T08:38:44+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.
sburke@sewer:~/sandbox/sparkle-kitchen$ knife solo cook --identity-file=/home/sburke/.ssh/sab-sburke-sparkle.pem -r "role[sparkle_database_master], role[webserver]" -E production [email protected]

sparkle_database_master role

{
    "name": "sparkle_database_master",
    "default_attributes": {
        "postgresql": {
            "password": {
                "postgres": "md586643717dc6cb1111610b853bf48efbb"
            },
            "config": {
                "listen_addresses": "localhost",
                "port": "5432"
            }
        }
    },
    "json_class": "Chef::Role",

    "env_run_lists": {
        "production": ["recipe[postgresql::server]",
                       "recipe[database::master]",
                       "recipe[database::postgresql]"
                      ]
    },
    "chef_type": "role",
    "override_attributes": {
        "postgresql": {
            "password": {
                "postgres": "md586643717dc6cb1111610b853bf48efbb"
            },
            "config": {
                "listen_addresses": "localhost",
                "port": "5432"
            }
        }
    }
}

webserver role

{
  "name": "webserver",
  "default_attributes": {
  },
  "json_class": "Chef::Role",
  "env_run_lists": {
    "production": ["recipe[build-essential::default]",
                   "recipe[apache2]",
                   "recipe[apache2::mod_ssl]",
                   "recipe[apache2::mod_rewrite]",
                   "recipe[apache2::mod_deflate]",
                   "recipe[apache2::mod_headers]",
                   "recipe[nodejs]",
                   "recipe[sparkle]"
                  ],
    "test": [ "role[base]", "recipe[apache2]", "recipe[apache::copy_test_configs]" ],
    "dev": [ "role[base]", "recipe[apache2]", "recipe[apache::copy_dev_configs]" ]
  },
  "run_list": [ "role[base]",
                "recipe[build-essential::default]",
                "recipe[apache2]",
                "recipe[apache2::mod_ssl]" ],
  "description": "The webserver role",
  "chef_type": "role",
  "override_attributes": {
      "passenger": {
          "install_method": "package",
          "package": {
              "name": "libapache2-mod-passenger"
          }
      }
  }
}
1

1 Answers

2
votes

The database::master recipe is not currently compatible with chef-solo, though it could be. Either use chef-client --local or the chef-solo-search cookbook, or patch the cookbook to not use the search API.