Skip to content

PGPORT environment variable is ignored #311

@rgl

Description

@rgl
SUMMARY

The PGPORT environment variable is ignored.

Because of that, we have to explicitly set the port variable in all the ansible module invocation, which is quite unfortunate.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

postgresql_db

ANSIBLE VERSION
ansible [core 2.13.1]
  config file = /playbooks/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection           Version
-------------------- -------
community.postgresql 2.1.5  
CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
  1. Start postgres in a non default port (e.g. 1234)
  2. Export the PGPORT=1234 environment variable
  3. run the following playbook
- hosts: localhost
  connection: local
  tasks:
    - name: Create database
      postgresql_db:
        name: example
        #port: 1234 # this works.
        #port: "{{ lookup('ansible.builtin.env', 'PGPORT') }}" # this also works.
EXPECTED RESULTS

Expected that exporting the PGPORT environment variable would set the used port.

ACTUAL RESULTS
TASK [Create database] *********************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: 	TCP/IP connections on port 5432?
fatal: [localhost]: FAILED! => {"changed": false, "msg": "unable to connect to database: could not connect to server: Connection refused\n\tIs the server running on host \"yb-tservers.yugabytedb\" (10.244.0.18) and accepting\n\tTCP/IP connections on port 5432?\n"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions