Dave Taubler
Dave Taubler

Reputation: 1091

Chef and postgres; how do I specify the password?

I'm new to chef, and I'm trying to interprete the documentation. I've added the opscode postgresql recipe to my chef-solo environment. postgresql seems to install and launch just fine, but unfortunately I can't log in to the server, rendering it pretty much unusable.

The documentation mentions this:

The following node attribute is stored on the Chef Server when using chef-client. Because chef-solo does not connect to a server or save the node object at all, to have the password persist across chef-solo runs, you must specify them in the json_attribs file used. For Example:

{
  "postgresql": {
    "password": {
      "postgres": "iloverandompasswordsbutthiswilldo"
    }
  },
  "run_list": ["recipe[postgresql::server]"]
}

However, I don't know what "the json_attribs" file is. The recipe itself doesn't contain such a file, and I tried googling, with no results. I also tried creating such a file and sticking it in random spots in my directory structure, but of course that didn't work.

And by "didn't work", I mean that I brought vagrant up, ssh'ed in, and tried "psql -U postgres -W" and then entering the password I'd created... but always get an authentication error. Note also that I understand that the value I provide for the password (e.g. in place of "iloverandompasswordsbutthiswilldo" in the example above) is supposed to be an MD5 hash of the password, not plaintext, so that's what I'd provided.

Upvotes: 4

Views: 4946

Answers (1)

cmur2
cmur2

Reputation: 2624

Since you are using Vagrant you should propably add something like the following to your Vagrantfile into the config.vm.provision :chef_solo do |chef| section (where one or more chef.add_recipe calls exists too):

config.vm.provision :chef_solo do |chef|
  # other stuff... like: chef.add_recipe "postgresql::server"
  chef.json = {
    "postgresql" => {
      "password" => {
        "postgres" => "iloverandompasswordsbutthiswilldo"
      }
    }
  }
end

The chef.json hash is the place where all your node specific attributes go and which is handed over to chef-solo during the provision run by Vagrant, see Vagrant doc for more information.

Upvotes: 7

Related Questions