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

[ansible/postgres] pg_hba var should be one of method or auth #417

Closed
EmptyByte opened this issue Oct 24, 2024 · 2 comments
Closed

[ansible/postgres] pg_hba var should be one of method or auth #417

EmptyByte opened this issue Oct 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@EmptyByte
Copy link

EmptyByte commented Oct 24, 2024

There is a mix between method and auth to configure pg_hba.conf. Seems to default to trust always.

postgres/defaults/main.yml

postgres_allowed_hosts:
  - {
      type: "host",
      database: "all",
      user: "all",
      address: "0.0.0.0/0",
      method: "trust",
    }

postgres/templates/pg_hba.conf.j2

{% if postgres_allowed_hosts and postgres_allowed_hosts is iterable -%}
{%- for host in postgres_allowed_hosts %}
{{ host.type | default('host') }}         {{ host.database | default('all') }}        {{ host.user | default('all') }}             {{ host.address | default('0.0.0.0/0') }}            {{ item.auth | default('trust') }}
{% endfor %}

postgres\README.md

postgres_allowed_hosts:
  - { type: "host", database: "all", user: "all", address: "0.0.0.0/0", method: "trust"}
@chukka
Copy link
Collaborator

chukka commented Nov 18, 2024

I think there is already PR #428 for this, will be part of next patch release

@bbaassssiiee
Copy link
Contributor

Indeed my PR will fix that, it should be method in the template file (with host as the loop_var, and the var should be tested by JFrog defined as:

# Set the hosts that can access the database
# The first allows SSL with password from the same subnet
# The second does not require SSL from localhost
# The third denies all others
postgres_allowed_hosts:
  - {
    type: "hostssl",
    database: "all",
    user: "all",
    address: "samenet",
    method: "password",
  }
  - {
    type: "host",
    database: "all",
    user: "all",
    address: "127.0.0.1/0",
    method: "password"
  }
  - {
    type: "hostnossl",
    database: "all",
    user: "all",
    address: "0.0.0.0/0",
    method: "reject",
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants