Chef and postgres; How to specify a password?

I am new to the cook and I am trying to interpret the documentation. I added the postscreql opscode recipe to my chef's environment. postgresql seems to install and run just fine, but unfortunately I cannot log into the server, making it pretty unusable.

The documentation mentions the following:

The following node attribute is stored on the Chef Server when using the cook client. Because chef-solo does not connect to the server or does not save the node object at all, so that the password is saved through the chef you must specify them in the json_attribs file. For example:

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

However, I do not know what the json_attribs file is. The recipe itself does not contain such a file, and I tried a search on Google, without any results. I also tried to create such a file and paste it into random spots in my directory structure, but of course this did not work.

And "didn’t work," I mean, I brought the stroller up, ssh'ed in and tried "psql -U postgres -W" and then entered the password that I created ... but I always get an authentication error. Please also note that I understand that the value that I provide for the password (for example, instead of “iloverandompasswordsbutthiswilldo” in the above example) should be an MD5 password hash, not plain text, so that what I provide.

+4
source share
1 answer

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

 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 attributes are sent and passed to the chef solo during the execution of Vagrant, see the Vagrant doc for more information.

+7
source

All Articles