Chef and postgres; how do I specify the password?

会有一股神秘感。 提交于 2019-12-04 13:21:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15195467/chef-and-postgres-how-do-i-specify-the-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!