Why can't this ansible role (geerlinguy.postgresql) find the variables?

34 views Asked by At

I have the following Ansible Playbook:

- hosts: vdtreportlive
  vars_files:
    - ./vars/postgresql.yml
    - ./vars/postgresql_report.yml
  roles:
    - role: geerlingguy.postgresql

When I run this, I get this error: ERROR! couldn't resolve module/action 'postgresql_user'. This often indicates a misspelling, missing collection, or incorrect module path.

However, if I run this modified playbook to check for the presence of the variable, I get the expected result.

- hosts: vdtreportlive
  vars_files:
    - ./vars/postgresql.yml
    - ./vars/postgresql_report.yml
  tasks:
    - name: Print the value of variable postgresql_user
      debug:
        msg: "{{ postgresql_user }} "

This results in

ok: [vdtreportlive] => {
    "msg": "postgres "
}

Why can't the role find the variable when the task can?

1

There are 1 answers

5
Jean-Baptiste Quenot On BEST ANSWER

The error message is about the postgresql_user module, whereas you are referring to postgresql_user as a variable.

You have to make sure that this module is installed, it is not part of Ansible core. Quoting the docs:

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list

To install it, use: ansible-galaxy collection install community.postgresql