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

Database And User Adding Problem #140

Closed
koraykutanoglu opened this issue Jan 11, 2022 · 3 comments
Closed

Database And User Adding Problem #140

koraykutanoglu opened this issue Jan 11, 2022 · 3 comments
Labels
bug Something isn't working enhancement Improvement of the current functionality

Comments

@koraykutanoglu
Copy link

On the Ansible config files, I specify the database and user that I want to add to my postgresql cluster.

image

and I also set it up so users can join pgbouncer.

image

and I want to redistribute the changes with ansible with the following command

ansible-playbook deploy_pgcluster.yml --tags postgresql_users,postgresql_databases,pgbouncer_conf

but I am getting error as below.

TASK [postgresql-users : Make sure the PostgreSQL users are present] **************************************************************
fatal: [10.10.10.91]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'postgresql_unix_socket_dir' is undefined\n\nThe error appears to be in '/root/postgresql-cluster-v2/postgresql_cluster-kurduktan-sonra/roles/postgresql-users/tasks/main.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Make sure the PostgreSQL users are present\n  ^ here\n"}
...ignoring

TASK [postgresql-databases : Make sure the PostgreSQL databases are present] ******************************************************
fatal: [10.10.10.91]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'postgresql_unix_socket_dir' is undefined\n\nThe error appears to be in '/root/postgresql-cluster-v2/postgresql_cluster-kurduktan-sonra/roles/postgresql-databases/tasks/main.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Make sure the PostgreSQL databases are present\n  ^ here\n"}
...ignoring

I used the -vvvvv option for more detailed output.

TASK [postgresql-users : Make sure the PostgreSQL users are present] **************************************************************
task path: /root/postgresql-cluster-v2/postgresql_cluster-kurduktan-sonra/roles/postgresql-users/tasks/main.yml:3
fatal: [10.10.10.91]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'postgresql_unix_socket_dir' is undefined\n\nThe error appears to be in '/root/postgresql-cluster-v2/postgresql_cluster-kurduktan-sonra/roles/postgresql-users/tasks/main.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Make sure the PostgreSQL users are present\n  ^ here\n"
}
...ignoring
Read vars_file 'vars/main.yml'
Read vars_file 'vars/system.yml'
Read vars_file 'vars/main.yml'
Read vars_file 'vars/system.yml'
Read vars_file 'vars/main.yml'
Read vars_file 'vars/system.yml'

TASK [postgresql-databases : Make sure the PostgreSQL databases are present] ******************************************************
task path: /root/postgresql-cluster-v2/postgresql_cluster-kurduktan-sonra/roles/postgresql-databases/tasks/main.yml:3
fatal: [10.10.10.91]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'postgresql_unix_socket_dir' is undefined\n\nThe error appears to be in '/root/postgresql-cluster-v2/postgresql_cluster-kurduktan-sonra/roles/postgresql-databases/tasks/main.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Make sure the PostgreSQL databases are present\n  ^ here\n"

What do you think is the problem?

@vitabaks
Copy link
Owner

vitabaks commented Jan 11, 2022

Hi @koraykutanoglu

'postgresql_unix_socket_dir' is undefined - when using tags, the vars/Debian.yml (or vars/RedHat.yml) variable file is not imported

since I moved these files to pre_tasks:include_vars to support Rocky Linux and AlmaLinux in Ansible prior to version 2.11
I will think about how to fix it so as not to lose support for these distributions

in the meantime (workaround), change the code in the deploy_pgcluster.yml file as follows

- hosts: postgres_cluster
  become: true
  become_method: sudo
  gather_facts: true
  any_errors_fatal: true
  vars_files:
    - vars/main.yml
    - vars/system.yml
    - vars/Debian.yml

  pre_tasks:
#    - name: Include OS-specific variables
#      include_vars: "vars/{{ ansible_os_family }}.yml"
#     when: not ansible_os_family == 'Rocky' and not ansible_os_family == 'AlmaLinux'

    # For compatibility with Ansible old versions
    # (support for RockyLinux and AlmaLinux has been added to Ansible 2.11)
#    - name: Include OS-specific variables
#      include_vars: "vars/RedHat.yml"
#      when: ansible_os_family == 'Rocky' or ansible_os_family == 'AlmaLinux'

@vitabaks vitabaks added bug Something isn't working enhancement Improvement of the current functionality labels Jan 11, 2022
@vitabaks
Copy link
Owner

@koraykutanoglu I fixed it 6acba3c

please download the playbook and check again

@koraykutanoglu
Copy link
Author

problem solved, thanks!

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

No branches or pull requests

2 participants