Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peer authentication failed for user "postgres" on initial chef run (reboot + 2nd run works fine) #232

Closed
nlochschmidt opened this issue Feb 24, 2015 · 3 comments

Comments

@nlochschmidt
Copy link

I am trying to setup a fairly simple Vagrantfile that boots a VM with postgresql and creates a couple of users and databases using hw-cookbooks/database. In the end I need access to the database from the host machine, so I change the pg_hba.conf by setting a couple of attributes in the Vagrantfile:

chef.json = {
  "postgresql" => {
    "version" => "9.3",
    "password" => {
      "postgres" => "postgres",
    },
    "config" => {
      "listen_addresses" => "*"
    },
    "pg_hba" => [
      { "type" => 'host', "db" => 'all', "user" => 'all', "addr" => '10.0.0.0/16', "method" => 'md5' },
      { "type" => 'local', "db" => 'all', "user" => 'all', "addr" => '', "method" => 'trust' }
    ]
  }
}

Now, when I boot the VM for the first time I get FATAL: Peer authentication failed for user "postgres". When I reboot the VM and run chef again everything works as it should, but I destroy and reprovision the VM a couple of times per month and it's just cumbersome.

I also see this in my log:

INFO: template[/etc/postgresql/9.3/main/pg_hba.conf] not queuing delayed action restart on service[postgresql] (delayed), as it's already been queued

So my guess is this has to do with the service notification having been changed from :immediately to :delayed and therefore when I try to create the users and databases during the initial convergence run the default pg_hba.conf is still in effect.

Am I doing something wrong? Help would be appreciated.

@chr4
Copy link
Contributor

chr4 commented Feb 24, 2015

I'm having a similar issue - Creating databases in the same Chef run as configuring postgresql seems to me like a regular usecase.
Was there a particular reason the action was changed to :delayed?

+1

@nlochschmidt
Copy link
Author

I experienced this on 3.4.14 but can not reproduce this on 3.4.20. So it seems to be fixed.

chris-rock pushed a commit to chris-rock/postgresql that referenced this issue Jan 4, 2017
chris-rock pushed a commit to chris-rock/postgresql that referenced this issue Jan 4, 2017
chris-rock pushed a commit to chris-rock/postgresql that referenced this issue Jan 4, 2017
chris-rock pushed a commit to chris-rock/postgresql that referenced this issue Jan 4, 2017
chris-rock pushed a commit to chris-rock/postgresql that referenced this issue Jan 4, 2017
chris-rock pushed a commit to chris-rock/postgresql that referenced this issue Jan 4, 2017
@lock
Copy link

lock bot commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants