| --- |
| # postgresql tasks/main.yml |
| # |
| # SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org> |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| - name: include OS-specific vars |
| include_vars: "{{ ansible_os_family }}.yml" |
| |
| - name: include OS-specific tasks |
| include_tasks: "{{ ansible_os_family }}.yml" |
| |
| # docs: https://docs.ansible.com/ansible/latest/modules/postgresql_user_module.html |
| # using no_log to not expose the user's postgres password at runtime, see docs: |
| # https://docs.ansible.com/ansible/latest/reference_appendices/logging.html |
| - name: Create PostgreSQL Database Users |
| postgresql_user: |
| name: "{{ item.name }}" |
| password: "{{ item.password }}" |
| with_items: "{{ pgsql_users }}" |
| no_log: true |
| become: true |
| become_user: "{{ pgsql_unix_username }}" |
| |
| # docs: https://docs.ansible.com/ansible/latest/modules/postgresql_db_module.html |
| - name: Create Databases |
| postgresql_db: |
| name: "{{ item.name }}" |
| owner: "{{ item.owner }}" |
| template: "template1" |
| with_items: "{{ pgsql_databases }}" |
| become: true |
| become_user: "{{ pgsql_unix_username }}" |