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

Support alternative database socket usage #185

Open
tyler-8 opened this issue Jun 25, 2024 · 1 comment
Open

Support alternative database socket usage #185

tyler-8 opened this issue Jun 25, 2024 · 1 comment

Comments

@tyler-8
Copy link
Collaborator

tyler-8 commented Jun 25, 2024

The role task currently assumes the database socket (if used) is auth-less and port-less. However in some circumstances (like when using pgbouncer locally, to access a remote db), passwords and ports are necessary to define for the socket.

This behavior could be controlled with a simple variable flag, for example: netbox_database_use_alt_socket: true to ensure only one type of socket validation task is used.

- name: Ensure Postgres database exists (via socket with password/port)
  community.postgresql.postgresql_db:
    name: "{{ netbox_database }}"
    login_user: "{{ netbox_database_user }}"
    login_unix_socket: "{{ netbox_database_socket }}"
    port: "{{ netbox_database_port }}"
    login_password: "{{ netbox_database_password }}"
    maintenance_db: "{{ netbox_database_maintenance }}"
  become: true
  become_user: "{{ netbox_database_user }}"
  when:
    - netbox_database_socket is defined
    - netbox_database_use_alt_socket
    - netbox_database_host is not defined
@lae
Copy link
Owner

lae commented Jul 1, 2024

I believe we can still use the same task, just use the omit filter for the port/login password.
Although since netbox_database_port technically has a default I guess omit wouldn't make any difference, but I'm not sure if specifying it here for standard socket use will cause a problem or not.

@lae lae added the enhancement label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants