Unable to define global config with version 3.4.0
fblackburn1 opened this issue · 15 comments
Given I use the latest ansible-role-postgres (3.4.0)
Given I override postgresql_global_config_options
variable (but not log_directory
option)
When I execute my playbook
Then I get the following error:
TASK [geerlingguy.postgresql : Define postgresql_log_dir.] ************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'log_directory'\n\nThe error appears to be in '/root/.ansible
/roles/geerlingguy.postgresql/tasks/variables.yml': line 58, 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: Define po
stgresql_log_dir.\n ^ here\n"}
Workaround: define log_directory
inside my custom postgresql_global_config_options
variable
Expected: No need to define log_directory
option
Playbook:
- name: Postgres issue
hosts: test
- name: Install postgres
include_role:
name: geerlingguy.postgresql
vars:
postgresql_global_config_options:
- option: listen_addresses
value: "{{ postgresql_listen_addresses | default('127.0.0.1') }}"
Same issue here.
Using Version 3.3.1 helps!
Same as @dcardellino here.
Update:
In my case it was because the variable postgresql_global_config_options got facts set in another role, overwriting the variable set in this role.
---
- hosts: db
become: yes
pre_tasks:
- name: Update repositories cache
apt:
update_cache: yes
roles:
- role: geerlingguy.postgresql
vars:
postgresql_users:
- name: vagrant
password: vagrant
postgresql_databases:
- name: books
owner: vagrant
postgresql_hba_entries:
- { type: host, database: all, user: all, address: '0.0.0.0/0', auth_method: md5 }
postgresql_global_config_options:
- option: listen_addresses
value: '*'
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
--- - hosts: db become: yes pre_tasks: - name: Update repositories cache apt: update_cache: yes roles: - role: geerlingguy.postgresql vars: postgresql_users: - name: vagrant password: vagrant postgresql_databases: - name: books owner: vagrant postgresql_hba_entries: - { type: host, database: all, user: all, address: '0.0.0.0/0', auth_method: md5 } postgresql_global_config_options: - option: listen_addresses value: '*'
![]()
I had the same issue, so just put the log_directory
param in there as well, same value as the default
That seems to make it happy
This issue is no longer marked for closure.
Still actual
Still actual
indeed
check my solution above, perhaps it works for you as well
Still actual
indeed check my solution above, perhaps it works for you as well
Of course, I have no problem finding the workaround.
This issue should be investigated and fixed in this repository.
Can somebody help me, this is my playbook.
I still get the same error:
- hosts: database
become: yes
pre_tasks:
- name: Update repositories cache
apt:
update_cache: yes
roles:
- role: geerlingguy.postgresql
vars:
postgresql_restarted_state: "restarted"
postgresql_service_state: started
postgresql_service_enabled: true
postgresql_auth_method: 'scram-sha-256'
postgresql_hba_entries:
- {type: local, database: all, user: postgres, auth_method: peer}
- {type: local, database: all, user: all, auth_method: peer}
- {type: host, database: all, user: all, address: '127.0.0.1/32', auth_method: "scram-sha-256"}
- {type: host, database: all, user: all, address: '::1/128', auth_method: "scram-sha-256"}
- {type: host, database: all, user: all, address: '0.0.0.0/0', auth_method: "scram-sha-256"}
- {type: host, database: all, user: all, address: '::/0', auth_method: "scram-sha-256"}
postgresql_global_config_options:
- option: listen_addresses
value: '*'
- name: Open Postgres Port
hosts: database
tasks:
- name: Allow Postgres
community.general.ufw:
rule: allow
port: "5432"
proto: tcp
After adding the option: log_directory, it kinda works! I get the following error and I need to restart postgresql manually
TASK [geerlingguy.postgresql : Ensure PostgreSQL users are present.] *****************************************************
failed: [208.83.232.178] (item=None) => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
fatal: [208.83.232.178]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.