courseworkrep/roles/postgresql/tasks/databases.yml
2024-12-08 22:11:48 +03:00

19 lines
522 B
YAML

- name: Create PostgreSQL database
community.postgresql.postgresql_db:
name: '{{ postgres_db }}'
owner: '{{ postgres_user }}'
encoding: UTF8
state: present
- name: Create contacts table
community.postgresql.postgresql_query:
db: '{{ postgres_db }}'
query: |
CREATE TABLE IF NOT EXISTS contacts (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
phone_number VARCHAR(15) UNIQUE
);
login_user: '{{ postgres_user }}'
login_password: '{{ postgres_password }}'