{"id":13747088,"url":"https://github.com/geerlingguy/ansible-role-postgresql","last_synced_at":"2025-05-14T22:09:25.284Z","repository":{"id":11409461,"uuid":"69580677","full_name":"geerlingguy/ansible-role-postgresql","owner":"geerlingguy","description":"Ansible Role - PostgreSQL","archived":false,"fork":false,"pushed_at":"2025-01-31T03:25:40.000Z","size":135,"stargazers_count":599,"open_issues_count":10,"forks_count":396,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-13T19:38:45.778Z","etag":null,"topics":["ansible","database","postgres","postgresql","role","setup","sql"],"latest_commit_sha":null,"homepage":"https://galaxy.ansible.com/geerlingguy/postgresql/","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geerlingguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"geerlingguy","patreon":"geerlingguy"}},"created_at":"2016-09-29T15:24:25.000Z","updated_at":"2025-04-09T14:47:24.000Z","dependencies_parsed_at":"2023-02-17T04:30:49.096Z","dependency_job_id":"d1d9bbf6-c090-44a4-b4ef-f2b6fe39f4e3","html_url":"https://github.com/geerlingguy/ansible-role-postgresql","commit_stats":{"total_commits":156,"total_committers":31,"mean_commits":5.032258064516129,"dds":0.3782051282051282,"last_synced_commit":"7f20fe244b2e09cfa79754ae07507164e3ceede2"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-postgresql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-postgresql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-postgresql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-postgresql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geerlingguy","download_url":"https://codeload.github.com/geerlingguy/ansible-role-postgresql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235701,"owners_count":22036964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","database","postgres","postgresql","role","setup","sql"],"created_at":"2024-08-03T06:01:14.562Z","updated_at":"2025-05-14T22:09:20.273Z","avatar_url":"https://github.com/geerlingguy.png","language":"Jinja","readme":"# Ansible Role: PostgreSQL\n\n[![CI](https://github.com/geerlingguy/ansible-role-postgresql/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-postgresql/actions/workflows/ci.yml)\n\nInstalls and configures PostgreSQL server on RHEL/CentOS or Debian/Ubuntu servers.\n\n## Requirements\n\nNo special requirements; note that this role requires root access, so either run it in a playbook with a global `become: yes`, or invoke the role in your playbook like:\n\n```yaml\n- hosts: database\n  roles:\n    - role: geerlingguy.postgresql\n      become: yes\n```\n## Role Variables\n\nAvailable variables are listed below, along with default values (see `defaults/main.yml`):\n\n```yaml\npostgresql_enablerepo: \"\"\n```\n(RHEL/CentOS only) You can set a repo to use for the PostgreSQL installation by passing it in here.\n\n```yaml\npostgresql_restarted_state: \"restarted\"\n```\n\nSet the state of the service when configuration changes are made. Recommended values are `restarted` or `reloaded`.\n\n```yaml\npostgresql_python_library: python-psycopg2\n```\n\nLibrary used by Ansible to communicate with PostgreSQL. If you are using Python 3 (e.g. set via `ansible_python_interpreter`), you should change this to `python3-psycopg2`.\n\n```yaml\npostgresql_user: postgres\npostgresql_group: postgres\n```\n\nThe user and group under which PostgreSQL will run.\n\n```yaml\npostgresql_unix_socket_directories:\n  - /var/run/postgresql\n```\n\nThe directories (usually one, but can be multiple) where PostgreSQL's socket will be created.\n\n```yaml\npostgresql_service_state: started\npostgresql_service_enabled: true\n```\n\nControl the state of the postgresql service and whether it should start at boot time.\n\n```yaml\npostgresql_global_config_options:\n  - option: unix_socket_directories\n    value: '{{ postgresql_unix_socket_directories | join(\",\") }}'\n  - option: log_directory\n    value: 'log'\n```\nGlobal configuration options that will be set in `postgresql.conf`.\nFor PostgreSQL versions older than 9.3 you need to at least override this variable and set the `option` to `unix_socket_directory`.\nIf you override the value of `option: log_directory` with another path, relative or absolute, then this role will create it for you.\n\n```yaml\npostgresql_hba_entries:\n  - { type: local, database: all, user: postgres, auth_method: peer }\n  - { type: local, database: all, user: all, auth_method: peer }\n  - { type: host, database: all, user: all, address: '127.0.0.1/32', auth_method: md5 }\n  - { type: host, database: all, user: all, address: '::1/128', auth_method: md5 }\n```\n\nConfigure [host based authentication](https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html) entries to be set in the `pg_hba.conf`. Options for entries include:\n\n  - `type` (required)\n  - `database` (required)\n  - `user` (required)\n  - `address` (one of this or the following two are required)\n  - `ip_address`\n  - `ip_mask`\n  - `auth_method` (required)\n  - `auth_options` (optional)\n\nIf overriding, make sure you copy all of the existing entries from `defaults/main.yml` if you need to preserve existing entries.\n\n```yaml\npostgresql_locales:\n  - 'en_US.UTF-8'\n```\n\n(Debian/Ubuntu only) Used to generate the locales used by PostgreSQL databases.\n\n```yaml\npostgresql_databases:\n  - name: exampledb # required; the rest are optional\n    lc_collate: # defaults to 'en_US.UTF-8'\n    lc_ctype: # defaults to 'en_US.UTF-8'\n    encoding: # defaults to 'UTF-8'\n    template: # defaults to 'template0'\n    login_host: # defaults to 'localhost'\n    login_password: # defaults to not set\n    login_user: # defaults to 'postgresql_user'\n    login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories\n    port: # defaults to not set\n    owner: # defaults to postgresql_user\n    state: # defaults to 'present'\n```\n\nA list of databases to ensure exist on the server. Only the `name` is required; all other properties are optional.\n\n```yaml\npostgresql_users:\n  - name: jdoe #required; the rest are optional\n    password: # defaults to not set\n    encrypted: # defaults to not set\n    role_attr_flags: # defaults to not set\n    db: # defaults to not set\n    login_host: # defaults to 'localhost'\n    login_password: # defaults to not set\n    login_user: # defaults to '{{ postgresql_user }}'\n    login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories\n    port: # defaults to not set\n    state: # defaults to 'present'\n```\n\nA list of users to ensure exist on the server. Only the `name` is required; all other properties are optional.\n\n```yaml\npostgresql_privs:\n  - db: exampledb # database (required)\n    roles: jdoe  # role(s) the privs apply to (required)\n    privs: # comma separated list of privileges - defaults to not set\n    type: # type of database object to set privileges on - defaults to not set\n    objs: # list of database objects to set privileges on - defaults to not set\n    schema: # defaults to not set\n    session_role: # defaults to not set\n    fail_on_role: # defaults to true\n    grant_option: # defaults to not set\n    target_roles: # defaults to not set\n    login_host: # defaults to 'localhost'\n    login_password: # defaults to not set\n    login_user: # defaults to '{{ postgresql_user }}'\n    login_unix_socket: # defaults to 1st of postgresql_unix_socket_directories\n    port: # defaults to not set\n    state: # defaults to 'present'\n```\n\nA list of privileges to configure (new in role version 4.0.0).\n\n```yaml\npostgres_users_no_log: true\n```\n\nWhether to output user data (which may contain sensitive information, like passwords) when managing users.\n\n```yaml\npostgresql_version: [OS-specific]\npostgresql_data_dir: [OS-specific]\npostgresql_bin_path: [OS-specific]\npostgresql_config_path: [OS-specific]\npostgresql_daemon: [OS-specific]\npostgresql_packages: [OS-specific]\n```\n\nOS-specific variables that are set by include files in this role's `vars` directory. These shouldn't be overridden unless you're using a version of PostgreSQL that wasn't installed using system packages.\n\n## Dependencies\n\nNone.\n\n## Example Playbook\n\n```yaml\n- hosts: database\n  become: yes\n  vars_files:\n    - vars/main.yml\n  roles:\n    - geerlingguy.postgresql\n```\n\n*Inside `vars/main.yml`*:\n\n```yaml\npostgresql_databases:\n  - name: example_db\npostgresql_users:\n  - name: example_user\n    password: supersecure\n```\n\n## License\n\nMIT / BSD\n\n## Author Information\n\nThis role was created in 2016 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).\n","funding_links":["https://github.com/sponsors/geerlingguy","https://patreon.com/geerlingguy"],"categories":["Jinja","sql"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fansible-role-postgresql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeerlingguy%2Fansible-role-postgresql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fansible-role-postgresql/lists"}