Issues and Fixes for Ansible PostgreSQL Replication Role

Sam Doran contributed this Ansible role for PostgreSQL Repliction, especially for Database Streaming Replication for Ansible Tower Cluster. Some of the issues are already fixed and good to go.

existing_pg_dir - undefined variable

1
2
TASK [packages_el : Check for old Postgres data] ***********************************************************************************
fatal: [node05-db.lab.local]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'existing_pg_dir' is undefined\n\nThe error appears to be in '/home/ansible/ansible-tower-setup-3.6.4-1/roles/packages_el/tasks/install_postgres.yml': line 2, 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: Check for old Postgres data\n  ^ here\n"}

FIX: Added existing_pg_dir: "" in import_role - packages_el section

Typo in Variable value

1
2
TASK [samdoran.pgsql_replication : Add trust in pg_hba.conf] ***********************************************************************
fatal: [node04-db.lab.local]: FAILED! => {"msg": "An unhandled exception occurred while templating ''. Error was a <class 'ansible.errors.AnsibleError'>, original message: template error while templating string: expected token ',', got 'all_ipv4_addresses'. String: "}

Fix:

  • Before : missing ‘ at the end of ansible_facts (in replication sample playbook)
1
pgsqlrep_replica_address: ""
  • After :
  • 1
    
    pgsqlrep_replica_address: ""
    

Issue with Loop as only item entry for replica

1
2
TASK [samdoran.pgsql_replication : Add trust in pg_hba.conf] **************************************************************************
fatal: [node04-db.lab.local]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: 10.6.1.207. Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup."}

Fix: Replaced loop with with_items

1
2
3
#loop: "\{\{ pgsqlrep_replica_address \}\}"
  with_items: "\{\{ pgsqlrep_replica_address \}\}"
  notify: restart postgresql

comments powered by Disqus